473,699 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling referential integrity

Hi, my problem is this:

I have a table called faps_key the unique identifier being key_code:

taupo=# \d faps_key
Table "faps_key"
Column | Type | Modifiers
-----------------+-----------------------+-----------
key_code | character varying(6) | not null
date_key_issued | date |
date_key_due | date |
key_issued_by | character varying(12) |
description | character varying(20) |
comments | character varying(30) |
permit_id | integer |
status | character varying(10) |
Primary key: faps_key_key_co de_pk
Triggers: RI_ConstraintTr igger_243657,
RI_ConstraintTr igger_243665,
RI_ConstraintTr igger_243667

Problem is the users now want the old key_codes deleted, and new ones entered, some of which are the same as the old ones. So I need to disable the referential integrity constraints in order to delete the old codes and input the new ones. I've had a look through the archives and at the below link, however i'm having trouble.

Associated tables are:

\d faps_permit
Table "faps_permi t"
Column | Type | Modifiers
-------------------+------------------------+-----------
permit_id | integer | not null
person_id | integer | not null
date_from | date | not null
date_to | date | not null
location | character varying(30) | not null
purpose | character varying(30) | not null
subpurpose | character varying(30) | not null
vehicle_rego | character varying(6) |
vehicle_type | character varying(30) |
dogs | character varying(3) |
permit_conditio ns | character varying(300) |
other_info | character varying(300) |
issued_by | character varying(12) | not null
issue_date | date |
permit_printed | integer |
firearms_licenc e | character varying(20) |
drivers_licence | character varying(10) |
cancel_permit | character varying(10) |
Primary key: faps_permit_per mit_id_pk
Triggers: RI_ConstraintTr igger_243659,
RI_ConstraintTr igger_243661

\d archive_faps_ke y
Table "archive_faps_k ey"
Column | Type | Modifiers
-----------------+-----------------------+-----------
key_code | character varying(6) | not null
permit_id | integer | not null
date_key_issued | date |
date_returned | date |
date_key_due | date |
status | character varying(10) |
key_issued_by | character varying(12) |
Primary key: archivefapskey_ keycode_permit_ i
Triggers: RI_ConstraintTr igger_243663

I checked out the following link, and followed the instructions

http://techdocs.postgresql.org/techd...lintegrity.php

but i still can't delete rows.

As you can see from below all tgenabled fields are set to 'f'. but further below when I try to delete it still fails.
taupo=> select * from pg_trigger;
tgrelid | tgname | tgfoid | tgtype | tgenabled | tgisconstraint | tgconstrname | tgconstrrelid | tgdeferrable | tginitdeferred | tgnargs | tgattr | tgargs
---------+-----------------------------+--------+--------+-----------+----------------+---------------------------+---------------+--------------+----------------+---------+--------+------------------------------------------------------------------------------------------------------
1260 | pg_sync_pg_pwd | 1689 | 29 | t | f | | 0 | f | f | 0 | |
233004 | RI_ConstraintTr igger_243663 | 1644 | 21 | f | t | archivefapskey_ keycode_fk | 233001 | f | f | 6 | | archivefapskey_ keycode_fk\000a rchive_faps_key \000faps_key\00 0UNSPECIFIED\00 0key_code\000ke y_code\000
233001 | RI_ConstraintTr igger_243657 | 1644 | 21 | f | t | faps_key_permit id_fk | 232998 | f | f | 6 | | faps_key_permit id_fk\000faps_k ey\000faps_perm it\000UNSPECIFI ED\000permit_id \000permit_id\0 00
233001 | RI_ConstraintTr igger_243665 | 1654 | 9 | f | t | archivefapskey_ keycode_fk | 233004 | f | f | 6 | | archivefapskey_ keycode_fk\000a rchive_faps_key \000faps_key\00 0UNSPECIFIED\00 0key_code\000ke y_code\000
233001 | RI_ConstraintTr igger_243667 | 1655 | 17 | f | t | archivefapskey_ keycode_fk | 233004 | f | f | 6 | | archivefapskey_ keycode_fk\000a rchive_faps_key \000faps_key\00 0UNSPECIFIED\00 0key_code\000ke y_code\000
232998 | RI_ConstraintTr igger_243659 | 1654 | 9 | f | t | faps_key_permit id_fk | 233001 | f | f | 6 | | faps_key_permit id_fk\000faps_k ey\000faps_perm it\000UNSPECIFI ED\000permit_id \000permit_id\0 00
232998 | RI_ConstraintTr igger_243661 | 1655 | 17 | f | t | faps_key_permit id_fk | 233001 | f | f | 6 | | faps_key_permit id_fk\000faps_k ey\000faps_perm it\000UNSPECIFI ED\000permit_id \000permit_id\0 00
(7 rows)

taupo=> delete from faps_key where substring(key_c ode from 1 for 1) = 'B';
ERROR: archivefapskey_ keycode_fk referential integrity violation - key in faps_key still referenced from archive_faps_ke y

Any ideas about how best to go about solving my problem?

Best Regards,

Sharon.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #1
0 1883

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3681
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into "access_log", the referential integrity triggers generate these queries: SELECT 1 FROM ONLY "public"."application_type" x
7
2463
by: Jimmie H. Apsey | last post by:
Referential Integrity on one of our production tables seems to have been lost. I am running Postgres 7.1.3 embedded within Red Hat kernel-2.4.9-e.49. Within that I have a table with referential integrity constraints which no longer work. I do not know how to disable referential integrity on a column in a table. I do not know how to view what Postgres thinks my referential integrity
5
4015
by: Geisler, Jim | last post by:
So, as far as I know, PostgreSQL does not have any way of verifying the loss of referential integrity. Are there any recommended methods or utilities for checking referential integrity in a PostgreSQL database?
6
4714
by: heyvinay | last post by:
I have transaction table where the rows entered into the transaction can come a result of changes that take place if four different tables. So the situation is as follows: Transaction Table -TranId -Calc Amount Table 1 (the amount is inserted into the transaction table) - Tb1Id
80
7868
by: Andrew R | last post by:
Hi I'm creating a series of forms, each with with around 15-20 text boxes. The text boxes will show data from tables, but are unbound to make them more flexible. I want the form to be used for both adding new data and modifying existing data. I have created a save button on the form. When the user clicks the save button, the code checks to see if there
3
3774
by: moskie | last post by:
Is there a way to run an alter table statement that adds a constraint for a foreign key, but does *not* check the existing data for refrential integrity? I'm essentially looking for the equivalent to SQL Server's NOCHECK flag. I am able to create equivalent keys in the Relationships screen, as long as the "Enforce referential integrity" box is left unchecked. But when I try to create that relationship with an ALTER TABLE statement, I...
6
4500
by: CPAccess | last post by:
How do I maintain referential integrity between a main form and a subform, each based upon different (but joined with integrity enforced) table? Here's the situation: I have two tables: tblContracts and tblPayments. tblContracts has an autonumber field called IDKey as its primary key. tblPayments also has an IDKey field (Integer datatype). The two tables are linked in a one-to-many relationship on the field IDKey with referential integrity...
3
2659
by: Wayne | last post by:
I've inadvertently placed this post in another similar newgroup, and I apologise if you get it twice. I'm building a database that consists of frontend and backend. Some of the lookup tables need to reside in the frontend database. The data in the lookup fields that relate to the backend tables will never change, but a descriptor for items in these fields will. I may need to update the descriptors periodically, hence the need to keep...
2
3920
by: ApexData | last post by:
Access2000, using a continuous form. I’m getting a message that say “you cannot add or change a record because a related record is required in table Employee”. This occurs in all my combobox fields that have referential integrity linked to another table. I do not have the field in the table set as required, and I do not want to require the entry. If the record is filled out completely and added to the table, you can go back to the...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.