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


---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

Reply via email to