Re: prepared statements in db-lib

"Paul Thurston" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <EAC08B98627344D1AF8D4A5079FB0A05@Paul>
Andy:

 

Right, prepare the SQL statement and feed it normally.

If correctly implemented, your user-defined Parameter class should handle
escaping quotes during SQL statement assembly.

 

Paul

 

 

  _____  

From: Andrew H. Wakefield [mailto:[email protected]] 
Sent: Sunday, February 21, 2010 4:02 PM
To: Paul Thurston
Cc: 'FreeTDS Development Group'
Subject: RE: [freetds] prepared statements in db-lib

 

Paul,

I had considered this option ... but wasn't quite sure of the execution,
other than going into the libtds layer. Is that what you mean, or did you
mean that I could assemble the statement from the parameters and then feed
it to db-lib as a regular sql statement? My concern with the latter is that,
when I have used prepared statements on other platforms, one reason has been
the ability to feed an entire TEXT field into a parameter and not have to
worry about escaping any quote marks inside the string.



Andy Wakefield
[email protected] 

On Sun, 2010-02-21 at 14:57 Paul Thurston wrote: 

Andy:

 

If you are programming in, say C++, it is fairly straightforward to write a
function with this capability.

Have the function take as parameters the tablename, along with vector of
pointers to a user-defined class Parameter.

If each Parameter contains type information, along with the value,
formatting & executing the query string is a snap.

 

 

Best,

 

Paul

 

 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Andrew H. Wakefield
Sent: Sunday, February 21, 2010 2:27 PM
To: [email protected]
Subject: [freetds] prepared statements in db-lib

 

I have been playing with db-lib, and find it to be a very nice

interface. But there is one thing that I seem to be missing, and can't

figure out -- does it not have any way to do a "prepared statement" --

IOW, a statement with parameters that are filled in before execution --

other than as an actual stored procedure?

 

Here's what I want to be able to do, in a mixture of sql and

pseudo-code:

 

sql_statement: INSERT INTO test_tbl VALUES ( ?, ?, ? );

set_param(1, 52)

set_param(2, 'Testing')

set_param(3, 123.456)

execute prepared statement

 

If db-lib cannot do this, can ct-lib? Or do I have to go down to the

libtds layer?

 

Many thanks ...

 

 

Andy Wakefield

[email protected] 

 

On Mon, 2010-01-11 at 21:55 -0500, James K. Lowden wrote:

 

> Andrew H. Wakefield wrote:

> > I

> > downloaded the "nightly snapshot" yesterday and tried to cross-compile

> > for Windows. It failed during the make, using the settings that worked

> > successfully for freetds-0.82. IIRC, the error had something to do with

> > types.h inclusion.

> 

> Tonight's version should be better.  Let us know.  

> 

> --jkl

_______________________________________________

FreeTDS mailing list

[email protected]

http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.