Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread hubert depesz lubaczewski
On 3/16/07, Jasbinder Singh Bali <[EMAIL PROTECTED]> wrote: just wondeng why doesn't it let me put my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", "", ""); in eval you dont need to put ->connect in eval. just set connect option 'raiseerror' to 0 (and printerror as

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Randal L. Schwartz
> "Douglas" == Douglas McNaught <[EMAIL PROTECTED]> writes: Douglas> my $dbh; Douglas> eval { $dbh = connect(...) }; Since eval returns its value (or undef if $@ has the error), you can shorten this to: my $dbh = eval { DBI->connect(...) }; and now either look at $@ (if you want to disting

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Douglas McNaught
"Jasbinder Singh Bali" <[EMAIL PROTECTED]> writes: > just wondeng why doesn't it let me put > my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", > "", ""); > in eval > > says > Global symbol "$dbh" requires explicit package name at line used> The my() variable goes ou

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Martijn van Oosterhout
On Fri, Mar 16, 2007 at 10:54:49AM -0400, Jasbinder Singh Bali wrote: > just wondeng why doesn't it let me put > my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; > port=5432;", "", ""); > in eval > > says > Global symbol "$dbh" requires explicit package name at line is used> Wel

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Adam Rich
esql.org Subject: Re: [GENERAL] exception handling in plperlu just wondeng why doesn't it let me put my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", "", ""); in eval says Global symbol "$dbh" requires explicit package

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread A.M.
On Mar 16, 2007, at 10:54 , Jasbinder Singh Bali wrote: just wondeng why doesn't it let me put my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", "", ""); in eval says Global symbol "$dbh" requires explicit package name at line ever dbh is used> There is a ma

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Jasbinder Singh Bali
just wondeng why doesn't it let me put my $dbh=DBI->connect("dbi:Pg:dbname=dbunmask; host=192.168.0.120; port=5432;", "", ""); in eval says Global symbol "$dbh" requires explicit package name at line Jas On 3/16/07, Martijn van Oosterhout wrote: On Thu, Mar 15, 2007 at 10:06:06PM -0400, Jas

Re: [GENERAL] exception handling in plperlu

2007-03-16 Thread Martijn van Oosterhout
On Thu, Mar 15, 2007 at 10:06:06PM -0400, Jasbinder Singh Bali wrote: > How about using a try catch block? > isn't that more efficient that eval? Umm, eval is perl's equivalent of try/catch. There is no other way. Have a nice day, -- Martijn van Oosterhout http://svana.org/kleptog/ > From e

Re: [GENERAL] exception handling in plperlu

2007-03-15 Thread Jasbinder Singh Bali
How about using a try catch block? isn't that more efficient that eval? ~Jas On 3/15/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Jasbinder Singh Bali" <[EMAIL PROTECTED]> writes: > Actually, if I rephrase my requirement, I need to catch an exception at any > point ,where ever it is raised, in th

Re: [GENERAL] exception handling in plperlu

2007-03-15 Thread Tom Lane
"Jasbinder Singh Bali" <[EMAIL PROTECTED]> writes: > Actually, if I rephrase my requirement, I need to catch an exception at any > point ,where ever it is raised, in the perl code. > E.g during an insert, there is a foreign key contraint violation, then i > need to catch this specific error and do