If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > ESQL/C - SQLDA and the SQLDATE type

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-15-09, 11:59
sd3782 sd3782 is offline
Registered User
 
Join Date: Jun 2009
Posts: 1
ESQL/C - SQLDA and the SQLDATE type

Hi,

I'm trying to use an SQLDA structure to specify the binding variables for my prepared statement. I've got it to work with an SQLINT type, but I can't get it to work with the SQLDATE type, because I get the error:
Quote:
-1205: Invalid month in date.
I have prepared a statement like this (it's a bit more complicated than this actually, and I have to use dynamic SQL (obviously for the below code I wouldn't, but anyway):

Code:
select name, price, descr from catalogue
where date_added >= ?
and quantity >= ?
I used an SQLDA structure and malloc'd it:

Code:
static  sqlda   *bindvars = NULL;
bindvars = (sqlda*)malloc(sizeof(sqlda));
bindvars->sqlvar = malloc(max_n * sizeof(sqlvar_struct));

/* date_int holds the date as the number of days since 31/12/1899
 * as a 4-byte integer
 */
bindvars->sqlvar[0].sqldata = (char*)&date_int;
bindvars->sqlvar[0].sqllen = rtypmsize(SQLDATE, 0);
bindvars->sqlvar[0].sqltype = SQLDATE;

bindvars->sqlvar[1].sqldata = (char*)&quantity;
bindvars->sqlvar[1].sqllen = sizeof(int);
bindvars->sqlvar[1].sqltype = SQLINT;
If I run this without the SQLDATE type (just with the SQLINT and quantity), it works fine. But when I add the date, I get the -1205 error.

What am I doing wrong? I've printed out the contents of all the data variables of the SQLDA and they appear to be correct. It's a 4-byte date: 39978 (15/06/2009), which is surely what it expects, no? Does anyone have any experience with SQLDA?

As I said previously, the rest of the prepared statement is dynamic, so I have to use SQLDA, it's just this beginning bit with the date that is causing me grief!

Thank you in advance!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On