<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2838" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New" size=2>Not sure if
this question is appropriate for this group, but here it is.</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New" size=2>I am using
PERL DBI to SELECTing all columns from a table on Neteeza database and am
INSERTing into an existing table on Oracle. However, some of the columns
are character based so they require ("") quotes around the column data to
insert. I need to dynamically built the INSERT values. Is there an
easy way to quote the column data for the INSERT statement. Here are some
examples what I am trying to do:</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2> $d_sth = $d_dbh->prepare("select column_name,
data_type<BR>
from
all_tab_columns<BR>
where table_name like
upper('%$d_tblName%')<BR>
") || die "$DBI::errstr\n";</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2> $d_sth->execute() || die
"$DBI::errstr\n";<BR> while ( $d_arrayref =
$d_sth->fetchrow_arrayref() ) {<BR> if (
@$d_arrayref[1] =~ /CHAR|DATE/ ) {<BR>
$columnsToAssign{ @$_arrayref[0] } =
"0";<BR>
}<BR> }</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2> $s_sth = $s_dbh->prepare("select * from
$s_tblName") || die "$DBI::errstr\n";<BR> $s_sth->execute()
|| die "$DBI::errstr\n";<BR> while ( $s_hashref =
$s_sth->fetchrow_hashref ) {</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2> Name
Null? Type<BR> -----------------------------------------
--------
----------------------------<BR> DLVRB_GID
NOT NULL
NUMBER(10)<BR> PRC_REL_GID
NOT NULL
NUMBER(10)<BR> PRDCT_GID
NOT NULL
NUMBER(10)<BR> BIL_PYMT_TYP_CDE
NOT NULL
CHAR(1)<BR> PRJTD_TRX_CNT
NOT NULL NUMBER(10)</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New" size=2>The column
above (BIL_PYMT_TYP_CDE) require quotes for the INSERT statement. I would
like to dynamically create the INSERT statements like so:</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2> $columnsToAssign =
$columnsToAssign . ", \"" . @$d_arrayref[0] .
"\"";<BR>
}<BR> else
{<BR> $columnsToAssign =
$columnsToAssign . ", " .
@$d_arrayref[0];<BR>
}</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New" size=2>Is there an
easier way?</FONT></SPAN></DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=009085316-13032006><FONT face="Courier New"
size=2>Thanks.</FONT></SPAN></DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face="Courier New" size=2>Peter Loo</FONT></DIV>
<DIV align=left> </DIV>
<DIV> </DIV><p></p><p>This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message.</BODY></HTML>