execute() documentation

Issue #28 resolved
Kristopher Baehr created an issue

The execute() function in the API Reference documentation appears to be out-dated. It's missing the array of output parameters, which is parameter 1. Thanks!

Comments (4)

  1. mengxumx Account Deactivated

    Hello @krisbaehr , did you mention this? --> https://www.ibm.com/developerworks/community/wikis/home/wiki/IBM%20i%20Technology%20Updates/page/DB2%20for%20i%20Access%20APIs%20-%20New?lang=en&section=execute

    Actually the execute() API is very flexible.

    1. If the SQL statement contains no parameter marker ?, then there is only a result set so we need to run fetchAll() to get that in the callback function -->
    execute(()=>{fetchAll(...)}) 
    
    1. If the SQL statement contains parameter markers ?, and there is no result set, then we can directly get the output parameters (js array) in the callback function parameter out -->
    execute((out)=>{console.log(out)}) // out is a js array
    
    1. If the SQL statement contains parameter markers ? along with a result set, then we can directly get the output parameters (js array) in the callback function parameter out , and get the result set with calling fetchAll() in the callback function -->
    execute((out)=>{console.log(out); fetchAll(...))
    

    The API reference says

    Parameter Callback(Out):

    Callback is a callback function. If the output contains parameters of the parameter markers, Out is a list of the output parameters in the java script array format. Otherwise, the callback function takes no output parameter and is only for fetching the result set.

    I think the description is OK or maybe I misunderstood the issue?

  2. Log in to comment