Drop Primary Key
Posted in 2000
Topics: Stored Procedures & SPL, Data Types & Schema Design
Hello
I am trying to drop a primary key from a table (Informix 2000) with the
procedure below. When I run it I get the message
"Unable to find CONSTRAINT (prim_key)."
Any thoughts ?
Thanks
Patrick
CREATE PROCEDURE DropSpvxDestPrimKey()
DEFINE prim_key VARCHAR(25);
select constrname into prim_key from sysconstraints where constrtype =
'P'
and tabid = (select tabid from systables where tabname =
'fv_spvx_dest_2');
alter table fv_spvx_dest_2 drop constraint prim_key;
END PROCEDURE;
Because you cannot do dynamic SQL in SPL. Someone submitted a
datablade module to the IIUG Software Repository that will let you
do what you want. You need IDS 9.2x to use it but you have that...
Art S. Kagel
Patrick Brosnan wrote:
>
> Hello
> I am trying to drop a primary key from a table (Informix 2000) with the
> procedure below. When I run it I get the message
> "Unable to find CONSTRAINT (prim_key)."
> Any thoughts ?
> Thanks
> Patrick
>
> CREATE PROCEDURE DropSpvxDestPrimKey()>
> DEFINE prim_key VARCHAR(25);
>
> select constrname into prim_key from sysconstraints where constrtype =
> 'P'
> and tabid = (select tabid from systables where tabname =
> 'fv_spvx_dest_2');
>
> alter table fv_spvx_dest_2 drop constraint prim_key;>
> END PROCEDURE;