PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Connie Zhang" <czhang at fir dot fbc dot com>
Subject: Re: SybPerl Question
Date: Jan 22 1998 4:48PM

Hi Michael,

Your hints are just to to point!!

After I made changes in my scripts following
the stuff you pointed out, all problems
were cleared out! Thank you very,
very much!!!

Connie Zhang
czhang@fir.fbc.com

On Jan 21, 17:24, Michael Peppler wrote:
> Subject: Re: SybPerl Question
> Connie Zhang wrote:
> >
> > Hi, everyone,
> >
> > I was using SybPerl/DBlib for my Perl scripts.
> > Things work fine so far until I got stuck with
> > one problem...Wonder if someone can give some
> > hints...
> >
>
> Several problems.
>
> First you mix Sybase::Sybperl and Syabse::DBlib calls. That
> works, but it's very bad form.
>
> Remove the
> use Sybase::Sybperl
> statement, and change all the &dbxxx($dbh) to $dbh->dbxxx.
>
> >
> > Msg 207, Level 16, State 2
> > Server 'CMOQA', Line 12
> >         Invalid column name 'czhang'.
>
> This is:
>
>                 SELECT \@own_id = owner_id
>                   FROM gml_user
>                  WHERE unix_id = $user_id
>
> You are missing quotes around $user_id (which is almost certainly set
> to czhang).
>
> > DB-Library error:
> >         General SQL Server error: Check messages from the SQL Server.
> > Msg 156, Level 15, State 1
> > Server 'CMOQA', Line 1
> >         Incorrect syntax near the keyword 'AND'.
>
> You've submitted the batch to the server, and then *after* that you
> try to add additional conditionals.
>
> You must build your entire SQL statment first, and then submit it:
>
> 
>
>                      WHERE A.comp_country_cd = C.country_cd
>                        AND A.ret_fax_dt      = 'Jan 1 1900 12:00AM'
>                        AND A.comp_country_cd = B.country_cd");
> &dbsqlexec ($dbh1);
> &dbresults ($dbh1);
>
> # This has now been sent to the server (as if you type 'go'
> # in isql)
>
> while (&dbnextrow ($dbh1))
>   {
>     # do nothing.
>   }
>
> # Now the server becomes very confused when you send it this
> # conditional!
>
> if ($D2 eq "")
>   {
>     $dbh1->dbcmd (" AND A.list_cd = '$D1' ");
>   }
> else
>   {
>     $dbh1->dbcmd (" AND A.list_cd IN \('$D1', '$D2'\) ");
>   }
>
> > Msg 137, Level 15, State 1
> > Server 'CMOQA', Line 1
> >         Must declare variable '@list_id'.
>
> Same problem. T-SQL variables live within one command batch.
> When you sent the batch to the server (with dbsqlexec) a
> new batch is started, and you need to redeclare the variables.
>
> The rest of the errors are all linked to the same problem.
>
> I think that if you move the call the dbsqlexec() to the end of
> your script, and submit everything at once (except maybe the
> COMMIT TRAN) then things should work a lot better...
>
> Michael
> --
> Michael Peppler       -||-  Data Migrations Inc.
> mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler
>-- End of excerpt from Michael Peppler