Thank you for your help on the trigger question. The RULE worked for most
of the cases I had for this, but I have one that is giving me trouble.
Here are my table definitions:
CREATE SEQUENCE "stat_id_seq" cache 1;
CREATE TABLE "ref_status" (
"status_id" integer DEFAULT nextval('stat_id_seq') PRIMARY KEY,
"short_name" varchar(5),
"description" varchar(25),
"modified" timestamp with time zone DEFAULT current_timestamp,
"modified_by" varchar(50) DEFAULT current_user
);
CREATE SEQUENCE "prod_id_seq" cache 1;
CREATE TABLE "prod_data" (
"prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY,
"client_id" integer NOT NULL,
"cat_id" integer NOT NULL,
"status_id" integer NOT NULL,
"modified" timestamp with time zone DEFAULT current_timestamp,
"modified_by" varchar(50) DEFAULT current_user,
CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id)
REFERENCES ref_clients(client_id)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id)
REFERENCES ref_category(cat_id)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT prod_stat_fk FOREIGN KEY (status_id)
REFERENCES ref_status(status_id)
ON DELETE CASCADE ON UPDATE CASCADE
);
TABLE job_data_bak looks just like job_data but with all constraints
removed.
Here is where the problem begins. When I try to create this rule:
CREATE RULE log_prod_upd AS ON UPDATE TO prod_data
where NEW.prod_id = OLD.prod_id
DO INSERT INTO job_data_bak VALUES (
OLD.prod_id,OLD.client_id,
OLD.cat_id, OLD.status_id,
OLD.modified,OLD.modified_by
);
This is the error I get:
ERROR: column "status_id" is of type 'integer' but expression is of type
'character varying'
You will need to rewrite or cast the expression
I tried casting status_id to text, but that doesn't work. I do not know
what I need to cast to make this work. Maybe another pair of eyes will
see something...
Here's the dump of the tables:
Table "prod_data"
Column | Type | Modifiers
--------------+--------------------------+----------------------------------------------------
prod_id | integer | not null default
nextval('prod_id_seq'::text)
client_id | integer | not null
cat_id | integer | not null
status_id | integer | not null
modified | timestamp with time zone | default
('now'::text)::timestamp(6) with time zone
modified_by | character varying(50) | default "current_user"()
Primary key: job_data_pkey
Table "ref_status"
Column | Type | Modifiers
--------------+--------------------------+----------------------------------------------------
status_id | integer | not null default
nextval('stat_id_seq'::text)
short_name | character varying(5) |
description | character varying(25) |
modified | timestamp with time zone | default
('now'::text)::timestamp(6) with time zone
modified_by | character varying(50) | default "current_user"()
Primary key: ref_status_pkey
Thank you,
Barb Lindsey
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend 5 3527
On Fri, 7 Nov 2003, Barbara Lindsey wrote: CREATE SEQUENCE "prod_id_seq" cache 1; CREATE TABLE "prod_data" ( "prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY, "client_id" integer NOT NULL, "cat_id" integer NOT NULL, "status_id" integer NOT NULL, "modified" timestamp with time zone DEFAULT current_timestamp, "modified_by" varchar(50) DEFAULT current_user, CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id) REFERENCES ref_clients(client_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id) REFERENCES ref_category(cat_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_stat_fk FOREIGN KEY (status_id) REFERENCES ref_status(status_id) ON DELETE CASCADE ON UPDATE CASCADE );
TABLE job_data_bak looks just like job_data but with all constraints removed.
Here is where the problem begins. When I try to create this rule:
CREATE RULE log_prod_upd AS ON UPDATE TO prod_data where NEW.prod_id = OLD.prod_id DO INSERT INTO job_data_bak VALUES ( OLD.prod_id,OLD.client_id, OLD.cat_id, OLD.status_id, OLD.modified,OLD.modified_by );
Was this intended to go to prod_data_bak as opposed to job_data_bak?
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly
For what it's worth, this appears to be a case scenario problem within
postgres.(?!)
I removed the ref_status table entirely and all the places it is
referenced, and the problem switched to another variable on another rule
for another table...
Any suggestions? Workarounds? Thank you for your help on the trigger question. The RULE worked for most of the cases I had for this, but I have one that is giving me trouble. Here are my table definitions:
CREATE SEQUENCE "stat_id_seq" cache 1; CREATE TABLE "ref_status" ( "status_id" integer DEFAULT nextval('stat_id_seq') PRIMARY KEY, "short_name" varchar(5), "description" varchar(25), "modified" timestamp with time zone DEFAULT current_timestamp, "modified_by" varchar(50) DEFAULT current_user );
CREATE SEQUENCE "prod_id_seq" cache 1; CREATE TABLE "prod_data" ( "prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY, "client_id" integer NOT NULL, "cat_id" integer NOT NULL, "status_id" integer NOT NULL, "modified" timestamp with time zone DEFAULT current_timestamp, "modified_by" varchar(50) DEFAULT current_user, CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id) REFERENCES ref_clients(client_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id) REFERENCES ref_category(cat_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_stat_fk FOREIGN KEY (status_id) REFERENCES ref_status(status_id) ON DELETE CASCADE ON UPDATE CASCADE );
TABLE job_data_bak looks just like job_data but with all constraints removed.
Here is where the problem begins. When I try to create this rule:
CREATE RULE log_prod_upd AS ON UPDATE TO prod_data where NEW.prod_id = OLD.prod_id DO INSERT INTO job_data_bak VALUES ( OLD.prod_id,OLD.client_id, OLD.cat_id, OLD.status_id, OLD.modified,OLD.modified_by );
This is the error I get:
ERROR: column "status_id" is of type 'integer' but expression is of type 'character varying' You will need to rewrite or cast the expression I tried casting status_id to text, but that doesn't work. I do not know what I need to cast to make this work. Maybe another pair of eyes will see something... Here's the dump of the tables: Table "prod_data" Column | Type | Modifiers --------------+--------------------------+---------------------------------------------------- prod_id | integer | not null default nextval('prod_id_seq'::text) client_id | integer | not null cat_id | integer | not null status_id | integer | not null modified | timestamp with time zone | default ('now'::text)::timestamp(6) with time zone modified_by | character varying(50) | default "current_user"() Primary key: job_data_pkey
Table "ref_status" Column | Type | Modifiers --------------+--------------------------+---------------------------------------------------- status_id | integer | not null default nextval('stat_id_seq'::text) short_name | character varying(5) | description | character varying(25) | modified | timestamp with time zone | default ('now'::text)::timestamp(6) with time zone modified_by | character varying(50) | default "current_user"() Primary key: ref_status_pkey Thank you, Barb Lindsey ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org
I see what you mean - yes - corrections to post below: On Fri, 7 Nov 2003, Barbara Lindsey wrote:
CREATE SEQUENCE "prod_id_seq" cache 1; CREATE TABLE "prod_data" ( "prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY, "client_id" integer NOT NULL, "cat_id" integer NOT NULL, "status_id" integer NOT NULL, "modified" timestamp with time zone DEFAULT current_timestamp, "modified_by" varchar(50) DEFAULT current_user, CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id) REFERENCES ref_clients(client_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id) REFERENCES ref_category(cat_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_stat_fk FOREIGN KEY (status_id) REFERENCES ref_status(status_id) ON DELETE CASCADE ON UPDATE CASCADE );
TABLE prod_data_bak looks just like prod_data but with all constraints removed.
Here is where the problem begins. When I try to create this rule:
CREATE RULE log_prod_upd AS ON UPDATE TO prod_data where NEW.prod_id = OLD.prod_id DO INSERT INTO prod_data_bak VALUES ( OLD.prod_id,OLD.client_id, OLD.cat_id, OLD.status_id, OLD.modified,OLD.modified_by );
Was this intended to go to prod_data_bak as opposed to job_data_bak?
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to ma*******@postgresql.org so that your message can get through to the mailing list cleanly
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly
On Fri, 7 Nov 2003, Barbara Lindsey wrote: I see what you mean - yes - corrections to post below:
On Fri, 7 Nov 2003, Barbara Lindsey wrote:
CREATE SEQUENCE "prod_id_seq" cache 1; CREATE TABLE "prod_data" ( "prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY, "client_id" integer NOT NULL, "cat_id" integer NOT NULL, "status_id" integer NOT NULL, "modified" timestamp with time zone DEFAULT current_timestamp, "modified_by" varchar(50) DEFAULT current_user, CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id) REFERENCES ref_clients(client_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id) REFERENCES ref_category(cat_id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT prod_stat_fk FOREIGN KEY (status_id) REFERENCES ref_status(status_id) ON DELETE CASCADE ON UPDATE CASCADE );
TABLE prod_data_bak looks just like prod_data but with all constraints removed.
Here is where the problem begins. When I try to create this rule:
CREATE RULE log_prod_upd AS ON UPDATE TO prod_data where NEW.prod_id = OLD.prod_id DO INSERT INTO prod_data_bak VALUES ( OLD.prod_id,OLD.client_id, OLD.cat_id, OLD.status_id, OLD.modified,OLD.modified_by );
Was this intended to go to prod_data_bak as opposed to job_data_bak?
What version are you running?
I had to drop the extra references constraints to other tables that
weren't given, but had no problems with the creation on the rule once I
did so, given creating a prod_data_bak that didn't have any of the
references constraints (or the primary key) and it seemed to work for me
(using my 7.3.4 system)
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org
Running with version 7.2.1 On Fri, 7 Nov 2003, Barbara Lindsey wrote:
I see what you mean - yes - corrections to post below:
> On Fri, 7 Nov 2003, Barbara Lindsey wrote: > >> CREATE SEQUENCE "prod_id_seq" cache 1; >> CREATE TABLE "prod_data" ( >> "prod_id" integer DEFAULT nextval('prod_id_seq') PRIMARY KEY, >> "client_id" integer NOT NULL, >> "cat_id" integer NOT NULL, >> "status_id" integer NOT NULL, >> "modified" timestamp with time zone DEFAULT >> current_timestamp, "modified_by" varchar(50) DEFAULT >> current_user, >> CONSTRAINT prod_clnt_fk FOREIGN KEY (client_id) >> REFERENCES ref_clients(client_id) >> ON DELETE CASCADE ON UPDATE CASCADE, >> CONSTRAINT prod_cat_fk FOREIGN KEY (cat_id) >> REFERENCES ref_category(cat_id) >> ON DELETE CASCADE ON UPDATE CASCADE, >> CONSTRAINT prod_stat_fk FOREIGN KEY (status_id) >> REFERENCES ref_status(status_id) >> ON DELETE CASCADE ON UPDATE CASCADE >> ); >> >> TABLE prod_data_bak looks just like prod_data but with all constraints removed. >> >> >> Here is where the problem begins. When I try to create this rule: >> >> CREATE RULE log_prod_upd AS ON UPDATE TO prod_data >> where NEW.prod_id = OLD.prod_id >> DO INSERT INTO prod_data_bak VALUES ( >> OLD.prod_id,OLD.client_id, >> OLD.cat_id, OLD.status_id, >> OLD.modified,OLD.modified_by >> ); > > Was this intended to go to prod_data_bak as opposed to job_data_bak?
What version are you running?
I had to drop the extra references constraints to other tables that weren't given, but had no problems with the creation on the rule once I did so, given creating a prod_data_bak that didn't have any of the references constraints (or the primary key) and it seemed to work for me (using my 7.3.4 system)
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Maurice LING |
last post by:
Hi,
I have the following codes:
from __future__ import nested_scopes
import re
from UserDict import UserDict
class Replacer(UserDict):
|
by: Chris Dunaway |
last post by:
When deciding to use a structure or a class, what is the general "rule
of thumb"? When you're creating your data model, what factors
dictate that you use a class instead of a structure?
...
|
by: Allen Browne |
last post by:
Subform is based on a single-table query that contains a calculated field:
Amount: Round(CCur(Nz(*,0)),2)
Continuous subform displays this field in a text box named Amount.
As user enters new...
|
by: kermit |
last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or
Javascript on an aspx page.
I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object',...
|
by: Stu Carter |
last post by:
Hi,
ENV: Windows 2003 Server SP1 (+all updates), VS 2003, .Net 1.1 SP1
We've got an ASP.Net web application using State Service. All is fine until
we tried to use the app through a virtual...
|
by: jeffc226 |
last post by:
I'm interested in an idiom for handling errors in functions without
using traditional nested ifs, because I think that can be very awkward
and difficult to maintain, when the number of error checks...
|
by: =?Utf-8?B?VmlqYXkgQ2hpa3Rl?= |
last post by:
Hi Experts,
With Session Affinity and Web Server Farm on ISA Server 2006 accessing 2
backend IIS servers, I’m getting error “Validation of ViewState MAC failed.
If this application is hosted...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
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,...
|
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...
| |