develooper Front page | perl.beginners | Postings from February 2002

More clarity needed for fetchrow_arrayref()

From:
McElwee, Shane
Date:
February 13, 2002 07:22
Subject:
More clarity needed for fetchrow_arrayref()
Message ID:
BD898E20FCD1D51181D300B0D049A614282646@kendall-ex2.kendall.akamai.com
> Hi,
> 
> I'm trying to capture output from a table description query, input it into
> an array and use each line of that array as part of a CREATE statement.
> I'm
> trying to use fetchrow_arrayref() but I'm not sure I'm using it correctly
> or
> if its what I should be using. This code won't work because it captures
> the literal reference. How do I get it to output the actual line it
> references. The $i refers to a table name captured earlier from an array
> of table names. Any pointers welcome.     
> 
> while ( $array_ref = $sth->fetchrow_arrayref ) {
>         push @stash, [@$array_ref];
>       }
> 
>       foreach $array_ref (@stash){
>         $sql2 = "CREATE TABLE $i($array_ref)";
>         $sth2 = $dbh2->prepare($sql2);
>         $sth2->execute or die "Can't execute SQL statement: ",
> $sth2->errstr(), "\n";
>       }
> 
This is one example what it is trying to capture:

'cityname' 'string'
'x' 'int'
'y' 'int'

> Thanks
> 
> Shane
> 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About