Re: pltcl problem

From: Russ Brown <postgres(at)dot4dot(dot)plus(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pltcl problem
Date: 2003-09-24 16:03:16
Message-ID: oprv0hjqr16sifx0@relay.plus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Can we see the whole function definition? I think you are somehow
> managing to include this string in a quoted argument of some other elog
> command, but without context it's hard to say more.
>
> regards, tom lane

I thought that too but I can't see anything obvious (but then I am a tcl
novice :-). The function definition is as follows:

CREATE OR REPLACE FUNCTION HierarchyAddTrigger() RETURNS trigger AS '
# Debug to make sure Im getting back what I think I am from the
subselect
spi_exec "SELECT relname FROM pg_class WHERE oid = ''$TG_relid''::oid"

elog DEBUG "$relname"

# Get data on this hierarchy structure
spi_exec "SELECT vchtablename, vchtableid, vchtablepid, vchlookupname,
vchlookupid, vchlookuppid, vchlevel FROM fnGetHierarchyData((SELECT
relname FROM pg_class WHERE oid = ''$TG_relid''::oid))"

elog DEBUG "Trigger Call $vchtablename"

# First check that the level is correct
if [ info exists NEW($vchtablepid) ] {
elog DEBUG "MAIN ADD"
elog DEBUG "SELECT $vchlevel + 1 AS new_level FROM $vchtablename
WHERE intGroupID=$NEW($vchtablepid)"
spi_exec "SELECT $vchlevel + 1 AS new_level FROM $vchtablename
WHERE intGroupID=$NEW($vchtablepid)"

# Set the correct level in the new row. We dont ever need to know
# what value the original insert set the level to.
set NEW($vchlevel) $new_level

# Now add the parents of this new row
spi_exec "SELECT HierarchyAdd(\'$vchtablename\',
$NEW($vchtablepid), $NEW($vchtableid))"
} else {
elog DEBUG "INITIAL ADD"
set NEW($vchlevel) 1

spi_exec "INSERT INTO $vchlookupname ($vchlookupid, $vchlookuppid)
VALUES ($NEW($vchtableid), $NEW($vchtableid))"
}
elog DEBUG "End Trigger"
return [array get NEW];

' LANGUAGE 'pltcl';

Trigger definition is:

CREATE TRIGGER trgGroupAddTrigger BEFORE INSERT ON tblGroup
FOR EACH ROW EXECUTE PROCEDURE HierarchyAddTrigger();

Thanks for you help!

--

Russell Brown

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel E. Fisher 2003-09-24 16:09:48 7.3.3 again - fixed
Previous Message Dennis Gearon 2003-09-24 15:34:54 Re: Is this "order by" logic right