INSERT statement works by itself but not in the script??

From: Bing Du (bdu_at_iastate.edu)
Date: 03/30/04


Date: Tue, 30 Mar 2004 10:22:39 -0600

Greetings,

This is perl, v5.8.0 built for i386-linux-thread-multi.

The result of the following INSERT is '0E0' (value of $rv) if run in a
Perl script that uses DBI and DBD::mysql (version 2.9003). The table
$ltm_ssn_table is still empty after INSERT.

=============
$rv = $mysql_dbh->do(qq{INSERT INTO $ltm_ssn_table (ltm_number,ssn,notes)
                    SELECT
$source_data_table.crse,$source_data_table.ssn,$old_ltm_ssn_table.notes
                    FROM $source_data_table LEFT JOIN $old_ltm_ssn_table
                    ON $source_data_table.crse=$old_ltm_ssn_table.ltm_number
                    AND $source_data_table.ssn=$old_ltm_ssn_table.ssn
                    WHERE $source_data_table.offer_dept_abrvn='$ltm_string'
                    });
============

However, the above INSERT works fine with the MySQL command line client:

========
mysql> INSERT INTO ltm_ssn (ltm_number,ssn,notes) SELECT
source_data.crse, source_data.ssn, old_ltm_ssn.notes FROM source_data
LEFT JOIN old_ltm_ssn ON source_data.crse=old_ltm_ssn.ltm_number AND
source_data.ssn=old_ltm_ssn.ssn WHERE source_data.offer_dept_abrvn='L TM;
Query OK, 485 rows affected (0.03 sec)
Records: 485 Duplicates: 0 Warnings: 0
==========

Would anybody tell me what's wrong with the INSERT within the script?

Appreciate any help.

Bing



Relevant Pages

  • (Fwd) RE: DBI with ORACLE encryption
    ... Subject: DBI with ORACLE encryption ... perl script to pull data out of the interface and dump the same to the ... All we do with oracle is to take an database connection ...
    (perl.dbi.users)
  • RE: Unable to connect to Oracle on another Unix host in a perl programming using DBI
    ... This is not a DBI issue. ... To those who could help me with a problem connecting to an Oracle database on HP-UX from within a perl script that uses DBI ... In the program I am trying to connect to another unix hostrunning Oracle 8.1.7 holding a table c1dwg. ... The perl script that runs on host A contains these lines. ...
    (perl.dbi.users)
  • Re: Problem with fetching LONGs and LONG RAWs (ORA-01062)
    ... This perl script illustrates a strange problem while fetching ... LONGs and LONG RAWs. ... What is the full version of Oracle? ... What is the version of the DBI? ...
    (comp.databases.oracle.misc)
  • RE: DBI connects to one oracle instance but cannot connect to others
    ... DBI connects to one oracle instance but cannot connect to ... prod, tmp1,...,tmp6. ... my perl script on localhost cannot connect to any of the tmp instances ...
    (perl.dbi.users)
  • RE: DBI with ORACLE encryption
    ... We are using the DBI version 1.06. ... Subject: DBI with ORACLE encryption ... perl script to pull data out of the interface and dump the same to the ... All we do with oracle is to take an database connection ...
    (perl.dbi.users)