×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




That does seem to work, but I'm interested in getting the entire result set
like when you just use db.exec with an SQL statement.

Is that not possible? I notice you're not using the callback. Or I'm
misunderstanding the use of the callback. :) This does help, though. I
will dig deeper.

On Mon, Apr 4, 2016 at 8:57 AM, Aaron Bartell <aaronbartell@xxxxxxxxx>
wrote:

Check out this example:

var db = require('/QOpenSys/QIBM/ProdData/Node/os400/db2i/lib/db2')
try{
db.init();
db.conn("*LOCAL");
var sql = 'select * from QIWS.QCUSTCDT where LSTNAM like ?'
db.prepare(sql)
db.bindParam([
['%S%', db.SQL_PARAM_INPUT, 0]
])
db.execute();
var rc;
do{
rc = db.fetch(function callback(row) {
console.log(row);
});
} while(rc != db.SQL_NO_DATA_FOUND);
db.close();
} catch(e) {
db.close();
console.log(e);
}

Aaron Bartell
litmis.com - Services for open source on IBM i


On Mon, Apr 4, 2016 at 7:11 AM, Bradley Stone <bvstone@xxxxxxxxx> wrote:

That makes sense about the varchar. ... thanks.

Still getting nothing in my result sets. See anything wrong with my
prepared statement? Debug looks good.

Connect to *LOCAL
Connected to *LOCAL with ID .
SQL: select CMEMAIL, CMLNAME, CMFNAME, CMFCOMP, CMFADD1, CMFADD2,
CMFCITY,
CMFSTATE, CMFZIP, CMFCNT, CMNOTES from bvscomp.cstmstpf where
UCASE(CMEMAIL) like ?
Bind Parameter [1] = %STONE%
SQLExecute() rc=0.
SQLRowCount() rc=0.

var sql = 'select * from cstmstpf where UCASE(CMEMAIL) like ?';

db.init();
db.conn(DBname);
db.prepare(sql);
db.bindParam([
['%' + email + '%', db.SQL_PARAM_INPUT, 0],
]);

try {
db.execute(function callback(out) {
console.log(out);
res.render('customerList', {customerList: out});
});
} catch(e){
console.log('error: ' + e + ' for sql statement ' + sql);
}

I've tried a few different SQL statements, even ones without any
parameters
and they don't work when using the prepare... but if I run the same SQL
statement through exec it works fine.


--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.