|
|
sybperl-l Archive
Up Prev Next
From: "Patrick S dot Leung" <pleung at easygroup dot com>
Subject: Re: client api layer error
Date: Jun 6 2001 5:33PM
Thanks Michael,
The exact same perl scripts works with any other sybase (on linux) db I
have except for one particular sybase ase on linux. I understand what
you said about the fetch data, and for the sake of completness, here the
entire code fragment:
$query="SELECT id FROM table_one";
$X->ct_execute($query);
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
while(@dat = $X->ct_fetch) {
if($dat[0] eq "") {
last;
}
push @dat_dist, @dat;
$rowcount++;
}
}
/* some perl code here to process the data */
$query="SELECT id2 FROM table_two";
$X->ct_execute($query);
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
while(@dat = $X->ct_fetch) {
if($dat[0] eq "") {
last;
}
push @dat_dist, @dat;
$rowcount++;
}
}
...
repeat for more queries.
What I don't understand is that the script runs file against more of my
recently installed Sybase ASE, but failed on this particular Sybase
which is installed with probably the earlier release.
Almost without a doubt I am using more and more Sybase::Simple for quick
development.
Rgds, Patrick
Michael Peppler wrote:
>Patrick S Leung writes:
> > Dear all,
> >
> > I use a perl script to fetch data from sever sybase ase dbs. The perl
> > scripts are on one linux machine while the db is on another linux
> > machine. All but one sybase server gave me the open client error. I
> > got the error even if I run the perl script on the same machine.
> >
> > Open Client Message:
> > Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (163)
> > Message String: ct_results(): user api layer: external error: This
> > routine cannot be called until all fetachable results have been
> > completely processed.
>
>Your perl code is almost certainly incorrect. You *must* call
>ct_fetch() within the ct_results() loop for *all* result types that
>return rows, even if there are no rows in that result set.
>
>Specifically you need to do something like this (semi-pseudocode):
>
>ct_execute(...);
>while(ct_results($restype) == CS_SUCCEED) {
> next unless ct_fetchable($restype);
> while(@d = ct_fetch) {
> ....
> }
>}
>
>If you don't want to have to mess with all that I strongly suggest you
>take a look at Sybase::Simple, where you have methods that will hide
>all this complexity from you.
>
>Michael
>
|