That worked!!!!  Thank you so very much...I have been beating my head
against the wall on this one.....

Thanks for helping while I am trying to learn perl!!!

Have a great day!

Pam

-----Original Message-----
From: Steve Bertrand [mailto:st...@ipv6canada.com] 
Sent: Tuesday, May 04, 2010 12:19 PM
To: Pam Wampler
Cc: beginners@perl.org
Subject: Re: how to denote the like symbol % in perl program

On 2010.05.04 12:11, Pam Wampler wrote:
> Here's the code -- I'm just learning perl so any help is greatly
> appreciated
> 
> It will work if I have the user input something like pam% with the
> percent sign...but I really just want the user to have to enter pam
and
> have the program append the %percent sign....

Ok. without getting into detail in regards to the code itself (I haven't
used DBI in quite some time), see if my one-line addition to your code
helps:


> #!/usr/bin/perl -w
> 
> use DBI;
> 
> print "Content-type: text/html\n\n";
> $dbh = DBI->connect("DBI:Oracle:mydb", 'mydb', 'mydb')
>     or die "can't make 1st database connect: $DBI::errstr\n";
> my $sth = $dbh->prepare("select username,default_tablespace from
> dba_users where username like upper(?)")
>     or die "Can't prepare statement: " . $dbh->errstr;
> print "Enter name to search for  ( exit to end application) ";
> while ($name = <>)  {
>   my @data;
>   chomp $name;
>   if ($name eq 'exit') {
>    exit;
> }

$name .= "%";

>   $sth->execute($name)
>    or die "couldn't execute statement: ". $sth->errstr;
> while (@data = $sth->fetchrow_array()) {
>     my $wholename = $data[0];
>         my $tablespace = $data[1];
>     print "\tname: $wholename \n";
>     print "\tdefault tablespace_name: $tablespace \n";
> }
> 
> if ($sth->rows == 0) {
>    print "No names matched $name',\n\n";
> }
> $sth->finish;
> print "\n";
> print "Enter name> ";
> }
> $dbh->disconnect;
> 
> $rv = $sqlQuery->execute
> or die "can't execute the query: $sqlQuery->errstr";
> 

Steve

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.814 / Virus Database: 271.1.1/2850 - Release Date: 05/04/10
02:27:00

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to