xdenser/node-firebird-libfbclient — Issue #5: passing date to a stored procedure
Author: xdenser
Created: 2011-12-19 20:29:29+00:00
State: open

I have the following stored procedure:

CREATE PROCEDURE insert_member
(
username VARCHAR(25),
created_date TIMESTAMP
)
AS
BEGIN
INSERT INTO users (username, created_date) VALUES(:username, :created_date);
SUSPEND;
END^

When I run the following:
function run_query(username, created_date){
var conn = fb.createConnection();
conn.connect(cfg.db, cfg.user, cfg.password, cfg.role, function() {
var res = conn.prepareSync('EXECUTE PROCEDURE insert_member(?,?)');
res.on('result', function() {
res.fetch('all', true, function(row) {
});
});
res.exec.apply(res, args);
});
}

I tried running the following:
run_query('test', new Date()); ///Causes Firebird Database Server process itself to crash and your driver to throw error: Expecting Date as argument #2
run_query('test', '12/17/2011'); //Error: Expecting Date as argument #2
run_query('test', '2011-12-17'); //Error: Expecting Date as argument #2
run_query('test', '12-17-2011'); //Error: Expecting Date as argument #2

I can't get pass a Date a Date to the stored procedure without getting the error 'Expecting Date as argument #2'. Do you know how I can pass a date? (I like to avoid using strings if possible and use the javascript Date object).

I also looked at the C++ IsDate function (not an c++ expert) but I think the error is in fbresults.css:
line:
case SQL_TIMESTAMP:
if(!args[i]->IsDate())

I don't understand why it says none of the formats above are valid?