We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
Following this link, I came out following working code:
append_item_photo(itemno: number, caption: string, filename: string) { return new Promise((resolve, reject) => { try { let sql = `insert into picture(PICTNO, CAPTION, ITEMNO, JPEG) VALUES(GEN_ID(PICTNO_GEN, 1 ), '${caption}', ${itemno}, ? )` var stmt = this.con.prepareSync(sql); var blob = this.con.newBlobSync(); var strm = new fb.Stream(blob); var fstrm = fs.createReadStream(filename); fstrm.resume(); fstrm.pipe(strm); let cn = this.con strm.on("close", function () { stmt.execSync(blob) cn.commitSync(); resolve(true) // cb(); }); strm.on('error', function (err) { console.log('error in write blob stream ', err); }) } catch (error) { resolve(false) } }) }
Now, I'd like to do this in a specific transaction, following is the code, but got 'invalid BLOB ID':
append_item_photo(itemno: number, caption: string, filename: string) { return new Promise((resolve, reject) => { this.con.startNewTransaction(async (err, tx) => { try { let sql = `insert into picture(PICTNO, CAPTION, ITEMNO, JPEG) VALUES(GEN_ID(PICTNO_GEN, 1 ), '${caption}', ${itemno}, ? )` var stmt = tx.prepareSync(sql); var blob = this.con.newBlobSync(); // this uses default transaction? var strm = new fb.Stream(blob); var fstrm = fs.createReadStream(filename); fstrm.resume(); fstrm.pipe(strm); strm.on("close", function () { stmt.execInTransSync(tx, blob) tx.commitSync(); resolve(true) }); strm.on('error', function (err) { console.log('error in write blob stream ', err); }) } catch (error) { resolve(false) } }); }) }
looks like :
var blob = this.con.newBlobSync();
it should have been
var blob = tx.newBlobSync();
but Transaction does not have newBlobSync()
any idea how to do it? Thanks
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
Following this link, I came out following working code:
Now, I'd like to do this in a specific transaction, following is the code, but got 'invalid BLOB ID':
looks like :
it should have been
but Transaction does not have newBlobSync()
any idea how to do it? Thanks
The text was updated successfully, but these errors were encountered: