Drop Primary Key

Drop Primary Key

Post by Patrick Brosna » Sun, 31 Dec 1899 09:00:00



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;

 
 
 

Drop Primary Key

Post by Art S. Kage » Sun, 31 Dec 1899 09:00:00


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


> 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;


 
 
 

Drop Primary Key

Post by Obnoxio The Clow » Sun, 31 Dec 1899 09:00:00



Quote:

>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 ?

Sure. You can't do dynamic SQL in SPL. There is a Dynamic SPL bladelet at
http://www.iiug.org -- but even that may not support Dynamic DDL. It's your
best bet, though.

Quote:>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;

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
 
 
 

1. Drop primary key

Sardinka,

Please ALWAYS post which version of SQL Server you are using.

The following script executed without errors in SQL Server 2000 w/SP2:

create table Table1 (c1 int NOT NULL constraint Number primary key)
go

alter table Table1 drop constraint Number
go

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


2. Access 77 -> SQL Server via ODBC

3. Replication drops Primary Key designation?

4. Field default values

5. Dropping Primary Key ?

6. JDBC-ODBC-bridge for mac?

7. ALTER TABLE tablename DROP PRIMARY KEY

8. iidbms stopped

9. alter table drop primary key

10. Dropping Primary Key Indexs

11. Push publications drops Primary key ???

12. Drop Primary Key

13. Dropping Primary Key Taking Forever