Re: exception handling in plperlu - Mailing list pgsql-general

From Douglas McNaught
Subject Re: exception handling in plperlu
Date
Msg-id 87hcsl43qq.fsf@suzuka.mcnaught.org
Whole thread Raw
In response to Re: exception handling in plperlu  ("Jasbinder Singh Bali" <jsbali@gmail.com>)
Responses Re: exception handling in plperlu  (merlyn@stonehenge.com (Randal L. Schwartz))
List pgsql-general
"Jasbinder Singh Bali" <jsbali@gmail.com> 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 <where ever dbh is
> used>

The my() variable goes out of scope when the eval {} is done.  Declare
the variable outside the eval {}:

my $dbh;

eval { $dbh = connect(...) };

eval { $dbh->prepare(...:) };

-Doug

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: exception handling in plperlu
Next
From: Tony Caduto
Date:
Subject: Re: pg_dumpall and version confusion