Re: How to find owning schema in function - Mailing list pgsql-general

From Sim Zacks
Subject Re: How to find owning schema in function
Date
Msg-id 4EB650F8.4060502@compulab.co.il
Whole thread Raw
In response to How to find owning schema in function  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
On 11/05/2011 05:36 PM, Andrus wrote: <blockquote cite="mid:590C7236EDF84F6CB786F6C7678A7167@dell2" type="cite">8.1+
databasecontains separate schemas for every company named company1, company2, .... companyi. <br /><br /> order tables
inthose schemas contain trigger like for company1: <br /><br /> CREATE OR REPLACE FUNCTION dok_seq_trig() RETURNS
"trigger"<br /> AS $$BEGIN <br /> IF NEW.tasudok IS NULL AND NEW.doktyyp!='O'  THEN <br /> NEW.tasudok = nextval(
'company1.'||TG_RELNAME || '_'|| NEW.doktyyp ||'_seq'); <br /> END IF; <br /><br /> IF NEW.arvenumber IS NULL AND
NEW.doktyyp='O' THEN <br /> NEW.arvenumber = nextval( 'company1.'|| TG_RELNAME || '_'|| NEW.doktyyp ||'_seq'); <br />
ENDIF; <br /><br /> RETURN NEW; <br /> END$$  LANGUAGE plpgsql STRICT; <br /><br /> This code has hard coded schema
name'company1'  . If new company schema n is created from existing one, trigger functions needs manual update to change
schemato companyn. <br /><br /> How to change this code so that instead of hard-coded schema name it automatically uses
theschema where trigger function is defined ? <br /></blockquote><a
href="http://www.postgresql.org/docs/8.2/interactive/plpgsql-trigger.html">http://www.postgresql.org/docs/8.2/interactive/plpgsql-trigger.html</a><br
/>Shows all available variables. In this case - <span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family:
   monospace; font-size: 13px; font-style: normal; font-variant:     normal; font-weight: normal; letter-spacing:
normal;line-height:     normal; orphans: 2; text-align: left; text-indent: 0px;     text-transform: none; white-space:
normal;widows: 2;     word-spacing: 0px; background-color: rgb(255, 255, 255);">TG_TABLE_SCHEMA</span><br /><br />
Sim<br/> 

pgsql-general by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Some services of pgfoundry down?
Next
From: Scott Marlowe
Date:
Subject: Re: How to force some char type columns to be stored in uppercase