Ananda has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, Greetings !!
I am facing problem while executing an outer join querry in Oracle 8i DB using Perl.
I am using perl DBI::DBD
#open connection to the database my $db = DBI->connect("dbi:Oracle:host=$host;sid=$sid;port=$port", $ui +d, $pwd) or die "Error while connecting to database!!!\nIncorrect Con +nection information\n"; my $SQL_query; $SQL_query = qq {SELECT A.DISPLAY_ORDER, A.NAME PARENT_NAME, B.NAM +E 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 st +atement: $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"; }
However, when I use the following, I can fetch the values from the tab +le / view #$SQL_query = qq {SELECT display_order, name, id_parent_category from + CATEGORY ORDER BY DISPLAY_ORDER }; #$SQL_query = qq {SELECT display_order, name, id_parent_category f +rom MY_VIEW }; I tried creating a oracle view for the SQL query which has the outer j +oin and used the following query but still I could not display the va +lues from the array. #$SQL_query = qq {SELECT * from VW_CATEGORIES};
Any immediate help is appreciated
CHEERS Ananda
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Reading Database with Outer Joins
by rdfield (Priest) on Jan 13, 2003 at 09:22 UTC | |
by Ananda (Pilgrim) on Jan 13, 2003 at 10:47 UTC | |
Re: Reading Database with Outer Joins
by cadfael (Friar) on Jan 13, 2003 at 17:03 UTC | |
by smersh (Friar) on Jan 13, 2003 at 21:24 UTC |