in reply to Re: Win32::ODBC query error
in thread Win32::ODBC query error

This is the example of that query:
update category set chrCat_Full_Name='Vinyl powder free gloves' where +chrCategory_Code='VINYLPF' Vinyl powder free gloves

Replies are listed 'Best First'.
Re^3: Win32::ODBC query error
by davidrw (Prior) on Aug 30, 2005 at 20:12 UTC
    (note: i'm going to assume that trailing "Vinyl powder free gloves" is a copy/paste error)

    what does $db2->Error() say?

    Taking a closer look at your debugging, you have:
    $db2->Sql($sql2)|| die("Query error");
    Reading the docs for Win32::ODBC, it says that ->Sql() "Returns ? on success, or an error number on failure." .. apparently (after looking at the source) they meant s/\?/undef/ ... BUT you have that '||' in there, so on _success_ it's going to die. You need to change it to something like:
    my $rc = $db2->Sql($sql2); die sprintf("Query error!! RC: %s ; Error: %s ; SQL: %s", $rc, $db2- +>Error(), $sql2) if $rc;

    As i mentioned above, DBI/DBD is far superior for this because of placeholders... and radiantmatrix below was kind enough to post a sample porting of your code -- be sure to review it...

    Update: oops .. forgot the "if $rc" on there ... and changed $Sql->Error() to $db2->Error()
      my $rc = $db2->Sql($sql2); die sprintf "Query error!! RC: %s ; Error: %s ; SQL: %s", $rc, $Sql- +>Error(), $sql2;
      This solution worked for me but without second line. Second line gave me an error saying that i cant call method Error on undefined value. Thank you guys for your help. From what i've read around net DBI looked much easier to read but i just couldn't get it to work. I will give it a shoot again and will see what happens.