X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 22C6B52807 for ; Wed, 18 May 2005 14:29:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07104-09 for ; Wed, 18 May 2005 17:29:23 +0000 (GMT) Received: from gwm.sc.edu (sunny.csd.sc.edu [129.252.152.105]) by svr1.postgresql.org (Postfix) with ESMTP id 4F3B2528A5 for ; Wed, 18 May 2005 14:29:22 -0300 (ADT) Received: from GWHUB-MTA by gwm.sc.edu with Novell_GroupWise; Wed, 18 May 2005 13:29:22 -0400 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.2 Date: Wed, 18 May 2005 13:29:09 -0400 From: "Peter Bense" To: Cc: Subject: Re: My MS-Access problem keeps getting weirder and Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/41 X-Sequence-Number: 5344 This is what I have been reflecting on for awhile. I spoke to some = individuals in #postgresql about the possibility of using a trigger, = stored procedure, or something like that. [Which honestly I have no = experience in implementing.] The rules method seems to be the most straightfoward implementation, = however * but perhaps that's a false presumption? As I understand it a = rule is a type of procedure in and of itself. Is this understanding = correct? If so, what would prevent me from being able to execute more = than one INSERT per rule? ./Peter Peter T. Bense - Teradata Certified Professional (ptbense@gwm.sc.edu) - 803-777-9476=20 Database Administrator/Webmaster Prevention Research Center University of South Carolina >>> "Greg Campbell" 5/17/2005 5:24:14 PM = >>> I think of the activity you described as TRIGGER events, more than rules. It sound a bit complicated, like you have to avoid a series of foreign=20 key violations or loops or FOREIGNS where the PRIMARY side is NOT=20 transacted yet. This situation still sound like a DATA problem with a value exceeding=20 the BOUNDS of what a field will hold. Have you tried DEBUGGING with a simplistic version where each action is=20 done as separate steps? (I suppose if the rule are in place you have = to=20 redo you database a bit to test this.) .... I guess you have,...that's=20 what your message says. Is it possible to use the client to send each step as a statement, all=20 wrapped in a transaction? Is it possible to write a function (stored procedure) to take care of=20 the combination of steps? Peter Bense wrote: > I want to thank everyone who has provided suggestions regarding my > MS-Access / ODBC / Link-tables issue the past couple of days. >=20 > Here's what I've found: >=20 > 1. As my gut instincts had told me, there is no problem with the > translations of booleans, at least given how I have been using them > (with foreign-key lookups). >=20 > 2. Inserts into the following view work cleanly: >=20 > afl=3D# \d vi_tblpis_survey_receipt > View "public.vi_tblpis_survey_receipt" > Column | Type | Modifiers > ---------------+----------+----------- > ppt_id | integer | > date_received | date | > staff_id | integer | > survey_type | smallint | > is_blank | boolean | > birth_month | smallint | > birth_year | smallint | > View definition: > SELECT tblpis_survey_receipt.ppt_id, > tblpis_survey_receipt.date_received, tblpis_survey_receipt.staff_id, > tblpis_survey_receipt.survey_type, tblpis_survey_receipt.is_blank, > tblpis_survey_receipt.birth_month, tblpis_survey_receipt.birth_year > FROM tblpis_survey_receipt > ORDER BY tblpis_survey_receipt.insertion; >=20 > 3. THINGS BREAK WHEN I APPLY CERTAIN TYPES OF RULES TO THE VIEW. >=20 > The way this view is supposed to work is as follows: > A) - A data entry person enters participant ID, survey type, date > received, etc. > B) - A RULE performs the following insertion: > INSERT INTO tblpis_survey_receipt (ppt_id, date_received, staff_id, > survey_type, is_blank, birth_month, birth_year, check_ppt, check_dob, > check_tracking, date_inserted, date_modified) > VALUES (new.ppt_id, new.date_received, new.staff_id, new.survey_type, > new.is_blank, new.birth_month, new.birth_year, 'f', 'f', 'f', now(), > now()); >=20 > C) - A series of checks are conducted to ensure that this data is > valid. Basically 4 or 5 updates are run to toggle these boolean fields > on the PostgreSQL side. If the participant ID is a valid participant > ID, that field is toggled. Once it passes that field, the month and > year of birth are verified. If that check is successful, then it checks > to see whether or not there is an associated tracking record already.=20 > If there isn't, it passes the tracking check. >=20 > All of those steps work fine on my test inserts, and the datavalues are > toggled accordingly. So far so good. >=20 > WHEN I TRY TO INSERT DATA INTO SOME OTHER TABLE FROM THAT RULE, THINGS > BREAK! >=20 > As soon as I add an INSERT statement to my rule following the UPDATEs, > e.g.=20 > INSERT INTO tblpis_tracking (ppt_id, pre_rc_date, pre_rc_id, > pre_is_blank) > SELECT ppt_id, date_received, staff_id, is_blank > FROM tblpis_survey_receipt > WHERE ppt_id=3Dnew.ppt_id > AND survey_type=3D1 > AND check_ppt=3D't' > AND check_dob=3D't' > AND check_tracking=3D't'; > ); >=20 > ... Things break upon insert. >=20 > Why? >=20 > Can I only perform one insert per AS ON INSERT TO? >=20 > If so, this might be the cause of my problem.