Nathan

you are wrong, your statement should be ...

await step 1: check foreign-key relationship #1
await step 2: check foreign-key relationship #2
await step 3: check foreign-key relationship #3
await step 4: check foreign-key relationship #4
await step 5: check foreign-key relationship #5
await step 6: check foreign-key relationship #6
await step 7: check foreign-key relationship #7
await step 8: check foreign-key relationship #8
step 9: return success message to client.

while you await other requests can use the tread for processing so what
you see happens are

await step 1 req 1: check foreign-key relationship #1
await step 1 req 2: check foreign-key relationship #1
await step 2 req 1: check foreign-key relationship #2
await step 3 req 1: check foreign-key relationship #1
await step 3 req 2: check foreign-key relationship #3
await step 4 req 2: check foreign-key relationship #4
await step 4 req 1: check foreign-key relationship #1
await step 5 req 2: check foreign-key relationship #5
await step 6 req 2: check foreign-key relationship #6
await step 7 req 1: check foreign-key relationship #1
await step 7 req 2: check foreign-key relationship #7
await step 8 req 2: check foreign-key relationship #8
step 9 req 2: return success message to client.
await step 8 req 1: check foreign-key relationship #8
step 9 req 1: return success message to client.

or someting like that.






On Mon, Mar 19, 2018 at 4:50 AM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:

On Sun, Mar 18, 2018 at 8:22 AM, Bradley Stone <bvstone@xxxxxxxxx> wrote:

Well, SQL inside the JS.
It's how I'd do it with RPG too.


I'll restate that the context for my question was Aaron Bartell's advise to
move away from RPG and implement foreign-key validation in Node.js, using
JavaScript. Given that RPG is off the table in this context, the JavaScript
would obviously invoke SQL statements to check for the existence of
foreign-key relationships.

If I understand the Node event loop and db2 interface correctly, then each
invocation of an SQL statement in Node.js would register a callback to
another JavaScript function, which would be invoked in a later cycle of the
event loop, perhaps 1 to 3 event-loop cycles later, after the results of
the SQL statement have been returned from the database.

I envision an iterative process flow in Node.js that would flow much
differently than how a comparable RPG procedure would work. Correct me if
I'm mistaken, but I envision a Node.js process-flow like the following:

step 1: check foreign-key relationship #1 and callback step 2.
step 2: check foreign-key relationship #2 and callback step 3.
step 3: check foreign-key relationship #3 and callback step 4.
step 4: check foreign-key relationship #4 and callback step 5.
step 5: check foreign-key relationship #5 and callback step 6.
step 6: check foreign-key relationship #6 and callback step 7.
step 7: check foreign-key relationship #7 and callback step 8.
step 8: check foreign-key relationship #8 and callback step 9.
step 9: return success message to client.

Each step might return an error message instead of invoking the next step.

Depending on number of events that might occur in the event loop, Node.js
might require from 9 to some larger number event cycles before returning a
message to a client. Am I the only one here who sees advantages to calling
an RPG procedure to perform the validation? Just consider the overhead of
repetitive db2 connect=>run SQL=>disconnect cycles.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.