How to execute xxx.sql in DBI in perl

How to execute xxx.sql in DBI in perl

am 26.05.2011 11:58:58 von hye-jin.woo

Would you help me how to execute like @xx.sql in PL/SQL in perl?

If I do not execute select query, I want to get the query result using by x=
..sql file.

It mean that I want to execute x.sql file after connecting oracle, then I w=
ant to get the output.

Is it possible or not ?





use DBI;

....
....

my $dbh =3D DBI->connect ($dsn, $username, $password, \%attr) || die "Datab=
ase connection not mode : $DBI::errstr";

my $que =3D "@/lhome/elcaro/scripts/admin/moniCPU.sql";
#my $que =3D "select instance_name from v\$instance";

my $cursor =3D $dbh->selectall_arrayref($que);

for (@$cursor) {
print "@{$_} \n";
}

$dbh->disconnect;




Hyejin Woo
GM&Q / Network & DBA

Certificate : CISA, CCNP, IBM AIX Expert, HP-UX, ITIL

HP-DIS
23, Sungju-dong, Changwon, Kyeongnam, 641-745, South Korea
Office : +82-55-269-1272 / Fax: +82-55-269-1261
Mobile : +82-10-9300-6793
Mail : hye-jin.woo@hp.com




--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: How to execute xxx.sql in DBI in perl

am 26.05.2011 11:59:29 von Abhinav Kukreja

--0016e643461e906d2404a42ae09a
Content-Type: text/plain; charset=ISO-8859-1

you can open the .sql file and store the contents in a perl variable (lets
say $SQL) and then execute the command.

On Thu, May 26, 2011 at 3:28 PM, Woo, Hye Jin wrote:

> Would you help me how to execute like @xx.sql in PL/SQL in perl?
>
> If I do not execute select query, I want to get the query result using by
> x.sql file.
>
> It mean that I want to execute x.sql file after connecting oracle, then I
> want to get the output.
>
> Is it possible or not ?
>
>
>
>
>
> use DBI;
>
> ...
> ...
>
> my $dbh = DBI->connect ($dsn, $username, $password, \%attr) || die
> "Database connection not mode : $DBI::errstr";
>
> my $que = "@/lhome/elcaro/scripts/admin/moniCPU.sql";
> #my $que = "select instance_name from v\$instance";
>
> my $cursor = $dbh->selectall_arrayref($que);
>
> for (@$cursor) {
> print "@{$_} \n";
> }
>
> $dbh->disconnect;
>
>
>
>
> Hyejin Woo
> GM&Q / Network & DBA
>
> Certificate : CISA, CCNP, IBM AIX Expert, HP-UX, ITIL
>
> HP-DIS
> 23, Sungju-dong, Changwon, Kyeongnam, 641-745, South Korea
> Office : +82-55-269-1272 / Fax: +82-55-269-1261
> Mobile : +82-10-9300-6793
> Mail : hye-jin.woo@hp.com
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>

--0016e643461e906d2404a42ae09a--