#open connection to the database my $db = DBI->connect("dbi:Oracle:host=$host;sid=$sid;port=$port", $uid, $pwd) or die "Error while connecting to database!!!\nIncorrect Connection information\n"; my $SQL_query; $SQL_query = qq {SELECT A.DISPLAY_ORDER, A.NAME PARENT_NAME, B.NAME CHILD_NAME FROM CATEGORY A, CATEGORY B WHERE B.ID_PARENT_CATEGORY(+) = A.ID_CATEGORY AND A.DISPLAY_ORDER != -1 ORDER BY DISPLAY_ORDER}; debug($SQL_query); my $sth = $db->prepare( $SQL_query ) or die "Can't prepare SQL statement: $DBI::errstr\n"; ### Execute the statement in the database $sth->execute or die "Can't execute SQL statement: $DBI::errstr\n"; my ($pdisplay_order, $parent_name, $child_name); # Bind perl variables to columns: my $rv = $sth->bind_columns(\$pdisplay_order, \$parent_name, \$child_name); ### Retrieve the returned rows of data while ($sth->fetchrow_array()) { chomp($pdisplay_order); chomp($parent_name); chomp($child_name); print "$pdisplay_order, $parent_name, $child_name\n"; }