Comments (4)
Well, it's my fault.
Query is just a method to execute a pure SQL statement and follows the solution
SELECT * FROM NEW TABLE (INSERT INTO Users (name, age) VALUES ("Wilk", 26))
By the way, it could be an interesting feature returning the last inserted record after an INSERT sql query ;)
Cheers
Wilk
from node-ibm_db.
Are you using a prepare
statement? I can't seem to get anything back from an INSERT
.
I can't figure out how to INSERT
an escaped string, which leaves me vulnerable to errors and SQL injection. Of course, the prepare
doesn't seem to return the new inserted row.
What a conundrum.
from node-ibm_db.
You can use a prepare statement here, to insert an escaped string. You can use the following code snippet as a reference to use prepare statement.
var value = 'AB$C\'DI';
var queryString = "INSERT INTO ***** VALUES(?)";
conn.prepare(queryString, function(err, stmt) {
stmt.bindSync([value]);
stmt.executeSync(stmt);
console.log('Statement executed');
queryString = "SELECT * FROM *******";
conn.query(queryString, function (err, data) {
if (err) {
console.log('Error recieved: \n'+err);
}
console.log(JSON.stringify(data));
});
conn.close(function(){
console.log("Connection Closed");
});
});
The insert statement will not return the last row. If you need to fetch the key of the last inserted row, in case of auto generated keys, you can use the following query
SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1'
This query will fetch the latest key generated within a transaction scope and return it back to the user.
If this does not resolve your issue, please share more details, so that we can take a look.
from node-ibm_db.
this works, but if another solution exists ... i buy it
SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1
from node-ibm_db.
Related Issues (20)
- string returned after date type requested HOT 1
- Fetch multiple rows HOT 2
- adm-zip can it be moved to dev dependencies HOT 2
- queryResult deferred callback result changed with version 3.2.3 HOT 5
- Node ibm_db Installation Error with Python 3.12 HOT 2
- conn.query callback being fired before all queries are finished. (possibly) HOT 1
- Release v3.2.4 HOT 1
- Bug Report - Could not locate the bindings file. HOT 2
- Having trouble get a valid npm install in a GitLab CI Pipeline HOT 2
- libcrypto.so.1 error HOT 3
- Connection Pooling not working as expected .maxpool and settimeout having issue HOT 5
- I am tryingto install ibm_db in linux and getting error HOT 5
- GSKIT Error HOT 3
- No longer building on npm install HOT 11
- [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 HOT 6
- Q: z/OS license being cached ? HOT 1
- npm install not working with podman HOT 7
- There is no build folder after installation of ibm_db HOT 5
- unhandledrejection
- Support of ibm_db with arm64 for MacOS with M1/M2 Chip HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ibm_db.