RE: ORA-01031 when trying to connect as sysdba. sqlplus works

2003-09-09 Thread Baras, Gal
Is there a way to tell perl to use IPC?

-Original Message-
From: Steve Baldwin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 9 September 2003 8:31 AM
To: 'Baras, Gal'
Cc: [EMAIL PROTECTED]
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


We have a setup here where you cannot connect as sysdba via SQL*Net.
Maybe that's your problem.

-Original Message-
From: Baras, Gal [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 9 September 2003 7:44 AM
To: 'Gold, Samuel (Contractor)'
Cc: '[EMAIL PROTECTED]'
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


Thanks for the quick response, but this was not the solution.

In my subject line and body of message I mentioned that sqlplus works
for me with the same UNIX user.

Just to prove the point, I've added the following line to my code:

$opt_d  print `id`;

Here's what perl prints:

uid=105(psoft) gid=101(dba) groups=1004(cobol)

Thanks,
Gal


-Original Message-
From: Gold, Samuel (Contractor) [mailto:[EMAIL PROTECTED]
Sent: Monday, 8 September 2003 9:07 PM
To: 'Baras, Gal'; '[EMAIL PROTECTED]'
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


This is caused by the user executing the script not being part of the
dba group.  ORA-01031 is insufficient privileges.  Who ever is executing
the script needs to be part of the dba group or osdba group.  HTH.

 
Thanks,
Sam Gold


-Original Message-
From: Baras, Gal [mailto:[EMAIL PROTECTED]
Sent: Monday, September 08, 2003 3:59 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: ORA-01031 when trying to connect as sysdba. sqlplus works


Hello,
 
I'm getting an ORA-01031 error when trying to use the ORA_SYSDBA or
ORA_SYSOPER modes.
 
When using sqlplus, I can use '/ as sysdba' and '/ as sysoper' as the
same UNIX user(s).
 
This is on HP-UX 11i, Oracle 9.20, perl 5.8.0, DBI 1.37 and DBD::Oracle
1.14.
 
Thanks,
Gal



RE: ORA-01031 when trying to connect as sysdba. sqlplus works

2003-09-09 Thread Baras, Gal
BEAUTY!!  Thanks a lot, Steve.  To complete this solution, ORACLE_SID must
be set, but it works like a charm.  I'm a happy man.  Thanks for the
persistence.

For everybody else, here's what to do:

 use strict;
 use DBI;
 use DBD::Oracle qw(:ora_session_modes);

 my ($dbh, $mode);
 $ENV{'ORACLE_SID'} = your sid;
 $mode = ORA_SYSDBA; # or ORA_SYSOPER
 $dbh = DBI-connect(dbi::Oracle:, '', '', {ora_session_mode = $mode}) ||

  die $DBI::errstr;

The rest is downhill.

Have a great day,
Gal


-Original Message-
From: Steve Baldwin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 9 September 2003 8:39 AM
To: 'Baras, Gal'
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


As far as I know, just make sure your username/password doesn't contain
'@xxx', and there is nothing after the last ':' in the DBI connect
(dbi:Oracle: rather than dbi:Oracle:XXX).  I haven't actually tried
connecting as sysdba from a Perl script, so can't confirm this.

-Original Message-
From: Baras, Gal [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 9 September 2003 8:22 AM
To: 'Steve Baldwin'; Baras, Gal
Cc: [EMAIL PROTECTED]
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


Is there a way to tell perl to use IPC?

-Original Message-
From: Steve Baldwin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 9 September 2003 8:31 AM
To: 'Baras, Gal'
Cc: [EMAIL PROTECTED]
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


We have a setup here where you cannot connect as sysdba via SQL*Net.
Maybe that's your problem.

-Original Message-
From: Baras, Gal [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 9 September 2003 7:44 AM
To: 'Gold, Samuel (Contractor)'
Cc: '[EMAIL PROTECTED]'
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


Thanks for the quick response, but this was not the solution.

In my subject line and body of message I mentioned that sqlplus works
for me with the same UNIX user.

Just to prove the point, I've added the following line to my code:

$opt_d  print `id`;

Here's what perl prints:

uid=105(psoft) gid=101(dba) groups=1004(cobol)

Thanks,
Gal


-Original Message-
From: Gold, Samuel (Contractor) [mailto:[EMAIL PROTECTED]
Sent: Monday, 8 September 2003 9:07 PM
To: 'Baras, Gal'; '[EMAIL PROTECTED]'
Subject: RE: ORA-01031 when trying to connect as sysdba. sqlplus works


This is caused by the user executing the script not being part of the
dba group.  ORA-01031 is insufficient privileges.  Who ever is executing
the script needs to be part of the dba group or osdba group.  HTH.

 
Thanks,
Sam Gold


-Original Message-
From: Baras, Gal [mailto:[EMAIL PROTECTED]
Sent: Monday, September 08, 2003 3:59 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: ORA-01031 when trying to connect as sysdba. sqlplus works


Hello,
 
I'm getting an ORA-01031 error when trying to use the ORA_SYSDBA or
ORA_SYSOPER modes.
 
When using sqlplus, I can use '/ as sysdba' and '/ as sysoper' as the
same UNIX user(s).
 
This is on HP-UX 11i, Oracle 9.20, perl 5.8.0, DBI 1.37 and DBD::Oracle
1.14.
 
Thanks,
Gal


Entering data in Postgres bytea field

2003-09-09 Thread Zhivko Duchev
Hello all,
I'm trying to load a large amount of binary data in bytea field in Postgre 
table using perl.
The problem is that the only way I've managed to do it was by using 
placeholders and binding like this:
  $statement=Insert into pic1 (pic,type) values(?,'eps2');
  $sth=$dbh-prepare($statement);
  $sth-bind_param(1, $md,SQL_QUERY ) || die $dbh-errstr;

Is there any generic way to write this statement in the usual way :
INSERT INTO table (col1,col2,...) VALUES (val1,val2,...).

I'm using Perl5.6.1 ;DBI 1.21 ;DBD:Pg 1.01; PostgreSQL 7.2.1 on Debian Linux 
mashine

10x in advance



RE: bind columns behavior

2003-09-09 Thread Rozengurtel, Daniel
Hello Mike,

Thanx much for a nice example it definitely worked for me. However I also
succeeded (by gish and by gosh I guess) to achieve what I needed in this
following way:
# print header record
if ($sort_flg eq Y)
  {print OUTFILE join('|',sort @ClnFldsArray).\n; }
else
  {print OUTFILE join('|',@ClnFldsArray).\n; }

my %row;
my  $sth = $dbh-prepare_cached($sql) || die $dbh-errstr;
$sth-execute;
$sth-bind_columns( \( @[EMAIL PROTECTED] ));
while($sth-fetch) {
 if ($sort_flg eq Y)
{ print OUTFILE map($row{$_}|, sort @ClnFldsArray), \n; }
 else
{ print OUTFILE map($row{$_}|, @ClnFldsArray), \n;  }
}#while


# Using hash, was useful to me, since I was able to get into any HASH
element looping
# thru sorted/not sorted array of predefined fields. Something that I was
not able to achieve when I started this email. I am still puzzled as to why
it worked!!!

Anyway, thanx much for your time and help. 
This has really been educating. 

Daniel



-Original Message-
From: Michael A Chase [mailto:[EMAIL PROTECTED]
Sent: Monday, September 08, 2003 11:53 PM
To: dbi-users; Rozengurtel, Daniel
Subject: Re: bind columns behavior


Please keep this on dbi-users.  Others may have something to learn or
contribute.

On Mon, 8 Sep 2003 22:09:57 -0400  Rozengurtel, Daniel
[EMAIL PROTECTED] wrote:

 The reason i did not want to touch the sql before I call prepare() is
 because the sql is passed to a program in .ini file which my perl
 parses and creates an sql statement. I could basically get each of
 fields in a select statement from ini file into an array and just
 before constructing sql sort it or do whatever I neede to, however
 that involved some additional work on parsing. I did not know that i
 needed to preserve the order of fields in SELECT statemnt, and
 thought I could get away with just outputing the results the way I
 wanted. Well tought luck I guess. 

It's mostly a matter of where it is easiest and clearer.  TMTOWTDI.

 Now you mentioned passing an array instead of hash. I.e once I got my
 fields ordered in @ClnFldArray, I could do this:
 
  my $sth = $dbh-prepare_cached($sql) || die $dbh-errstr;
 $sth-execute;

The problem with just using the array is that it initially doesn't have
the elements needed.  One way to be sure it does is to assign the
$sth-{NAME} array to it, that also makes it a handy source for the
header line.  As long as you keep the \(), bind_columns() will be
passed a list of references to the elements of the array.  The \ is
distributive in that syntax and the array is expanded to a list of its
elements in the parenthesis.

   # After this, @ClnFldsArray has the right number of elements.
   @ClnFldsArray = @{$sth - {NAME}};
   print OUTPUT join( |, @ClnFldsArray ), \n;

   $sth-bind_columns( \( @ClnFldsArray ) );
 # I am not sure this will work! I think it will consider it as one
 # bind var instead of multiple that needs to be passed.
 # How do you get away with this???

See above.

  while($sth-fetch) {
 
    
  }#while
 
 Thanx much for your time Mike.

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.




IMPORTANT NOTICES: 
  This message is intended only for the addressee. Please notify the
sender by e-mail if you are not the intended recipient. If you are not the
intended recipient, you may not copy, disclose, or distribute this message
or its contents to any other person and any such actions may be unlawful.
 
 Banc of America Securities LLC(BAS) does not accept time
sensitive, action-oriented messages or transaction orders, including orders
to purchase or sell securities, via e-mail.

 BAS reserves the right to monitor and review the content of all
messages sent to or from this e-mail address. Messages sent to or from this
e-mail address may be stored on the BAS e-mail system.
__


Help with install????

2003-09-09 Thread Badinter, George
I am trying to get perl  mysql going and this is the error message I get :
dbimon mysql:test:localhost 
ld.so.1: /usr/local/bin/perl: fatal: relocation error: file
/usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris/auto/DBD/mysql/mysql.so:
symbol mysql_init: referenced symbol not found
Killed

Any ideas?

George



Re: bind columns behavior

2003-09-09 Thread Michael A Chase
On Tue, 9 Sep 2003 09:43:18 -0400  Rozengurtel, Daniel
[EMAIL PROTECTED] wrote:

 Thanx much for a nice example it definitely worked for me. However I
 also succeeded (by gish and by gosh I guess) to achieve what I needed
 in this following way:
 # print header record

Memory is cheap enough that you only need to sort once, then use the
array that contains the sorted list.

# if ($sort_flg eq Y)
#   {print OUTFILE join('|',sort @ClnFldsArray).\n; }
# else
#   {print OUTFILE join('|',@ClnFldsArray).\n; }

   my @OutFldsArray = @ClnFldsArray;
   @OutFldsArray = sort @ClnFldsArray if $sort_flg eq Y;
   print OUTFILE join( |, @OutFldsArray ), \n;

 
 my %row;
 my$sth = $dbh-prepare_cached($sql) || die $dbh-errstr;
   $sth-execute;
   $sth-bind_columns( \( @[EMAIL PROTECTED] ));
 while($sth-fetch) {
#  if ($sort_flg eq Y)
#{ print OUTFILE map($row{$_}|, sort @ClnFldsArray), \n; }
#  else
#{ print OUTFILE map($row{$_}|, @ClnFldsArray), \n; }

# The method above leaves a trailing | on each line
print OUTFILE join( |, @[EMAIL PROTECTED] ), \n;

 }#while
 
 
 Using hash, was useful to me, since I was able to get into any HASH
 element looping thru sorted/not sorted array of predefined fields.
 Something that I was not able to achieve when I started this email.
 I am still puzzled as to why it worked!!!

You may want to look at the following PODs.  You can view them from
http://search.cpan.org/dist/perl/ or by running perldoc $(name).

perlop
perlreftut
perlref
perlfunc
perlfaq

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.



RE: bind columns behavior

2003-09-09 Thread Rozengurtel, Daniel
You're absolutely right. Its better to use one sorted array instead of
sorting it all the time.

Thanx much again

Dan 

-Original Message-
From: Michael A Chase [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 11:30 AM
To: Rozengurtel, Daniel; dbi-users
Subject: Re: bind columns behavior


On Tue, 9 Sep 2003 09:43:18 -0400  Rozengurtel, Daniel
[EMAIL PROTECTED] wrote:

 Thanx much for a nice example it definitely worked for me. However I
 also succeeded (by gish and by gosh I guess) to achieve what I needed
 in this following way:
 # print header record

Memory is cheap enough that you only need to sort once, then use the
array that contains the sorted list.

# if ($sort_flg eq Y)
#   {print OUTFILE join('|',sort @ClnFldsArray).\n; }
# else
#   {print OUTFILE join('|',@ClnFldsArray).\n; }

   my @OutFldsArray = @ClnFldsArray;
   @OutFldsArray = sort @ClnFldsArray if $sort_flg eq Y;
   print OUTFILE join( |, @OutFldsArray ), \n;

 
 my %row;
 my$sth = $dbh-prepare_cached($sql) || die $dbh-errstr;
   $sth-execute;
   $sth-bind_columns( \( @[EMAIL PROTECTED] ));
 while($sth-fetch) {
#  if ($sort_flg eq Y)
#{ print OUTFILE map($row{$_}|, sort @ClnFldsArray), \n; }
#  else
#{ print OUTFILE map($row{$_}|, @ClnFldsArray), \n; }

# The method above leaves a trailing | on each line
print OUTFILE join( |, @[EMAIL PROTECTED] ), \n;

 }#while
 
 
 Using hash, was useful to me, since I was able to get into any HASH
 element looping thru sorted/not sorted array of predefined fields.
 Something that I was not able to achieve when I started this email.
 I am still puzzled as to why it worked!!!

You may want to look at the following PODs.  You can view them from
http://search.cpan.org/dist/perl/ or by running perldoc $(name).

perlop
perlreftut
perlref
perlfunc
perlfaq

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.




IMPORTANT NOTICES: 
  This message is intended only for the addressee. Please notify the
sender by e-mail if you are not the intended recipient. If you are not the
intended recipient, you may not copy, disclose, or distribute this message
or its contents to any other person and any such actions may be unlawful.
 
 Banc of America Securities LLC(BAS) does not accept time
sensitive, action-oriented messages or transaction orders, including orders
to purchase or sell securities, via e-mail.

 BAS reserves the right to monitor and review the content of all
messages sent to or from this e-mail address. Messages sent to or from this
e-mail address may be stored on the BAS e-mail system.
__


What to do with UTF-8 data?

2003-09-09 Thread Steve Hay
Hi,

Having looked through the list archives a bit, I see there has been lots 
of discussion over what to do with UTF-8 data, but I can't find anything 
that really helps me out now.

I'm running Perl 5.8.0 with MySQL 3.23.56 (via DBD-mysql).  Since (I 
think) there is no native UTF-8 support in MySQL below 4.1.x, my plan 
was to simply store the bytes of each UTF-8 character in the database 
(either by explicitly converting Perl's UTF-8 strings to sequences of 
octets using Encode::encode_utf8(), or else just letting that happen of 
its own accord as it seems to do :-s), and then convert such octet 
sequences back to UTF-8 strings when retrieving data from the database 
using Encode::decode_utf8().

As long as I store *all* my data in this way, those conversions should 
always succeed.  (encode_utf8() never fails anyway, and decode_utf8() 
will always work here because I'm always feeding it valid data.)

The problem is: How do I trap all input/output to/from DBI to do these 
conversions?

I can easily do it manually:

   $dbh-do('INSERT INTO foo (bar) VALUES (?)', undef, 
Encode::encode_utf8($input_utf8str));
   ...
   my @octets_row = $dbh-selectrow_array('SELECT bar FROM foo');
   my $output_utf8str2 = Encode::decode_utf8($octets_row[0]);

but that's way too tedious in practice.  I want to have those 
conversions done for me automatically, perhaps by having specified some 
appropriate encode/decode callbacks for certain hooks.  Do any such 
hooks exist?

If, as I suspect, there are not, then what is the currently recommended 
solution here?

Would it be at all easy to add such hooks, or some other means of 
specifying that I want these conversions done, to DBI as a stop-gap 
solution?

Thanks,
- Steve


Re: What to do with UTF-8 data?

2003-09-09 Thread Chuck Fox
Steve,

I am a Sybase DBA, but in situations like this, I have declared the 
column on the table to be varbinary or binary and stored the data 
directly without conversion.  Don't know if MySql supports this datatype.

HTH,

Chuck Fox
Principal Database Adminstrator
America Online, INC.
[EMAIL PROTECTED] wrote:

Hi,

Having looked through the list archives a bit, I see there has been 
lots of discussion over what to do with UTF-8 data, but I can't find 
anything that really helps me out now.

I'm running Perl 5.8.0 with MySQL 3.23.56 (via DBD-mysql).  Since (I 
think) there is no native UTF-8 support in MySQL below 4.1.x, my plan 
was to simply store the bytes of each UTF-8 character in the database 
(either by explicitly converting Perl's UTF-8 strings to sequences of 
octets using Encode::encode_utf8(), or else just letting that happen 
of its own accord as it seems to do :-s), and then convert such octet 
sequences back to UTF-8 strings when retrieving data from the database 
using Encode::decode_utf8().

As long as I store *all* my data in this way, those conversions should 
always succeed.  (encode_utf8() never fails anyway, and decode_utf8() 
will always work here because I'm always feeding it valid data.)

The problem is: How do I trap all input/output to/from DBI to do these 
conversions?

I can easily do it manually:

   $dbh-do('INSERT INTO foo (bar) VALUES (?)', undef, 
Encode::encode_utf8($input_utf8str));
   ...
   my @octets_row = $dbh-selectrow_array('SELECT bar FROM foo');
   my $output_utf8str2 = Encode::decode_utf8($octets_row[0]);

but that's way too tedious in practice.  I want to have those 
conversions done for me automatically, perhaps by having specified 
some appropriate encode/decode callbacks for certain hooks.  Do any 
such hooks exist?

If, as I suspect, there are not, then what is the currently 
recommended solution here?

Would it be at all easy to add such hooks, or some other means of 
specifying that I want these conversions done, to DBI as a stop-gap 
solution?

Thanks,
- Steve



Cant call method execute problem

2003-09-09 Thread Sharma, Amit

Hi,
While trying to execute the following SQL , I get the following error: Can't
call method execute on an undefined value at x.pl line 105.
..
my $sqlSch = SELECT SEQ_NO from $TableName;
my $sth = $dbHandle-prepare($sqlSch);
$sth-execute();
$sth-bind_columns(undef, \$SequenceNum);
..


However, when I hard-code the value for the table name, as shown below, the
script works fine.

my $sqlSch = SELECT SEQ_NO from Employee_data;
my $sth = $dbHandle-prepare($sqlSch);
$sth-execute();
$sth-bind_columns(undef, \$SequenceNum);
..


Am unable to figure out the problem. While debugging, the print function
shows correct value for the variable containing the correct table name for
$TableName.

While looking at the archives, I figured out that it could be a bug with
DBD::Oracle 1.13  1.14 and I need to patch my system. However, am not too
sure about that, and want to confirm with the list before applying a patch.
Incase, a patch has to be applied, could someone tell me how to go about
identifying the version of DBD on solaris 8 box and where can I get the
patch.

Thanx,
amit


Re: Cant call method execute problem

2003-09-09 Thread David N Murray
On Sep 9, Sharma, Amit scribed:

 Hi,
 While trying to execute the following SQL , I get the following error: Can't
 call method execute on an undefined value at x.pl line 105.
 ..
 my $sqlSch = SELECT SEQ_NO from $TableName;
The substitution of $TableName (if its populated) has already occurred at
this point.  What's the value of $sqlSch?
I use this type of code all the time, and have never had a problem
(v1.12).

 my $sth = $dbHandle-prepare($sqlSch);
 $sth-execute();

Can you cut down the script to just these lines and reproduce the
problem?  Your error was reported at line 105.  The error you are
reporting seems to indicate that $sth is the undefined value at this
point.  The prepare would have already identified any SQL errors or
undefined values.  Are you shore the prepare() didn't fail?  That would
cause $sth to be undefined.

 $sth-bind_columns(undef, \$SequenceNum);
 ..


 However, when I hard-code the value for the table name, as shown below, the
 script works fine.

 my $sqlSch = SELECT SEQ_NO from Employee_data;
 my $sth = $dbHandle-prepare($sqlSch);
 $sth-execute();
 $sth-bind_columns(undef, \$SequenceNum);
 ..


 Am unable to figure out the problem. While debugging, the print function
 shows correct value for the variable containing the correct table name for
 $TableName.

 While looking at the archives, I figured out that it could be a bug with
 DBD::Oracle 1.13  1.14 and I need to patch my system. However, am not too
 sure about that, and want to confirm with the list before applying a patch.
 Incase, a patch has to be applied, could someone tell me how to go about
 identifying the version of DBD on solaris 8 box and where can I get the
 patch.

I would just upgrade using CPAN and skip the patches.  To confirm current
versions:

use DBI;
use DBD::Oracle;
print \$DBI::VERSION=$DBI::VERSION\n;
print \$DBD::Oracle::VERSION=$DBD::Oracle::VERSION\n;

HTH,
Dave



Problem with proxy server upgrade and storable

2003-09-09 Thread Douglas Smith

Hello All-

I manage a use of a DBI proxyserver to give people access to a local
database worldwide, and I would like to update the proxy server to
use perl 5.8.0 and the latest DBI and related modules.

But after I have done this on a test server, and try to connect from an
existing client, I get this error:

Cannot log in to DBI::ProxyServer: Storable binary image v2.6 more recent than I am 
(v2.4)
at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 355

Since I also upgraded the Storable module along with the DBI.  

Does this mean I have to insist that all remote clients have to upgrade
right away to be able to keep using the server?  Shouldn't Storable be
backward compat. enough that this is not needed?  That a client with
an older version of Storable should be able to use a server with a newer
version of Storable?

I hate to have to make everyone who wants to continue use, go and track
down the versions of various modules and re-install and upgrade.  I was
hoping to upgrade to support the use of newer versions of perl and 
modules without insisting that current older versions that are working 
also need to upgrade.

Am I stuck, is there a way around this?

Douglas

-- 
---
Douglas A. Smith  [EMAIL PROTECTED]
Office: Bld 280, Rm 157   (650)926-2369
---


Can't locate object method TIEHASH when used in Safe compartment

2003-09-09 Thread Peter
Is this a bug or something else?  Can someone please give me some 
direction about where to look or go to solve this problem?

The error message is:
Can't locate object method TIEHASH via package DBI::st at 
/usr/lib/perl5/site_perl/5.6.1/i386-linux/DBI.pm line 1053.

I managed to reproduce the error in this simple test program:
#!/usr/bin/perl -w
use strict;
use integer;
use DBI;
use Safe;
our $dbh = DBI-connect(dbi:Pg:dbname=mydb, 'username', 'password');
$dbh-{AutoCommit} = 0; # Don't commit changes to the db until we're done
$dbh-{RaiseError} = 1; # die if there's a db error (thereby preventing 
us from writing partial data to the db)

our $safe = new Safe;
$safe-share_from('main',['$dbh']);
our $safecode = END;
\$dbh-prepare(SELECT * FROM mytable);
END
$safe-reval($safecode,1);
die $@ if $@;
exit;

Thanks in advance,

Peter



Re: Cant call method execute problem

2003-09-09 Thread Michael A Chase
On Tue, 9 Sep 2003 12:50:07 -0400  Sharma, Amit
[EMAIL PROTECTED] wrote:

 While trying to execute the following SQL , I get the following
 error:
 Can't call method execute on an undefined value at x.pl line 105.
 ..
 my $sqlSch = SELECT SEQ_NO from $TableName;
 my $sth = $dbHandle-prepare($sqlSch);
 $sth-execute();
 $sth-bind_columns(undef, \$SequenceNum);

The prepare() failed and you haven't the foggiest notion of what
happened since you aren't checking for errors.  You should either set
$dbHandle - {RaiseError} or check for errors on each method call.

   # Either enable implicit error checking
   $dbHandle - {RaiseError} = 1;

   # Or check for errors each method call
   my $sqlSch = SELECT SEQ_NO from $TableName;
   my $sth = $dbHandle-prepare($sqlSch)
  or die Prepare failed, $DBI::errstr\n$sqlSch\n;
   $sth-execute() or die Execute failed, $DBI::errstr\n;

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.