xdenser / node-firebird-libfbclient

Firebird SQL binding
MIT License
82 stars 34 forks source link

Procedure return values not coming in correctly #120

Closed asgeira13 closed 3 years ago

asgeira13 commented 3 years ago

Just encountered a problem while updating my libraries and think it is easy to replicate.

Firebird database version: Firebird 3.0.2 Node version: 8.16.1 & 15.6.0 node-firebird.-libfbclient: 0.1.1 - 0.1.4

Problem: When executing a procedure query with the node firebird library the return values are always NULL using any version after 0.1.1.

Replication:

Run a firebird database and create a simple procedure like this:

SET TERM ^ ; CREATE OR ALTER PROCEDURE TESTINGPROCEDURE (TESTINPUT BIGINT) RETURNS ( TESTOUTPUT BIGINT ) AS declare variable CON integer; declare variable MAXCON integer; begin :TESTOUTPUT = :TESTINPUT; end;^ SET TERM ; ^

Create a node project with node version 8.16.1 or newer and install the firebird library version 0.1.4 and run the following code

function test() {

    const connection = fb.createConnection();

    connection.connectSync("<yourdatabase>", "<youruser>", "<yourpassword>", "");

    const query = "EXECUTE PROCEDURE TESTINGPROCEDURE (1);"

    connection.startNewTransaction((err, transaction) => {
        transaction.query(query, (err, result) => {
            if(err) {
                console.log(err);
            }    
            transaction.commit(err => {
                console.log(result);
            })    
        });
    });
}

test();

The expected output would then be { TESTOUTPUT: 1 } but in version 0.1.2-0.1.4 it gives { TESTOUTPUT: NULL }

Maybe I am using procedures wrong but it used to work in 0.1.1 and it seems from 0.1.2 on it stopped working.

Hopefully you guys have time to check it out.

Thanks in advance