|
|
sybperl-l Archive
Up Prev Next
From: "Sheree Hemphill" <sah18 at po dot cwru dot edu>
Subject: RE: very basic db connection question
Date: Feb 10 1999 4:33PM
thank you again for your help.
your examples help immensely.
i did find the sybperl man page from your website & this looks helpful also.
are there additional sample programs to be found anywhere else? i find
examples seem to be the best way to learn when i'm just getting started.
sheree
> -----Original Message-----
> From: owner-SYBPERL-L@listproc.net
> [mailto:owner-SYBPERL-L@listproc.net]On Behalf Of Michael Peppler
> Sent: Wednesday, February 10, 1999 10:36 AM
> To: SybPerl Discussion List
> Subject: RE: very basic db connection question
>
>
> >>>>> "Sheree" == Sheree Hemphill writes:
>
> Sheree> this worked just fine for me! one more question on this: i'm
> Sheree> not quite clear as to the difference between ct_sql and
> Sheree> ct_execute. when would you use one over the other (ie, why
> Sheree> couldn't the "use database" command be passed via ct_execute
> Sheree> instead)? thank you once again, sheree
>
> The ct_execute() call sends the SQL command to the server, but does
> not fetch any results. You have to call ct_results() (in a loop) and
> ct_fetch() (as in Frédéric's example).
>
> ct_sql() sends the SQL command to the server *and* retrieves all the
> results. In my example I was ignoring any results because "use
> database" doesn't return any.
>
> But if I was querying the database (using SELECT) I would do something
> like this:
>
> $data = $dbh->ct_sql("select * from sysusers");
> foreach $row (@$data) {
> print "$$row[0] - $$row[3]\n";
> }
>
> # Prints the suid and name of each user in the default database...
>
> This is documented in the sybperl man page, which is part of the
> distribution, or is available on my web page.
>
> Hope this helps,
>
> Michael
>
>
> >> -----Original Message----- From: owner-SYBPERL-L@listproc.net
> >> [mailto:owner-SYBPERL-L@listproc.net]On Behalf Of Michael Peppler
> >> Sent: Tuesday, February 09, 1999 4:48 PM To: SybPerl Discussion
> >> List Subject: very basic db connection question
> >>
> >>
> >> >>>>> "Sheree" == Sheree Hemphill writes:
> >>
> Sheree> Hello. I am new to Sybperl, and I would like to use CTlib to
> Sheree> connect to a database. I can only seem to find code examples
> Sheree> which connect to the Master database, but none which show how
> Sheree> to connect to a user-defined database. Can someone give me an
> Sheree> example of the syntax for this?
> >> $dbh->ct_sql("use $database");
> >>
> >> Michael -- Michael Peppler -||- Data Migrations Inc.
> >> mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler Int. Sybase
> >> User Group -||- http://www.isug.com Sybase on Linux mailing list:
> >> ase-linux-list@isug.com
> >>
> >>
>
>
>
> --
> Michael Peppler -||- Data Migrations Inc.
> mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
> Int. Sybase User Group -||- http://www.isug.com
> Sybase on Linux mailing list: ase-linux-list@isug.com
>
>
|