Re: C API Prepared Statement Parameter not bind
Posted by: Joseph Dimech
Date: November 21, 2005 12:37PM

Armin,

I ran your test code on my test system.

I first had to change your declaration for the "is_null" variable in order to make my compiler happy to the following:

my_bool is_null;


Afterwards, I was able to run the program. Your program actually is returning data. The main problem, however, I ran into your print error statment after the fetch statment. You have the following fetch statement:

while (!mysql_stmt_fetch(stmt))
{
printf("error %-s\n");
}

However you should have the the following instead:


while (mysql_stmt_fetch(stmt))
{
printf("error %-s\n");
}

Notice I have removed the "not" ("!") operator from the fetch statment. After all, you are olny returning one row. And you should only be stopping at the "printf(...) statment if there was "no data" or an actual error. So your code was returning data but your logic is incorrectly acting as if there was an error or no data when in reality there was data (or no MYSQL_NO_DATA code returned). The fetch was actually working as I had stated above! Now, it may be that you just have a typo in your posting and I'm off base. Because this would not explain why you were seeing good results when you hard coded the query statement and no results when you used an input bind. They should have behaved the same way in both instances. I can not tell why it worked one way and not the other since you did not have that other example posted.

Hope this helps.

Joe

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: C API Prepared Statement Parameter not bind
475
November 21, 2005 12:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.