Maybe trap for oracle error number 1008 ?

my @sql = (
    q{select * from sfile where id = ?},
    q{select * from sfile where id = '?'},
);
for my $sql (@sql) {
    my $stmt = $dbh->prepare($sql);
    eval {
        $stmt->execute();
    };
    if ($@) {
        if ($stmt->err() == 1008) {
            print "statement: $sql is missing a bind var\n";
        }
    }
}


> perl etest
statement: select * from sfile where id = ? is missing a bind var

-----Original Message-----
From: E R [mailto:[email protected]] 
Sent: Monday, April 20, 2009 2:56 PM
To: [email protected]
Subject: new question: accurately detecting ? placeholders

I've got tons of sql that uses ? placeholders.

Is there a way to accurately determine which question marks represent
placeholders and which ones don't?

For instance:

  SELECT LENGTH('?') FROM DUAL;

v.s.

  SELECT LENGTH(?) FROM DUAL;

Thanks,
ER

Reply via email to