Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D4FF89FB1E9 for ; Thu, 4 Oct 2007 09:57:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 20956-05 for ; Thu, 4 Oct 2007 09:57:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from interscan.indicator.com (mail.indicator.be [193.121.199.3]) by postgresql.org (Postfix) with ESMTP id 7BE959FB289 for ; Thu, 4 Oct 2007 09:57:23 -0300 (ADT) Received: from webaccess.indicator.be ([10.100.1.7]) by interscan.indicator.com with InterScan Message Security Suite; Thu, 04 Oct 2007 14:56:09 +0200 Received: from DOMEXT-MTA by webaccess.indicator.bewith Novell_GroupWise; Thu, 04 Oct 2007 14:57:17 +0200 Message-Id: <4704FF3F.A3DD.0030.0@indicator.be> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Thu, 04 Oct 2007 14:57:03 +0200 From: "Bart Degryse" To: Subject: Re: Rule Error References: <008f01c80678$de562990$6f00a8c0@hengky> In-Reply-To: <008f01c80678$de562990$6f00a8c0@hengky> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__PartC7E1890F.0__=" X-imss-version: 2.048 X-imss-result: Passed X-imss-approveListMatch: *@indicator.be X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/23 X-Sequence-Number: 29395 --=__PartC7E1890F.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable You have defined the fields KODEGL and NAMAREK as uppercased field names. In your rule you refer to an unquoted field KODEGL twice and twice to an = unquoted field NAMAREK. Default behaviour of PostgreSQL for unquoted fieldnames is to lowercase = them. As such these fields effectively don't exist in your tables. Try CREATE RULE "rule1" AS ON INSERT TO "public"."tblmasdbt"=20 DO (insert into tblmasgl ("KODEGL","NAMAREK") VALUES (new."KODEGL", = new."NAMAREK")); >>> "Hengky Lie" 2007-10-04 13:22 >>> Dear Friends,=20 =20 I have problem with rule and tried several times to solve it but not yet = success. Hope someone can help me. =20 I have 2 tables : tblmasdbt and tblmasgl.=20 =20 I want on every record insertion in tblmasdbt, that record also automatical= ly insert into tblmasdbt. I need only 2 related field. =20 So I create rule like this =20 --------------- SQL --------------- CREATE RULE "rule1" AS ON INSERT TO "public"."tblmasdbt"=20 DO (insert into tblmasgl (KODEGL,NAMAREK) VALUES (new.KODEGL, new.NAMAREK))= ; =20 But I always get this error : =20 ---------- ERROR MESSAGE ---------- =20 ERROR: column "kodegl" of relation "tblmasgl" does not exist =20 =20 Here is the Table Structure=20 --------------------------- =20 CREATE TABLE "public"."tblmasgl" ( "KODEGL" VARCHAR(15) NOT NULL,=20 "NAMAREK" VARCHAR(50),=20 "GOLONGAN" VARCHAR(10),=20 "AWAL" DOUBLE PRECISION DEFAULT 0,=20 "Operator" VARCHAR(3),=20 CONSTRAINT "tblmasgl_pkey" PRIMARY KEY("KODEGL"),=20 CONSTRAINT "tblmasgl_fk" FOREIGN KEY ("KODEGL") REFERENCES "public"."tbltragl"("KODEGL") ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE ) WITHOUT OIDS; =20 =20 =20 CREATE TABLE "public"."tblmasdbt" ( "KODEGL" VARCHAR(15) NOT NULL,=20 "NAMAREK" VARCHAR(50),=20 "ALAMAT" VARCHAR(75),=20 "Telp" VARCHAR(50),=20 "Facs" VARCHAR(50),=20 "KOTA" VARCHAR(30),=20 "HP" VARCHAR(20),=20 "Plafond" DOUBLE PRECISION DEFAULT 0,=20 "Operator" VARCHAR(3),=20 "SALDOAWAL" DOUBLE PRECISION DEFAULT 0,=20 CONSTRAINT "tblmasdbt_pkey" PRIMARY KEY("KODEGL") ) WITHOUT OIDS; =20 =20 Hope someone could help me. Thanks a lot --=__PartC7E1890F.0__= Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Description: HTML
You have defined the fields KODEGL and NAMAREK as uppercased field = names.
In your rule you refer to an unquoted field KODEGL twice and twice to = an unquoted field NAMAREK.
Default behaviour of PostgreSQL for unquoted fieldnames is to = lowercase them.
As such these fields effectively don't exist in your tables.
Try

CREATE RULE "rule1" AS ON INSERT TO "public"."tbl= masdbt"

DO (insert into tblmasgl ("KODEGL","NAMAREK") = VALUES (new."KODEGL", new."NAMAREK"));


>= >> "Hengky Lie" <hengkyliwandouw@gmail.com> 2007-10-04 13:22 = >>>

Dear Friends,

 

I have problem with rule and tried several times = to solve it but not yet success. Hope someone can help me.

 

I have 2 tables : tblmasdbt and tblmasgl. =

 

I want on every record insertion in tblmasdbt, = that record also automatically insert into tblmasdbt. I need only 2 = related field.

 

So I create rule like this

 

--------------- SQL ---------------

CREATE RULE "rule1" AS ON INSERT TO "public"."tbl= masdbt"

DO (insert into tblmasgl (KODEGL,NAMAREK) VALUES = (new.KODEGL, new.NAMAREK));

 

But I always get this error :

 

---------- ERROR MESSAGE ----------

 

ERROR:  column "kodegl" of relation = "tblmasgl" does not exist

 

 

Here is the Table Structure

---------------------------

 

CREATE TABLE "public"."tblmasgl" (

  "KODEGL" VARCHAR(15) NOT NULL, =

  "NAMAREK" VARCHAR(50), <= /FONT>

  "GOLONGAN" VARCHAR(10), =

  "AWAL" DOUBLE PRECISION DEFAULT 0, =

  "Operator" VARCHAR(3), <= /FONT>

  CONSTRAINT "tblmasgl_pkey" PRIMARY = KEY("KODEGL"),

  CONSTRAINT "tblmasgl_fk" FOREIGN KEY = ("KODEGL")

    REFERENCES "public"."tbltragl"= ("KODEGL")

    ON DELETE CASCADE

    ON UPDATE NO ACTION=

    NOT DEFERRABLE

) WITHOUT OIDS;

 

 

 

CREATE TABLE "public"."tblmasdbt" (

  "KODEGL" VARCHAR(15) NOT NULL, =

  "NAMAREK" VARCHAR(50), <= /FONT>

  "ALAMAT" VARCHAR(75),

  "Telp" VARCHAR(50),

  "Facs" VARCHAR(50),

  "KOTA" VARCHAR(30),

  "HP" VARCHAR(20),

  "Plafond" DOUBLE PRECISION DEFAULT 0, =

  "Operator" VARCHAR(3), <= /FONT>

  "SALDOAWAL" DOUBLE PRECISION DEFAULT 0, =

  CONSTRAINT "tblmasdbt_pkey" PRIMARY = KEY("KODEGL")

) WITHOUT OIDS;

 

 

Hope someone could help me. Thanks a lot

--=__PartC7E1890F.0__=--