RE: Memoizing non-place-holding sql statements to place-holding



> >>> my @new_values = ();
> >>> my @place_holders =
> >>> map {
> >>> if (/^CURRENT TIMESTAMP$/) {
> >>> $_;
> >>> } else {
> >>> push @new_values => $_;
> >>> "?";
> >>> }
> >>> } @args
> >>> ;
> >>
> >
> >SQL::Statement can do this?
> >
> Yes. The snippet I sent before will automatically turn #1 into #2.
>
> #1 INSERT INTO MyTbl (col1,CURRENT_TIMESTAMP,col2)
> VALUES (7,'o''brian') };
>
> #2 INSERT INTO MYTBL (COL1,CURRENT_TIMESTAMP,COL2)
> VALUES (?,?)
>
> And return (7,q{o'brian}) as @vals.

I'm dealing with:

INSERT INTO MyTbl (col1,record_ts,col2)
VALUES (7,CURRENT TIMESTAMP,'o''brian') };

SQL ERROR: 'CURRENT TIMESTAMP' is not a valid value or is not quoted!

"CURRENT TIMESTAMP" is a keyword used by DB2.

Regards,
Hirosi Taguti
h-taguchi@xxxxxxxxxxx

.