in reply to using DBI oracle to make scrolling lists(drop down menus)

the CGI module provides a method called scrolling_list that makes this sort of thing simple. You pass the function an array of values and a hash of labels for those values. I usually do this by reference to keep it clean. I would do something like this
#!/usr/bin/perl -w use DBI; use CGI qw(:standard); use strict; #You connect to Oracle in a similar way I'm sure... my $driver = "mysql"; my $database = "blah"; my $hostname = "blah"; my $dsn = "DBI:$driver:database=$database;host=$hostname"; my $dbh = DBI->connect($dsn,undef,undef); print header,start_html,"\n"; my $people_query = $dbh->prepare("SELECT SS_NUMBER, FIRST_NAME +, LAST_NAME FROM people"); $people_query->execute; my %people_hash; #creat a hash of "fname lname" keyed by SSN while (my @people_array = $people_query->fetchrow_array) { $people_hash{"$people_array[0]"} = "$people_array[1] $ +people_array[2]"; } #create a list of the SSNs maybe sort it? my @people_keys = sort{$a <=> $b} keys %people_hash; print table( Tr( td( ['Some people:', scrolling_list( -name =>'people', -values =>\@people_keys, -labels =>\%people_hash, -size=>1) ]), ), ); print end_html;

Replies are listed 'Best First'.
Re: Re: using DBI oracle to make scrolling lists(drop down menus)
by rdfield (Priest) on Jan 22, 2002 at 15:50 UTC
    Personally I prefer to do the sorting in Oracle:
    $sql = "SELECT ss_number, last_name || ' ' || first_name NAME FROM people ORDER BY 2";
    and using
    $people_hash{$people_array[0]} = $people_array[1]; push @people_keys,$people_array[0];
    to populate the local storage structures.
    Just a matter of style, really. I haven't done any benchmarking, but Oracle Corp spends a lot of money writing code to make sorting effecient :)

    rdfield