I am doing a INSERT using this code;
The error I get is
That is good. I do not want to insert the record if it is already in the table, but I don't want the program to stop.
I added the 'or die' so I could see what was happening. Without it the program was dying with the message "prepare_cached failed: ORA-01756: quoted string not properly terminated". I knew that message was not an acturacte error message.
The bottom line, I do not want duplicates and I don't want the program to fail. I am writing all console output to a log for review using 'perl reqNote_sh >temp.txt'.
Can somebody help me?
Code:
## save the variables to procure.RECPO2 using INSERT
$insert = "INSERT INTO procure.RECPO2 (po_number, requestor,
req_num, send_to, vend_name, buyer_name) VALUES
('" . $sPO . "', '" . $vReqName . "', '" .
$vSource . "', '" . $vSendTo . "', '" .
$vVenNm . "', '" . $vBuyer . "')";
## if requisition # is zero and requester blank - don't write record
if (length($vSource) gt 1 && length($vReqName) gt 1)
{
$st6 = $dbh->prepare_cached($insert)
or die "Couldn't prepare insert: " . $dbh->errstr;
$st6->execute()
or die "Couldn't execute insert: " . $st6->errstr;
}
The error I get is
Code:
DBD::Oracle::st execute failed: ORA-00001: unique constraint (PROCURE.PCR_RECPO2
_PK) violated (DBD ERROR: OCIStmtExecute) [for Statement "INSERT INTO procure.RE
CPO2 (po_number, requestor,
req_num, send_to, vend_name, buyer_name) V
ALUES
(' 1625162', 'ADRIAN SAMPSON', '9371
46', 'asampson@ochsner.org', 'NEOTECH PRODUCTS INC', 'LAURA SPURGEON')"] at reqN
ote_sh line 148.
Couldn't execute insert: ORA-00001: unique constraint (PROCURE.PCR_RECPO2_PK) vi
olated (DBD ERROR: OCIStmtExecute) at reqNote_sh line 148.
That is good. I do not want to insert the record if it is already in the table, but I don't want the program to stop.
I added the 'or die' so I could see what was happening. Without it the program was dying with the message "prepare_cached failed: ORA-01756: quoted string not properly terminated". I knew that message was not an acturacte error message.
The bottom line, I do not want duplicates and I don't want the program to fail. I am writing all console output to a log for review using 'perl reqNote_sh >temp.txt'.
Can somebody help me?