'use DBI' failure

2003-02-07 Thread Alex Tunitsky
Please, help me.

I try to use DBI to connect Oracle (on Linux) using DBI and got this
message:


#!/usr/bin/perl -w

[root@localhost /root]# perl
use DBI;
Can't locate DBI.pm in @INC (@INC contains: /usr/lib/perl5/5.6.0/i386-linux
/usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl .) at - line 1.
BEGIN failed--compilation aborted at - line 1.


What am I missing?

Thanks,

Alex





Re: Installation problems on OS X 10.2.3

2003-02-07 Thread David Wheeler
On Thursday, February 6, 2003, at 11:39  AM, 
[EMAIL PROTECTED] wrote:

  I tried installing DBI 2 ways, first through CPAN.pm and second by
just downloading the source and compiling.  In both instances, I
received an internal bus error.


Send in the output of "make test TEST_VERBOSE=1".

David

--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
   Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]




RE: Can DBI be used to validate input?

2003-02-07 Thread Helck, Timothy
Will,

When you connect through dbi, set raiseError to 1. Normally a dbi error
message goes to stdout. To capture it you can do something like this
(untested):

if(eval{$csr_insertUser($userName...)} || $@){
$@ =~ m/Unique Constraint Failed/ ;  ### or whatever mySql error
reads like
$insertError = $1;
# check $insertError and decide what to do from there...
}

Of course this is only if you're too classy to use the "brute force and
ignorance" approach of first selecting the username that the person has
chosen, and only trying to insert it if the select returns zero rows.

Tim

-Original Message-
From: Will [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 1:57 PM
To: DBI Users
Subject: Can DBI be used to validate input?


I am developing a registration area for a members site
that will interface with a MySQL DB users table, and I
ran into a problem.  Note that I am using DBI
as my DB Driver.

Suppose the user tries to register with a username
that has already been taken.  I need a way to kick
back an error message to them.  I tried setting the
username field in the usrs table to UNIQUE, so that
might help if someone tried to insert something
already taken... I was thinking that if MySQL kicks
back an error message, then DBI might be able to
recongize it in such a way that I could use the return
value... I dont know if that is completely feasible
though...  there may be other, better ways anyway...
so I'm all ears...

Thanks,

Will

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Re: Can DBI be used to validate input?

2003-02-07 Thread Hardy Merrill
Will [[EMAIL PROTECTED]] wrote:
> I am developing a registration area for a members site
> that will interface with a MySQL DB users table, and I
> ran into a problem.  Note that I am using DBI
> as my DB Driver.
> 
> Suppose the user tries to register with a username
> that has already been taken.  I need a way to kick
> back an error message to them.  I tried setting the
> username field in the usrs table to UNIQUE, so that
> might help if someone tried to insert something
> already taken... I was thinking that if MySQL kicks
> back an error message, then DBI might be able to
> recongize it in such a way that I could use the return
> value... I dont know if that is completely feasible
> though...  there may be other, better ways anyway...
> so I'm all ears...

You have the right idea - create your username field
UNIQUE and let MySQL kick out the error - it's up to
you to catch the error and make sure the error was
caused by a user trying to enter a dup username.

This topic has been discussed at length in the last week
or two - find and search the archives for UNIQUE and I'm
sure you'll find the relevant conversations.

Read the perldocs by doing

   perldoc DBI

at a command prompt, and search for 'RaiseError' and
'eval' - you'll find a section with 'Transaction' in the
title.  That will show you how to execute some DBI code
(an INSERT perhaps), and catch any errors in DBI statements
(including db errors, such as attempting to insert a
duplicate key) using 'eval'.

HTH.

-- 
Hardy Merrill
Senior Software Engineer
Red Hat, Inc.



Re: Can DBI be used to validate input?

2003-02-07 Thread Susan Cassidy
Two methods come to mind:
Either do a select on the username to see if it exists before trying to 
insert it,  or, if the errstr for the message about a duplicate entry is 
unique enough, just look at the errstr, and if it tells you that the name 
already exists, issue an appropriate message to the user.





Will <[EMAIL PROTECTED]>
02/07/2003 10:57 AM

 
To: DBI Users <[EMAIL PROTECTED]>
cc: 
Subject:Can DBI be used to validate input?


I am developing a registration area for a members site
that will interface with a MySQL DB users table, and I
ran into a problem.  Note that I am using DBI
as my DB Driver.

Suppose the user tries to register with a username
that has already been taken.  I need a way to kick
back an error message to them.  I tried setting the
username field in the usrs table to UNIQUE, so that
might help if someone tried to insert something
already taken... I was thinking that if MySQL kicks
back an error message, then DBI might be able to
recongize it in such a way that I could use the return
value... I dont know if that is completely feasible
though...  there may be other, better ways anyway...
so I'm all ears...

Thanks,

Will

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com





Re: Can DBI be used to validate input?

2003-02-07 Thread Steve Sapovits
Will wrote:


I am developing a registration area for a members site
that will interface with a MySQL DB users table, and I
ran into a problem.  Note that I am using DBI
as my DB Driver.

Suppose the user tries to register with a username
that has already been taken.  I need a way to kick
back an error message to them.  I tried setting the
username field in the usrs table to UNIQUE, so that
might help if someone tried to insert something
already taken... I was thinking that if MySQL kicks
back an error message, then DBI might be able to
recongize it in such a way that I could use the return
value... I dont know if that is completely feasible
though...  there may be other, better ways anyway...
so I'm all ears...


If you know the errors you want to trap and handle you can
eval the SQL operation.  e.g., I have code for Oracle that
tries to create a temporary table but doesn't care if it
already exists.  That looks like this (snippet):

   eval
   {
   $dbh->do($sql);
   };

   die $@ if ( $@ && ($@ !~ /ORA-00955/) );

In other words, I continue if the error was one telling me
the table exists.  You can flip that around and do something
special for recognized errors.

You don't have to use eval.  If you read the DBI docs on
handling errors you can do it other ways by checking return
codes and error values/strings.

--
Steve SapovitsGSI Commerce, Inc.http://www.gsicommerce.com
Email:   [EMAIL PROTECTED]





Can DBI be used to validate input?

2003-02-07 Thread Will
I am developing a registration area for a members site
that will interface with a MySQL DB users table, and I
ran into a problem.  Note that I am using DBI
as my DB Driver.

Suppose the user tries to register with a username
that has already been taken.  I need a way to kick
back an error message to them.  I tried setting the
username field in the usrs table to UNIQUE, so that
might help if someone tried to insert something
already taken... I was thinking that if MySQL kicks
back an error message, then DBI might be able to
recongize it in such a way that I could use the return
value... I dont know if that is completely feasible
though...  there may be other, better ways anyway...
so I'm all ears...

Thanks,

Will

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Can not install DBI module

2003-02-07 Thread Somporn pragobmai
<>

FAIL DBI-1.32 darwin 6.0

2003-02-07 Thread System Administrator
This distribution has been tested as part of the cpan-testers
effort to test as many new uploads to CPAN as possible.  See
http://testers.cpan.org/

Please cc any replies to [EMAIL PROTECTED] to keep other
test volunteers informed and to prevent any duplicate effort.

--
This is an error report generated automatically by CPANPLUS,
version 0.042.

Below is the error stack during 'make test':

PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib -I/System/Library/Perl/darwin 
-I/System/Library/Perl -e 'use Test::Harness qw(&runtests $verbose); $verbose=0; 
runtests @ARGV;' t/*.t
t/01basics.ok
t/02dbidrv.ok
t/03hleak..ok
t/04mods...ok
t/05thrclone...skipped
all skipped: perl 5.006 not configured to support iThreads
t/06attrs..ok
t/07kids...ok
t/10examp..Insecure dependency in parameter 1 of 
DBI::st=HASH(0x204470)->FETCH method call while running with -T switch at t/10examp.t 
line 320.
DBI handle cleared whilst still active.
dbih_clearcom (sth 0x2059c0 0x10bed4, com 0x206af0, imp DBD::ExampleP::st):
   FLAGS 0x60011: COMSET Warn TaintIn TaintOut 
   PARENT DBI::db=HASH(0x1cc390)
   KIDS 0 (0 Active)
   IMP_DATA ARRAY(0x205c00)
   NUM_OF_FIELDS 3
   NUM_OF_PARAMS 1
dubious
Test returned status 20 (wstat 5120, 0x1400)
DIED. FAILED tests 104-245
Failed 142/245 tests, 42.04% okay
t/15array..ok
t/20meta...ok
t/30subclass...ok
t/40profileCan't locate Time/HiRes.pm in @INC (@INC contains: blib/arch 
blib/lib /System/Library/Perl/darwin /System/Library/Perl/darwin 
/System/Library/Perl/darwin /System/Library/Perl /System/Library/Perl/darwin 
/System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin 
/Library/Perl/darwin /Library/Perl /Library/Perl/darwin /Library/Perl 
/Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl . 
/System/Library/Perl/darwin /System/Library/Perl /Library/Perl/darwin /Library/Perl 
/Library/Perl /Network/Library/Perl/darwin /Network/Library/Perl /Network/Library/Perl 
.) at t/40profile.t line 183.
BEGIN failed--compilation aborted at t/40profile.t line 183.
dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-56
Failed 56/56 tests, 0.00% okay
t/41prof_dump..ok
t/42prof_data..ok
t/60preparse...ok
t/70shell..ok
t/80proxy..skipped
all skipped: modules required for proxy are probably not installed
t/zz_01basics_pp... Using DBI::PurePerl (DBI_PUREPERL=2)
ok
t/zz_02dbidrv_pp...ok
t/zz_03hleak_ppok
t/zz_04mods_pp.ok
t/zz_05thrclone_pp.skipped
all skipped: perl 5.006 not configured to support iThreads
t/zz_06attrs_ppok
t/zz_07kids_pp.skipped
all skipped: $h->{Kids} attribute not supported for DBI::PurePerl
t/zz_10examp_pp Taint mode switching tests skipped
 Taint attribute tests skipped
ok
t/zz_15array_ppok
t/zz_20meta_pp.ok
t/zz_30subclass_pp.ok
t/zz_40profile_pp..skipped
all skipped: profiling not supported for DBI::PurePerl
t/zz_41prof_dump_ppskipped
all skipped: profiling not supported for DBI::PurePerl
t/zz_42prof_data_ppskipped
all skipped: profiling not supported for DBI::PurePerl
t/zz_60preparse_pp.skipped
all skipped: preparse not supported for DBI::PurePerl
t/zz_70shell_ppok
t/zz_80proxy_ppskipped
all skipped: modules required for proxy are probably not installed
Failed Test   Stat Wstat Total Fail  Failed  List of Failed
---
t/10examp.t 20  5120   245  142  57.96%  104-245
t/40profile.t2   51256   56 100.00%  1-56
9 tests skipped.
Failed 2/34 test scripts, 94.12% okay. 198/1108 subtests failed, 82.13% okay.
make: *** [test_dynamic] Error 35


Additional comments:

Hello, Tim Bunce! Thanks for uploading your works to CPAN.

I noticed that the test suite seem to fail without these modules:

Time::HiRes

As such, adding the prerequisite module(s) to 'PREREQ_PM' in your
Makefile.PL should solve this problem.  For example:

WriteMakefile(
AUTHOR  => 'Tim Bunce ([EMAIL PROTECTED])',
... # other information
PREREQ_PM   => {
'Time::HiRes'   => '0', # or a minimum workable version
}
);

If you are interested in making a more flexible Makefile.PL that can
probe for missing dependencies and install them, ExtUtils::AutoInstall
at  may be
worth a look.

Thanks! :-)

 NOTE 
The comments above are created mechanically, possibly without manual
checking by the sender.  Also, because many people perform automatic
tests on CPAN, chances are that you will receive identical messages
about the same

RE: MySQL question

2003-02-07 Thread Dan Muey
> 
> How do you do that, using DBI without mysql.pm ?

I don't actually, it's just that it all came as one big happy setup on my server so I 
didn't have to install a bunch of different things . In fact I think on every server 
I've set up it is installed with perl or the os or something as I've never had to 
install it  myself. It was just magically there evry time.

I do use mysql.pm I just do

Use DBI;

$dh->connect(...:mysql:);

Sorry if I was confusing, didn't mean to be. :)

Dan

> 
> Best regards,
> 
> Stephan
> 
> Am Freitag, 7. Februar 2003 18:12 schrieb Dan Muey:
> > Those are three different modules. You'll only need one and 
> if any of 
> > the others are needed for it to work it will tel you on install.
> >
> > I use DBI, it's pretty cool.
> >
> > > -Original Message-
> > > From: Barone, Philip [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, February 07, 2003 11:09 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: MySQL question
> > >
> > >
> > > Can someone tell me the necessary modules needed to 
> access a MySQl 
> > > database using DBD/DBI?
> > >
> > > Looking in CPAN my guess is from what I find there is:
> > >
> > > DBI-1.32.tar.gz
> > > DBD-mysql-2.1020.tar.gz
> > > Msql-Mysql-modules-1.2219.tar.gz
> > >
> > >
> > > Are these the modules I need? Is this the correct order?
> > >
> > > Thanks.
> 
> -- 
> Stephan Harren
> Manager Site Operations
> MFN-IS
> ---
> Phone +49 69 90554 153
> Fax +49 69 90554 111
> Cell +49 173 7011126
> 
> 



Re: MySQL question

2003-02-07 Thread Stephan Harren
How do you do that, using DBI without mysql.pm ?

Best regards,

Stephan

Am Freitag, 7. Februar 2003 18:12 schrieb Dan Muey:
> Those are three different modules. You'll only need one and if any of the
> others are needed for it to work it will tel you on install.
>
> I use DBI, it's pretty cool.
>
> > -Original Message-
> > From: Barone, Philip [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 07, 2003 11:09 AM
> > To: [EMAIL PROTECTED]
> > Subject: MySQL question
> >
> >
> > Can someone tell me the necessary modules needed to access a
> > MySQl database using DBD/DBI?
> >
> > Looking in CPAN my guess is from what I find there is:
> >
> > DBI-1.32.tar.gz
> > DBD-mysql-2.1020.tar.gz
> > Msql-Mysql-modules-1.2219.tar.gz
> >
> >
> > Are these the modules I need? Is this the correct order?
> >
> > Thanks.

-- 
Stephan Harren
Manager Site Operations
MFN-IS
---
Phone +49 69 90554 153
Fax +49 69 90554 111
Cell +49 173 7011126




RE: MySQL question

2003-02-07 Thread Barone, Philip
Thanks guys for the quick response, I will use the first 2 and look for the more
recent DBD-mysql-2.1024 that Will suggested. 

> -Original Message-
> From: Gary Stainburn [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 07, 2003 12:16 PM
> To: Barone, Philip; [EMAIL PROTECTED]
> Subject: Re: MySQL question
> 
> 
> On Friday 07 Feb 2003 5:09 pm, Barone, Philip wrote:
> > Can someone tell me the necessary modules needed to access 
> a MySQl database
> > using DBD/DBI?
> >
> > Looking in CPAN my guess is from what I find there is:
> >
> > DBI-1.32.tar.gz
> > DBD-mysql-2.1020.tar.gz
> > Msql-Mysql-modules-1.2219.tar.gz
> 
> You will need the first two, installed in that order.  I 
> don't know what the 
> third one does - it may be usefill it may not, but the first 
> two should do 
> everything you need.
> 
> >
> >
> > Are these the modules I need? Is this the correct order?
> >
> > Thanks.
> 
> -- 
> Gary Stainburn
>  
> This email does not contain private or confidential material as it
> may be snooped on by interested government parties for unknown
> and undisclosed purposes - Regulation of Investigatory Powers 
> Act, 2000 
> 



RE: MySQL question

2003-02-07 Thread Ian Harisay
just install DBI and DBD::mysql  You should be good to go from there.


>>> "Dan Muey" <[EMAIL PROTECTED]> 02/07/03 10:12AM >>>
Those are three different modules. You'll only need one and if any of
the others are needed for it to work it will tel you on install.

I use DBI, it's pretty cool.

> -Original Message-
> From: Barone, Philip [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 07, 2003 11:09 AM
> To: [EMAIL PROTECTED] 
> Subject: MySQL question
> 
> 
> Can someone tell me the necessary modules needed to access a 
> MySQl database using DBD/DBI?
> 
> Looking in CPAN my guess is from what I find there is:
> 
> DBI-1.32.tar.gz
> DBD-mysql-2.1020.tar.gz
> Msql-Mysql-modules-1.2219.tar.gz
> 
> 
> Are these the modules I need? Is this the correct order? 
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> 



Re: MySQL question

2003-02-07 Thread Gary Stainburn
On Friday 07 Feb 2003 5:09 pm, Barone, Philip wrote:
> Can someone tell me the necessary modules needed to access a MySQl database
> using DBD/DBI?
>
> Looking in CPAN my guess is from what I find there is:
>
> DBI-1.32.tar.gz
> DBD-mysql-2.1020.tar.gz
> Msql-Mysql-modules-1.2219.tar.gz

You will need the first two, installed in that order.  I don't know what the 
third one does - it may be usefill it may not, but the first two should do 
everything you need.

>
>
> Are these the modules I need? Is this the correct order?
>
> Thanks.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 




RE: MySQL question

2003-02-07 Thread Dan Muey
Those are three different modules. You'll only need one and if any of the others are 
needed for it to work it will tel you on install.

I use DBI, it's pretty cool.

> -Original Message-
> From: Barone, Philip [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 07, 2003 11:09 AM
> To: [EMAIL PROTECTED]
> Subject: MySQL question
> 
> 
> Can someone tell me the necessary modules needed to access a 
> MySQl database using DBD/DBI?
> 
> Looking in CPAN my guess is from what I find there is:
> 
> DBI-1.32.tar.gz
> DBD-mysql-2.1020.tar.gz
> Msql-Mysql-modules-1.2219.tar.gz
> 
> 
> Are these the modules I need? Is this the correct order? 
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> 



Re: MySQL question

2003-02-07 Thread Mike Blezien
them will do it, alone with Perl :)... naturally.

MikeBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel:  1(985)902-8484
MSN: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Original Message - 
From: "Barone, Philip" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 07, 2003 11:09 AM
Subject: MySQL question


> Can someone tell me the necessary modules needed to access a MySQl database
> using DBD/DBI?
> 
> Looking in CPAN my guess is from what I find there is:
> 
> DBI-1.32.tar.gz
> DBD-mysql-2.1020.tar.gz
> Msql-Mysql-modules-1.2219.tar.gz
> 
> 
> Are these the modules I need? Is this the correct order? 
> 
> Thanks.
> 
> 
> 
> 
> 
> 




MySQL question

2003-02-07 Thread Barone, Philip
Can someone tell me the necessary modules needed to access a MySQl database
using DBD/DBI?

Looking in CPAN my guess is from what I find there is:

DBI-1.32.tar.gz
DBD-mysql-2.1020.tar.gz
Msql-Mysql-modules-1.2219.tar.gz


Are these the modules I need? Is this the correct order? 

Thanks.









Re: Possible Bug in DBD::Oracle

2003-02-07 Thread Jonathan Leffler
Andre Bonhote wrote:

On Fri, Feb 07, 2003 at 02:13:51PM +0100, H.Merijn Brand wrote:

Hm ...

Indeed. Hmm. I don't have any new ideas.

Strange enough: DBD::Pg and DBD::mysql works fine without any hassle.
Could the Oracle Version be a problem (9i)?


I  don't use DBD::Oracle, but DBD::Informix has a test harness module, 
and one of the functions in there, memory_leak_test, is specifically 
for running memory leak tests.  It takes a ref to a function.  It 
forks, and the child runs the function, while the parent periodically 
runs 'ps -fp$childpid'.   I've used that many times to track down 
memory leaks in DBD::Informix and related code.  It is actually a 
generic function; it doesn't care what the function does, and does not 
depend on DBD::Informix for any functionality.  Note that the code in 
the function should connect to the database, not the code which sets 
up the call to memory_leak_test.  If you wanted to try it, you could 
download DBD::Informix 1.04.PC1 and then extract memory_leak_test from 
the file lib/DBD/Informix/TestHarness.pm.  You might want to use a 
minor variation on the 'ps' command you have in place of the one I use 
by default.

Based on my experience, there is always a chance that there is a 
memory leak in the database connectivity software.  Doubly so if an 
alternative driver running the same Perl apart from the DBI->connect 
does not have the leak.  There is also a chance that the leak is due 
to a bug in the DBD code -- I've suffered from both, and more 
frequently from my coding than from bugs in the database connectivity 
code.  There's an outside chance the bug is in DBI code; I usually put 
that at the bottom of the probability list, though, especially in a 
case like yours where it appears that another driver is OK.

Step 1 is to establish that there is a leak - you've done that, I 
think.  Keep the original test code for the record (and proving that 
the original problem is fixed).

Step 2 is to try and make a slow leak like your into a more serious 
(blatant) leak without changing the substance of the test.  Sometimes, 
you can do this by changing a CHAR(10) to a CHAR(200); sometimes you 
select more columns; sometimes you...well, you ring the changes and 
see what happens.

Step 3 is to see whether you can change the blatantly leaky test so 
that it doesn't leak.  Generally, drivers try to avoid leaks, so 
there's often something odd about your code compared to anything that 
the author usually tests.  I said 'odd', not 'wrong'.  It simply means 
you've found something legitimate that the author hasn't thought of. 
I had a leak where people prepared a statement but never used it, for 
example.  Pure oversight in the administrative code.  Still a leak. 
One thing I'd try changing in your code is the selection function -- 
selectcol_arrayref.

Once you've done that, you may be starting to get an idea about what 
triggers the leak.  And you may have a workaround.  And the more 
precise information may help the author(s) of DBI and the driver (in 
this case, the same person, of course) track down where the problem is.

--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED]) 
#include 
Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/



Re: DBD::Oracle multiple SQL statements - PL/SQL example

2003-02-07 Thread Dave K
Colin,

When I try to test this the following error from 'plsql_errstr' indicates
that it is not possible to have multiple statements in a SQL string. The
PL/SQL statements are not being treated individually.
No. Your package spec is trying to contain a package body.

Errors for PACKAGE PLSQL_EXAMPLE:
6.6: PLS-00103: Encountered the symbol "CREATE"

Because your package specification needs to be seperate from the package
body.

Review the syntax for package creation. If you have Procedure Builder on
your system, run the script then go to procedure builder and look at the
result.
Good luck.





DBD::Oracle multiple SQL statements - PL/SQL example

2003-02-07 Thread Colin . Woodford

DBI-Users,

The DBI prepare statement documentation 
http://search.cpan.org/author/TIMB/DBI-1.32/DBI.pm#prepare says prepare "Prepares a 
single statement for later execution by the database engine"

The DBD::Oracle PL/SQL examples 
http://search.cpan.org/author/TIMB/DBD-Oracle-1.12/Oracle.pm#PL_SQL_Examples 
illustrates multiple statements in a SQL string.

When I try to test this the following error from 'plsql_errstr' indicates that it is 
not possible to have multiple statements in a SQL string. The PL/SQL statements are 
not being treated individually.

Errors for PACKAGE PLSQL_EXAMPLE:
6.6: PLS-00103: Encountered the symbol "CREATE" 

I would be grateful for any feedback about preparing and executing multiple SQL 
statements using DBD::Oracle.

The test code I used is :

#!/perl/5.8.0/bin/perl

# pragmata
use strict;
use warnings;

use DBI;

{
my($msg, $dbh, $sth, $ret_val);

my $sid="DATABASED1";
my $user="username";
my $passwd="password";

$dbh = DBI->connect("dbi:Oracle:$sid", $user, $passwd);

# we assume this package already exists
my $plsql = q{

  CREATE OR REPLACE PACKAGE plsql_example
  IS
PROCEDURE proc_np;
  END plsql_example;

  CREATE OR REPLACE PACKAGE BODY plsql_example
  IS
PROCEDURE proc_np
  IS
whoami VARCHAR2(20) := NULL;
  BEGIN
SELECT USER INTO whoami FROM DUAL;
  END;
  END plsql_example;
  };

  $dbh->{RaiseError} = 0;

  $sth = $dbh->prepare($plsql);
  $sth->execute;

  $msg = $dbh->func( 'plsql_errstr' );
  die $dbh->errstr if ! defined $msg;
  die $msg if $msg;
}
# END OF CODE

Many Thanks,
Colin Woodford

Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only
for the individual named.  If you are not the named addressee you
should not disseminate, distribute or copy this e-mail.  Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.  The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission.  If
verification is required please request a hard-copy version.  This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.