Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
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 ...");
while(dbresults() != NO_MORE_RESULTS) {
     while(@row = dbnextrow()) {
dbcmd("insert ...");

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 Peppler - Data Migrations Inc. - -
International Sybase User Group -
Sybase on Linux mailing list: