|
|
sybperl-l Archive
Up Prev Next
From: ye wei <yw at alabanza dot net>
Subject: Re: How to implement Statement handle in CTlib?
Date: Apr 10 2000 1:34AM
Michael Peppler wrote:
> ye wei writes:
> > Michael Peppler wrote:
> >
> > > ye wei writes:
> > > >
> > > > Compare with DBI, I perfer Sybperl, because sybperl is much more
> > > > flexiable, but
> > > > I wonder if is there any way to implement a statement handle or have
> > > > more than 1 database
> > > > handles in a script but only keep 1 database connection in CTLib?
> > >
> > > > So, I wonder is there any way to implement something like
> > > > DB_Handle/Statment_Handle (DBI conception) in CTLib?
> > > > I spent some time to study DBD::Sybase, it seems that ct_dynamic() is
> > > > used for allocate a statement handle.
> > > > But ct_cynamic() is not supported in CTLib.
> > >
> > > Read the documentation for DBD::Sybase closely. If you open more than
> > > one statement handle on a connection handle DBD::Sybase will create an
> > > additional physical connection to the database.
> >
> > Yes, that's true. However, it seems that with DBD::Sybase, I can
> > use only *one* database connection to call do() to execute non-query
> > statements with a db handle,
> > while I open a statement handle to hold some pending results.
> >
> > $sth = $dbh->prepare("select foo from tblBar");
> > $sth->execute();
> > while(@row=$sth->fetchrow()) {
> > ## with dbh execute SQL while statement handle is open
> > $dbh->do("update tblBar set balance=2 ...");
> > ...
> > }
>
> Wrong.
>
> The $dbh->do() call *will* open a second connection for you, even
> though you may not be aware of it.
>
> Trust me - I wrote it that way :-)
Michael,
I do trust you very much, I also have alot of thanks for you - Thanks you too
much to contribute the Sybperl and DBD::Sybase,
so that we can write Perl and connect to Sybase so easily!!!! :-)
So now I see the do() will open the second connection to sybase server, and
quickly
close the connection after the sql command has been executed. This explains that
I didn't notice
the connection number increase by running sp_who at server side.
But it makes me worry about the performance problem. Usually, open an connection
is a time consume operation.
If do() opens an addition connection then close it, assume that if a script run
alot of do() while have an opening a statement
handle to hold some pending results, I think it will cause poor performance. Is
that correct?
I'm not sure how fast to make a connection to sybase server, but I think a lot of
open connections will make both client
and sybase performance drop down. Consider we have some cgi scripts need to
connect to sybase, a big website will launch alot
of cgi scripts at the same time, if every one need open more than 1 connections,
I think it will cause problem.
Thanks very much!!
>
>
> Michael
> --
> Michael Peppler -||- Data Migrations Inc.
> mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler
> Int. Sybase User Group -||- http://www.isug.com
> Sybase on Linux mailing list: ase-linux-list@isug.com
--
Sincerely,
Ye wei
|