Subject | Re: [firebird-support] How to change Primary Key on a table by adding a new field |
---|---|
Author | Luigi Siciliano |
Post date | 2015-01-27T14:25:16Z |
thanks for your suggestion.
By ZeosLib TSQLProcessor, I try this:
----------------------
SET TERM !!;
EXECUTE BLOCK RETURNS (stmt VARCHAR(1000)) AS
BEGIN
FOR
SELECT 'ALTER TABLE MYTABLE DROP CONSTRAINT ' ||
rdb$constraint_name
from
rdb$relation_constraints
where
rdb$relation_name = "MYTABLE"
AND rDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
into :stmt
DO begin suspend; execute statement :stmt; end
END!!
set term ; !!
---------------------------
seems to work but not commit the statement. The primary Key is yet present :(
Where I have a mistake?
Thanks
Select trim(RC.RDB$INDEX_NAME)
from RDB$RELATION_CONSTRAINTS RC
where (RC.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY') and
(RC.RDB$RELATION_NAME = :TABELA)
into :PKTEMP
Using that select you can fiind the name of the column who has the primary
key.
Inspired from Carlos Cantu external log procedure. Maybe you can be inspired
to.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]
Sent: Monday, January 26, 2015 8:06 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] How to change Primary Key on a table by adding a
new field
Hello,
I have an application that use a Firebird database and I need to
change a Primary Key on a table by adding a new field.
I can drop a primary key constraint by "ALTER TABLE MyTable DROP
CONSTRAINT MyINTEG_000" where "MyINTEG_000" is the constraint on my
development database file.
I cannot use the instruction above because I don't know in all
production databases of my customers the name of the Primary Key I want
update.
How I can solve?
Thanks.
--
Luigi Siciliano
--------------------------
------------------------------------
------------------------------------
++++++&# 43;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu
there.
Also search the knowledgebases at
http://www.ibphoenix.com/resources/documents/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------
Yahoo Groups Links
--
Luigi Siciliano --------------------------