Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: oracle connection

by Eliya (Vicar)
on Jun 01, 2012 at 18:00 UTC ( #973828=note: print w/replies, xml ) Need Help??


in reply to oracle connection

You could put them in a hash. For example, pass the names to the routine (e.g. proc( [qw(foo bar)] )), and then say in the routine

my $names = shift; ... @v{@$names} = $sth->fetchrow()

(The @v{...} is a hash slice, which means you can assign multiple entries in one go.)

You can then access the "variables" as $v{foo} and $v{bar}.

Replies are listed 'Best First'.
Re^2: oracle connection
by Corion (Pope) on Jun 01, 2012 at 18:04 UTC

    You can also directly ask DBI to return you a hash:

    my $hash = $sth->fetchrow_hashref();

      Sure you can (presuming the query produces the desired column names).

      I was mainly trying to answer the general case, i.e. the typical "beginner's" problem of wanting to dynamically create variables like

      $xxx = "$DBNAME,$USERNAME,$PROFILE"; my ( '$xxx' ) = ( ... );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://973828]
help
Chatterbox?
[holli]: I really like these guys. Ugly, but hell of a flow.
[holli]: Quite good evidence immigrants can contribute to a countries culture.
LanX ... let me hear your body talk...
[LanX]: well ...immigrant music...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-12-13 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?