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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: multiple cmds?
Date: Jun 5 2001 2:14PM

Rickard Andersson (EMW/L/HDE) writes:
 > hi everyone!
 > 
 > I have a short question. how do i send multiple cmd:s with sybperl . All
 > i have to do is to insert som values into a table.
 > but dbh->dbcmd; and dbh->dbsqlexec; doesnt work .... is there something
 > else that i can use ?

I don't understand the question.

If I interpret what you ask I assume that you mean that you have
several inserts to perform sequentially. If so, you can do this either
by calling dbcmd() several times, or by building a SQL statement with
several insert statements, or by using nsql() or various other ways.

Mainly what you need to understand is that each time you call
dbsqlexec() to send a SQL command to the server, you have to call
dbresults() and dbnextrow() in loops to retrieve *all* results that
you SQL command generated before executing a new command.

So you might want to do:

dbcmd("insert ...");
dbsqlexec();
while(dbresults() != NO_MORE_RESULTS) {
     while(@row = dbnextrow()) {
        ....
     }
}
dbcmd("insert ...");
etc.

You can also call dbcmd() multiple times *before* calling
dbsqlexec(). Or you can use nsql() which combines a number of features
in an easy to use package.

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