logo       

Triggers and Functions: msg#01309

Subject: Triggers and Functions
Howdy,

I'm new to triggers and functions, and am having trouble doing something quite simple.
My previous experience includes writing a single trigger in Oracle.  This was somewhat easy since everything that had to do with the trigger
happened in the trigger creation process.  In PGSQL it seems a little different.

Scenerio:

1) Insert a row into one table
2) Fire Trigger AFTER this insert to obtain the Primary Key value (in this case a serial8) of the row entered.
        (according to the rules, this row should not be visible)
3) run a SELECT query against a different table to obtain another Primary Key value (serial8) WHERE point '(X,Y)' @ bounary
4) INSERT INTO yet a third table the two primary key values obtained from above.

Table 1:ltg
----------
ID--serial8
X--bigint
Y--bigint

Table 2:rtg
-----------
ID--serial8
BOUNDARY--closed path
 
Table 3:ltg_in_rtg
-------
LTGID--BIGINT
RTGID--BIGINT

Here is the function as I have it:

DECLARE

myltgid ltg_in_rtg.ltgid%TYPE; -- these are BIGINT types (8 bytes)
myrtgid ltg_in_rtg.rtgid%TYPE;
x ltg.long%TYPE;
y ltg.lat%TYPE;

BEGIN
 
x := NEW.X;
y := NEW.Y;
myltgid := SELECT max(id) FROM ltg;
myrtgid := SELECT id FROM rtg WHERE point '(x,y)' @ boundary;
INSERT INTO ltg_in_rtg (ltgid, rtgid) VALUES (myltgid, myrtgid);

END;
 
I am using PGAccess to create a FUNCTION, but it is giving me such hassles.  The errors are ambiguous and no linenumbers (even in such a short function) aren't there.
 
I've tried "internal" and "sql" type functions both to no avail.  What am I doing wrong?
 
Thanks in advance
RDB
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe