Search code examples
node.jsoracle-databasenode-oracledb

how can i execute multiple sql queries with node oracledb plugin in one session


I am using node oracle-db plugin for accessing my oracle database deployed at remote server. I need to execute multiple UPDATE queries in one session only. I am not able to modify multiple values in database.

For now this example statement is setting 9000 for both the PIDs. I need different values for both PIDs

UPDATE product_master 
SET prod_bal= :bal 
WHERE pid in (100857,100861),[9000]

Solution

  • Would something like this help?

    update product_master set
      prod_bal = case when pid = 100857 then 100
                      when pid = 100861 then 200
                 end
    where pid in (100857, 100861);             
    

    100 and 200 are hardcoded values in this example; you'd use two variables, obviously.