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

Re^3: dbi placeholders

by fionbarr (Friar)
on Aug 06, 2014 at 13:56 UTC ( [id://1096434]=note: print w/replies, xml ) Need Help??


in reply to Re^2: dbi placeholders
in thread dbi placeholders

my %rec; my $sth1 = $dbh_0->prepare ("select * from production.computersystem") +; my @fields = @{$sth1->{NAME_lc}}; $sth1->bind_columns (\@rec{@{$sth1->{NAME_lc}}}); my $sth2 = do { local $" = ", "; my $sql = "insert into barrycomputersystem (@fields) values (@{ +[('?')x@fields]})"; $dbh_1->prepare ($sql); }; $sth2->bind_columns (\@rec{@fields}); while ($sth1->fetch) { $sth2->execute; }
this is very interesting but get an error: 'statement has no result column' in the $sth2->bind_columns line

Replies are listed 'Best First'.
Re^4: dbi placeholders
by Tux (Canon) on Aug 06, 2014 at 14:25 UTC

    Sorry, my bad. bind_columns doesn't work on inserts :(

    # Delete the bind_columns line for sth2 while ($sth1->fetch) { $sth2->execute (@rec{@fields}); }

    Enjoy, Have FUN! H.Merijn
      deleted the bind but another error: fetch failed: Function sequence error (SQL-HY010)
        Try executing $sth1
        my $sth1 = $dbh_0->prepare ("select * from log"); my @fields = @{$sth1->{NAME_lc}}; $sth1->execute(); $sth1->bind_columns (\@rec{@{$sth1->{NAME_lc}}});
        poj

        Is this related? I don't have MS-SQL.


        Enjoy, Have FUN! H.Merijn

        Did you research this error code?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1096434]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-25 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found