Fw: Syntax error when inserting strings into a table

[email protected] (Julia Luxenburger)
Newsgroups perl.dbd.pg
Message-ID <OFE7351839.9AF51E6D-ONC125721F.0037BCE8-C125721F.0037CBD4@notes.mpi-sb.mpg.de>
Julia Luxenburger/AG5/MPII/DE 
11/07/2006 09:37 AM

To
[email protected]
cc

Subject
Syntax error when inserting strings into a table





Hi, 
I experience a problem with the insertion of strings into a table. 
However, this problem does not occur for all strings and there is no 
pattern or specific character I could find that triggers the exception. 
Okay, here is what I do:



my $stmt_resultset = $this->{db_handler}->prepare_cached("insert into 
resultset(session_id, query_
+id, uri, domain, rank) values(?,?,?,?,?)");
        $success = 1;

        for(my $i = 0; $i < @resultset; $i++)
        {
            my $result = $resultset[$i];
          $success &&= $stmt_resultset->execute($session_id,$query_id,
 
$this->{db_handler}->quote($result),$this->{db_handler}->quote($param4),$i+1 
);
        }

          if($success)
            {
                $this->{db_handler}->commit;
                print STDOUT "..committed" if debug;
            }
            else
            {
                $this->{db_handler}->rollback;
                print "Couldn't store resultset: " . 
$this->{db_handler}->errstr . "\n";
            }

Alternatively, I already tried to use bind_param, e.g., as in

         $stmt_resultset->bind_param(1, $session_id, SQL_INTEGER);
         #   $stmt_resultset->bind_param(2, $query_id, SQL_INTEGER);
         #   $stmt_resultset->bind_param(3, $result, SQL_VARCHAR);

and call execute without arguments which however does not work as well.

Here is a sample of the error I get:

DBD::PgPP::st execute failed: ERROR:  syntax error at or near "www" at 
character 133

This is when trying to insert a URL, however, when inspecting the database 
I find that some urls could have been written, and I cannot make up a 
pattern or specific character that is the reason - I also increased the 
size of the column definition without any effect. 

Has anyone an idea what the cause of this error might be - how to fix it? 

Thanks a lot for your help,
Julia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.