473,785 Members | 2,798 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 1891

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

Similar topics

1
3689
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
2470
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
4028
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
4720
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
7898
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
3776
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
4503
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
2661
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
3923
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
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10336
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
10155
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
10095
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
9953
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...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
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
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
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

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.