in reply to Inserting in an unknown point

If the FOREIGN KEY statement always follows immediately behind the fk table, and the fk table only shows up once in the sql string (i.e. if your sql string always looks like the above), you can simply do:

use strict; my $sql='"ALTER TABLE "ARSAMS"."TCMD_HEADER" ADD CONSTRAINT FK_TCMD_HE +A_OWNER_CONTAINE (CONTAINER_OWNER_CD) REFERENCES ARSAMS.CONTAINER_OWN +ER_CODE (CONTAINER_OWNER_CD)"'; my $fk_table_name="FK_TCMD_HEA_OWNER_CONTAINE"; $sql=~s/($fk_table_name)/$1 FOREIGN KEY/; print $sql;

CU
Robartes-

Replies are listed 'Best First'.
Re: Re: Inserting in an unknown point
by curtisb (Monk) on Oct 04, 2002 at 15:20 UTC
    Great!, but only one problem. How would you handle the table name changing. There are over 340 table names.

    Thanks
    Bobby