× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.



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-2024 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.