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: tlee at lehman dot com (Travis Lee)
Subject: Re: how to do this in perl
Date: Jun 18 1998 7:22PM

thanks Michael, it works.

i should have elaborated a bit more in my previous email.
i did it as the following but unable to get the value.

$syb->dbcmd($query);
$syb->dbsqlexec();
while($syb->dbresults() != NO_MORE_RESULTS) {
  while(@data = $syb->dbnextrow()) {
...



it's my first time to use $syb->sql().



> hi,
>  > 
>  > i'm trying to test the existence of data from a table then do something
>  > accordingly.
>  > how can i get the status value from this query in perl?
>  > this is not a stored proc.
>  > 
>  > if(exists (select * from atable))
>  > 	select 0
>  > else
>  > 	select 1
>  > 
>  > any suggestions?
> 
> One simple way to do this would be:
> 
> $dat = $dbh->sql("
> if(exists (select * from atable))
>  	select 0
>  else
>  	select 1
> ");
> 
> if($dat->[0]->[0] == 1) {
> 	do your stuff
> }
> 
> Alternatively, if you know what you need to do you can build the whole 
> SQL and then send it off in one go:
> 
> $data = $dbh->sql("
> if exists ( select * from atable )
>   begin
> 	-- add appropriate code to be executed if data exists
>   end
> else
>   begin
> 	-- etc
>   end
> ");
> 
> By using appropriate variables, etc you can build the SQL so that the
> right thing gets executed, and retrieve any results in $data...
> 
> Michael
> -- 
> Michael Peppler         -||-  Data Migrations Inc.
> mpeppler@datamig.com    -||-  http://www.mbay.net/~mpeppler
> Int. Sybase User Group  -||-  http://www.isug.com
> 
>