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.... #!/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; } $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"; -----Original Message----- From: Steve Bertrand [mailto:st...@ipv6canada.com] Sent: Tuesday, May 04, 2010 11:44 AM To: Pam Wampler Cc: beginners@perl.org Subject: Re: how to denote the like symbol % in perl program On 2010.05.04 11:21, Pam Wampler wrote: > How do you add the % sign in a perl program, if you are doing an oracle > query in the program? > > Example ....select date, name from my_table where name like upper(?)% > > > > The question mark would allow the user to enter the name - and I need to > append the % sign so that oracle will know to do a like search. What code do you have so far? Without any idea of what you've tried, my first suggestion is to use DBIx::Class, and searches are clean and easy: my $rs = $schema->resultset( 'Plans' )->search( { plan => { -like => "%$plan_name%" }}, { plan_status => $status }, ); while ( my $record = $rs->next ) { ...show us what you have so far... 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/