Question about SQLBindParameter and NULLs
From: JohnD (john_nospam_at_tech-testing.com)
Date: 01/17/05
- Next message: Neil Ginsberg: "Re: SQL Losing Data"
- Previous message: Michael Cheng [MSFT]: "RE: SQL server Login connection failed sqlstate 28000 sql server e"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 17 Jan 2005 16:25:53 GMT
Hello,
I'm trying to understand the correct way to accomplish using the same
SQL statement in a call to SQLPrepare with the following scenario:
Given the table:
my_table (
id IDENTITY NOT NULL PRIMARY KEY,
char_val CHAR(1),
int_val INTEGER
);
And the data:
id char_val int_val
----------------------------
1 'A' NULL
2 'B' 7
3 'C' 10
4 'B' NULL
I would like to be able to use the same SQL statement in a call to
SQLPrepare:
"SELECT id, char_val FROM my_table WHERE int_val = ?"
and use SQLBindParameter specifying NULL data for the bind. However, if
I use:
SELECT id, char_val FROM my_table WHERE int_val IS NULL"
I get different results sets. I know why, however, I'm wondering if
there is a way to accomplish what I'm trying to do with the single
statement using the positional bind? Or do I have to figure out in my
code if I have NULL data and substitute "IS NULL" for the " = ? " properly?
Thanks for any and all responses.
John
- Next message: Neil Ginsberg: "Re: SQL Losing Data"
- Previous message: Michael Cheng [MSFT]: "RE: SQL server Login connection failed sqlstate 28000 sql server e"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|