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: mpeppler (Michael Peppler)
Subject: Re: tool search: one row in column-name: value format?
Date: Nov 7 1995 4:18PM

From: "Dennis R. Sherman" 
> 
> * take as input username, password, database, tablename, where-clause
> * produce as output a listing of all rows in the named table that meet
>   the criteria of the where-clause, in a form similar to
>   
> ========== (row separator) ======
> column-name1: value1
> column-name2: value2
> column-name3: value3
> etc.

This is from the top of my head:

#!/usr/local/bin/sybperl

require 'sybperl.pl';
require 'getopts.pl';

&Getopts('P:U:D:T:W:);

# $opt_P is password, $opt_U is user, $opt_D is db_name, 
# $opt_T is table_name, and $opt_W is where clause...

$d = &dblogin($opt_U, $opt_P);
&dbuse($d, $opt_D);
&dbcmd("select * from $opt_T where $opt_W");
&dbsqlexec($d); &dbresults($d);
while(%dat = &dbnextrow($d, 1))
{
    print "========== (row separator) ======\n";
    foreach $col (sort keys(%dat))
    {
         print "$col: $dat{$col}\n";
    }
}

# That's it.
__END__;


Michael

PS. Now I am truly leaving for my holidays... see you all in December :-)