List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:January 23 2008 5:02pm
Subject:Re: Using Variables in Insert
View as plain text  
In the last episode (Jan 23), Kc9cdt@stripped said:
> In a message dated 1/23/2008 2:02:46 AM Eastern Standard Time, 
> dnelson@stripped writes:
> >
> Dan,
> Thanks very much for responding to my problem post.
> I was hoping I was just missing something in the syntax.
> Looks like I made a very big mistake recommending MySql to my Client.
> I have hundreds of SQL statements in the code I am converting for
> them. It is C code in IBM DB/2 running on OS/2 right now and I need
> to get them to Windows. It would take forever to do it the way the
> example shows. I recommended MySql because of previous experience
> with it being good ( and IBM's DCConnect high level script
> language).
> I never would have dreamed that a great DB engine like MySql would
> have so poor of implementation in C as this!

I would guess that since most scripting languages provide their own
bind variable syntax (I think the official name is "parameter
markers"), the lack of named variables in the C API itself wasn't seen
as much of a problem.  Or, the author might have used ODBC as a
reference, since it looks like it only supports the "?" syntax:
> Question, I wander how the IBM DCConnect script applications I have
> written do not have this problem? They use ODBC connections. I know
> the IBM DCConnect is written in C (Under my code) and I know it works
> the 'same way' in DB/2, SqlServer AND MySql. I just use a colon in
> front of the variable name in the SQL statement to get it to
> substitute the real value in when executed (like the sample I
> provided on the post). What do you think about this?

It may be that DCConnect has its own bind variable implementation to
ensure the same syntax no matter what underlying database you are
using.  MySQL didn't even have prepared statements at all until 4.1,
and if DCConnect supports them in earlier MySQL versions, it must have
done the work itself.

> I tried another approach... building the SQL statement string with
> sprintf, still a pain, but may be easier then the
> 'mysql_stmt_execute'.

	Dan Nelson
Using Variables in InsertKc9cdt23 Jan
  • Re: Using Variables in InsertDan Nelson23 Jan