Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to switch between product lines in DBI command 1

Status
Not open for further replies.

jcarrott

Programmer
May 28, 2009
130
US
My code is set to automatically switch between product lines (production and test) for the regular code, but it fails to switch in the DBI command.

Here is the basic code.

#!/usr/lpp/oracle/product/10.2/perl/bin/perl
#### program variables

if($PRODLINE eq "ocfp") {
$sys = "ocfp";
$dbsys = "lawocfp";
}
else {
$sys = "ocft";
$dbsys = "lawocft";
}

$LAWDIR="/usr/lawson/lawson/";
$vPath1=$LAWDIR . $sys . "/edi/in/810/";
$vName1="GHX810.out";
$vFlag = "";

... code...

## save the line record
use DBI;
$dbh = DBI->connect('DBI:Oracle:host=$dbsys;
sid=$dbsys', 'procure', 'procure90') or
die "$DBI::errstr";
$query = "INSERT INTO omflaw.X12LINE(company, invoice,
invoice_dte, po_number, line_nbr, item, ven_item,
description, qty, uom, price) VALUES
('"."$company"."',
'"."$invoice"."',
'"."$invoice_dte"."',
'"."$po_number"."',
$line_nbr,
'"."$item"."',
'"."$ven_item"."',
'"."$description"."',
'"."$qty"."',
'"."$uom"."',
'"."$price"."')";
$dbh->do($query) or die "$DBI::errstr";
$dbh->disconnect();
}

The error I get is

$ ./ghxEDMP
DBI connect('host=$dbsys;
sid=$dbsys','procure',...) failed: ORA-1
2545: Connect failed because target host or object does not exist (DBD ERROR: OC
IServerAttach) at ghxEDM_pl line 153
ORA-12545: Connect failed because target host or object does not exist (DBD ERRO
R: OCIServerAttach) at ghxEDM_pl line 153, <X12> line 1.

The issue is that the variable $dbsys did not convert to it's value.

Is there a way to use a variable in the DBI statement?
 
Hi,

Change the connect string to:

Code:
 $dbh = DBI->connect("DBI:Oracle:host=$dbsys;
                    sid=$dbsys", "procure", "procure90") or
                    die "$DBI::errstr";

Variables are taken literally within single quotes and don't evaluate.

Thanks,

Steven Parker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top