From: | Tariq Muhammad <tmuhamma(at)libertyrms(dot)com> |
---|---|
To: | Jessica Blank <jb(at)twu(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: ERROR: fmgr_info: function 24809: cache lookup failed |
Date: | 2002-12-17 20:10:39 |
Message-ID: | Pine.LNX.4.21.0212171509200.1727-100000@genesis.int.libertyrms.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You can do without function/trigger, try this :
Create a sequence first :
CREATE SEQUENCE sentenceid_seq;
Create the table:
CREATE TABLE SENTENCES (
SENTENCEID integer DEFAULT NEXTVAL('sentenceid_seq'::text) NOT NULL,
CHAPTERID NUMERIC,
SOFFSET INTEGER,
PRIMARY KEY (SENTENCEID)
);
Besides, I am not sure if DUAL exists in PostgreSQL.
Tariq Muhammad
Liberty RMS
tariq(at)libertyrms(dot)info
v:416-646-3304 x 111
c:416-993-1859
p:416-381-1457
On Tue, 17 Dec 2002, Jessica Blank wrote:
> Hi all. I feel awfully stupid.
>
> Migrating my skillset from Oracle to Postgres, I am trying (in vain) to
> create a trigger and a sequence to "auto increment" the primary key in a
> table, so I won't have to worry about setting it; each time you INSERT
> into the table, the primary key will be automagically assigned.
>
> Problem is, it isn't working... I get "cache lookup failed" whenever I try
> to INSERT on that table!
>
> THE TABLE:
> CREATE TABLE SENTENCES (
> SENTENCEID NUMERIC,
> CHAPTERID NUMERIC,
> SOFFSET INTEGER,
> PRIMARY KEY (SENTENCEID)
> );
>
> THE SEQUENCE:
> CREATE SEQUENCE sentenceid_seq;
>
> THE FUNCTION:
> CREATE FUNCTION sentenceid_fcn()
> RETURNS OPAQUE AS '
> BEGIN
> SELECT nextval(sentenceid_seq)
> INTO :new.sentenceid
> FROM dual;
> END; ' language plpgsql;
>
> THE TRIGGER:
> CREATE TRIGGER sentenceid_trig
> BEFORE INSERT
> ON sentences
> FOR EACH ROW
> EXECUTE PROCEDURE sentenceid_fcn();
> END;
>
> And when I try to INSERT into SENTENCES, without my SENTENCEID, hoping
> that the function/trigger/sequence will kick in and assign it for me...
>
> architxts=# INSERT INTO SENTENCES (CHAPTERID, SOFFSET) VALUES (123, 147);
> ERROR: fmgr_info: function 24809: cache lookup failed
>
> I'm certain I'm doing SOMETHING terribly wrong. Could someone help?
> PLEEEEASE? Why am I getting that error?
>
> Many thanks in advance!
>
>
>
> --
> J e s s i c a L e a h B l a n k
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Han Holl | 2002-12-17 20:19:18 | Re: RPMS for Redhat 7.3 ?? |
Previous Message | Camm Maguire | 2002-12-17 19:41:54 | create trigger on view |