CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
help in retrieving data from the database

 



datlaravi
Deleted

Jun 26, 2000, 1:21 PM

Post #1 of 2 (223 views)
help in retrieving data from the database Can't Post

 

Hi,
I have kept database columns in an array and given the same name as i have given to the columns in the database) and i am trying to retrieve it.
Here is the code
@fields =
#the following are the columns in the #database,fields in the form have same names ("location","conferenceRoomName","roomNumber","overHead","slideProj","tv_Vcr","videoConference","seats");
$value = 'Lobby';
my $selStr ='';
my $colList = '';
my $recset = '';
my @vals = ();
my %fieldvals =();
for ($i=0; $i < scalar(@fields); $i++)
{
if ($fields[$i] =~ /date/) {
$colList .= "to_char($fields[$i], \'MMDDYYYY\') as $fields[$i]";
} #end if
else {
$colList .= "$fields[$i]"}
if ($i < scalar(@fields)-1)
{$colList .= ","}
}
$selStr ="Select $colList from ConferenceRooms where conferenceRoomName='$value'";
$recset = $syb->prepare($selStr);
@vals =$recset->fetchrow;
$recset->finish;
for ($i =0; $i < scalar(@fields); $i++) {
$fieldvals{$fields[$i]} = $vals[$i];
}
return %fieldvals;
The error is 'no statement executing'.

I want to retrieve the database value in a form.
For example,
if i use
<input type ="text" name ="columnname" value=$fieldvals{'columnname'}>
It will retrieve the database value from the hash.
I was stuck in the above code.

Please help me.


dws
Deleted

Jun 26, 2000, 3:45 PM

Post #2 of 2 (223 views)
Re: help in retrieving data from the database [In reply to] Can't Post

Preparing a query is not the same as exectuting a query.

$recset = $syb->prepare($selStr);

will not give you a record set. Consult the DBI documentation.



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives