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

-- 
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