I am new to perl and i need help in getting output of a sql statements to one variable .can anyone provide me a sample perl code.Below are the sql's i am running and i kept all those sql in one file select instance_name,host_name from v\$instance; select sysdate from dual; select status,destination,dest_id from v\$archive_dest where status ='VALID';
below is the sample code i wrotemy $dbh = DBI->connect ("dbi:Oracle:$v_primary_db","username","passwor +d",{ RaiseError => 1, AutoCommit => 0, ora_session_mode => ORA_SYSDBA + }) || die "Database connection not made: $DBI::errstr"; open (SQL, "$primarysql"); while (my $sqlstatement = <SQL>) { $sth = dbi->prepare($sqlstatement); $sth ->execute(); while (my @row = $sth->fetchrow_array() ){ foreach (@row) { $_="\t" if !defined($_); print "$_\t"; } print "\n"; } } END { $dbh->disconnect if defined($dbh); } }
In reply to multiple sql command output to a array variable by smith19
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |