http://qs321.pair.com?node_id=73660


in reply to Dereference an array reference

my $slobbo = "select * from bleh where whatever = "; ... ... my $sth = $connection->connection->prepare($slobbo.$thangsname );
this is what placeholders were designed to do.
foreach my $var (@list) $sql = $l_dbh->prepare("INSERT activity (activity_num) VALUES (?)"); @l_sqlparams = ($var); $l_result=$sql->execute (@l_sqlparams) or die 'no';

see?

Replies are listed 'Best First'.
Re: (Boo) Re: Dereference an array reference
by fmogavero (Monk) on Apr 19, 2001 at 18:02 UTC
    This does help to clear things up. But at the same time it leaves a lot of questions.

    I am not trying to insert anything into the database. Where would I put the placeholder in a plain old select statement? || Can you direct me to a node with the answer?

    Does foreach my $var (@list); cause $var to be in list context? || Can you direct me to a node with a good explanation of the differences in context?

    Does @l_sqlparams = ($var); put $var back into an array from list context? || Can you direct me to a node with an explanation?

Re: (Boo) Re: Dereference an array reference
by fmogavero (Monk) on Apr 19, 2001 at 19:24 UTC
    Thank You! I wasn't understanding placeholders. Now I just have to figure out why I'm getting two error messages.
    1.) disallowed implicit conversion from datatype 'varchar' to datatype 'int'.
    After attempted adjustment
    2.) syntax error converting CHAR value 'ARRAY(XXXXXXX)' to an INT4 field
      It sounds like you're :
      1. stuffing non-integer values into an integer field.
      2. not deferencing the array.