![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
I am having a problem with my application that uses ODBC. I am doing the following: * prepare a statement * Bind * execute The problem is that my application needs to accept only insert queries with parameter markers since it later writes to the database depending on the values in the SQL query. It seems that SQLBindParameter does not return any Error/Info when there are no parameter markers to bind variables to in the statement. |
|
I would expect this call to fail or at least generate some info to suggest to the caller that the query had no parameters to bind variables to! Is there any way to find out using ODBC calls given a handle to a statement whether this is an insert statement and how many parameter markers are in the statement? |
|
I tried the SQLGetDiagField function with the SQL_DIAG_DYNAMIC_FUNCTION identifier to get the kind of statement but this would not tell me the number of parameter markers in the query. Moreover this approach may not work if the user uses a stored procedure in it. I want to avoid parsing the sql statement to get this info. |
|
I would appreciate if someone could give me some information on this. TIA, Nilesh |
#3
| |||
| |||
|
|
I tried the SQLGetDiagField function with the SQL_DIAG_DYNAMIC_FUNCTION identifier to get the kind of statement but this would not tell me the number of parameter markers in the query. Moreover this approach may not work if the user uses a stored procedure in it. I want to avoid parsing the sql statement to get this info. To deduce whether or not the SQL is an insert statement, one would normally examine the SQL statement and see if it starts with the keyword "INSERT". Not a whole lot to parse there... I don't know how one would do this if only the statement handle were available ... normally, you start with a connection handle and an SQL string in order to allocate a statement handle. How is the statement handle allocated? |
#4
| |||
| |||
|
|
Thanks for the info. The reason why I am not doing something simple like looking at the first word to see if it is INSERT is because the user can use a stored procedure named "foo" which has the insert statement in it! So I want it to be more general. Any suggestions? |
![]() |
| Thread Tools | |
| Display Modes | |
| |