Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Win32::ODBC;
- $db= new Win32::ODBC("DSN=datasourcename;UID=username;PWD=passwrd")
- || die "Error: " . Win32::ODBC::Error();
- $db->Sql("SELECT emp_Id, emp_name, salary FROM Sample.Emp");
- while($db->FetchRow())
- {
- @values = $db->Data;
- print @values;
- }
- $db->Close();
- PROCEDURE sp_rank(p_cursorVar out CursorType)
- is
- begin
- open p_cursorVar for
- select emp_id, emp_name from emp;
- End sp_rank;
- #!/usr/bin/perl
- use strict;
- use warnings;
- use DBI;
- my $datasource = "datasourcename";
- my $username = "foobar";
- my $password = "secret";
- # connect to your database with a database handle
- my $dbh = DBI->connect("DBI:Oracle:$datasource",$username,$password) or die $DBI::errstr();
- # create a statement handle for database interaction
- my $sth = $dbh->prepare("SELECT emp_Id, emp_name, salary FROM Sample.Emp");
- $sth->execute();
- # fetch the rows and print them
- while($sth->fetchrow_arrayref()){
- @values = @$_;
- print @values;
- }
- # never forget to close your statement handle
- $sth->finish();
- # using your stored procedure
- # overwrite your finished statement handle with a new one
- $sth = $dbh->prepare("sp_rank()");
- $sth->execute();
- # fetch all your data into an array hashref structure. the column names in your DB are the keys in the hashref
- my $data = $sth->fetchall_arrayref({});
- $sth->finish();
- $dbh->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement