Improving DBD::Sybase support, suggestion

Michael Peppler mpeppler at peppler.org
Fri Dec 17 11:42:17 EST 1999


Brian Bruns writes:
 > On 12/16/99, "Michael Peppler <mpeppler at peppler.org>" wrote:
 > > Adrian Blakey writes:
 > >  > In some offline email with Michael Peppler I was told that ct_capability()
 > >  > currently always returns false. The result from this is used by DBD::Sybase
 > >  > to determine whether things like parameterized queries are supported (?
 > >  > placeholders).
 > >  > 
 > >  > Is improving ct_capability on the near-term todo list? ( :-) )
 > > 
 > We started returning false to make DBD::Sybase test happy.  It then went on 
 > the  long term todo list. Problem is I know that sybase supports some of 
 > this from the server end, but I'm not exactly sure how.  If somebody sends 
 > me a script that uses placeholders I can probably see what is going on, and 
 > then we'll know how difficult it is.


#!/usr/bin/perl -w

use DBI;

my $dbh = DBI->connect('dbi:Sybase:', 'sa', '');
my $sth = $dbh->prepare("select * from sysusers where suid > ?");
$sth->execute(0);
while(my $d = $sth->fetch) {
    print "@$d\n";
}
$dbh->disconnect;



 > The other approach is to simply 
 > implement it all on the client side, which has the advantage of working 
 > against older Sybase engines and MS SQL as well.

True - but it can get pretty hairy, and of course it negates the
advantage of using prepared statements (where the SQL is compiled once 
into a temporary stored proc and then run multiple times)

Also - getting the types of each parameter from the client is probably 
not a simple task. Again the protocol helps us here by doing this for
us in an efficient manner.

Michael


 > > Specifically there are a few calls that would need to be supported:
 > > 
 > > 	CS_BOOL val;
 > > 	CS_RETCODE ret = ct_capability(imp_dbh->connection, CS_GET, CS_CAP_REQUEST,
 > > 			    CS_REQ_DYN, (CS_VOID*)&val);
 > > 
 > > is used to test for the "dynamic sql" capability.
 > > 
 > > 	ret = ct_dynamic(imp_sth->cmd, CS_PREPARE, imp_sth->dyn_id,
 > > 			 CS_NULLTERM, statement, CS_NULLTERM);
 > > 
 > > is needed to "prepare" a "dynamic" statement (one that includes
 > > ?-style placeholders)
 > > 
 > > 	ret = ct_dynamic(imp_sth->cmd, CS_DESCRIBE_INPUT, imp_sth->dyn_id,
 > > 			 CS_NULLTERM, NULL, CS_UNUSED);
 > > 
 > > Is used to get information on the parameters that are represented by
 > > the ? placeholders (this is btw much superior to most other data
 > > engines - most don't provide this capability (or at least that's what
 > > I understand from the DBI mailing list...)
 > > 
 > > 	if(ct_dynamic(imp_sth->cmd, CS_EXECUTE, imp_sth->dyn_id, CS_NULLTERM,
 > > 			 NULL, CS_UNUSED) != CS_SUCCEED)
 > > 
 > > Execute the dynamic statement.
 > > 
 > >     ret = ct_dynamic(imp_sth->cmd, CS_DEALLOC, imp_sth->dyn_id,
 > > 		     CS_NULLTERM, NULL, CS_UNUSED);
 > > 
 > > Dealloc (drop) the dynamic statement.
 > > 
 > > Michael
 > > -- 
 > > Michael Peppler         -||-  Data Migrations Inc.
 > > mpeppler at peppler.org    -||-  http://www.mbay.net/~mpeppler
 > > Int. Sybase User Group  -||-  http://www.isug.com
 > > Sybase on Linux mailing list: ase-linux-list at isug.com
 > 
 > ---
 > You are currently subscribed to freetds as: mpeppler at peppler.org
 > To unsubscribe, forward this message to $subst('Email.Unsub')
 > 

-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler at peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list at isug.com



More information about the FreeTDS mailing list