X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9FED052BE6 for ; Wed, 27 Jul 2005 02:49:26 -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 41042-09 for ; Wed, 27 Jul 2005 05:49:17 +0000 (GMT) Received: from omta18.mta.everyone.net (sitemail2.everyone.net [216.200.145.36]) by svr1.postgresql.org (Postfix) with ESMTP id F2E3652A37 for ; Wed, 27 Jul 2005 02:49:16 -0300 (ADT) Received: from dm16.mta.everyone.net (bigiplb-dsnat [172.16.0.19]) by omta18.mta.everyone.net (Postfix) with ESMTP id 1813840044 for ; Tue, 26 Jul 2005 22:49:17 -0700 (PDT) X-Eon-Dm: dm16 Received: from ets16 (203.115.13.5 [203.115.13.5]) by dm16.mta.everyone.net (EON-AUTHRELAY2) with ESMTP id dm16.42e6b612.d68a for ; Tue, 26 Jul 2005 22:49:15 -0700 (PDT) X-Eon-Sig: AQJKldpC5yBbLP0V2QIAAAAB,7541770f4cc1b7cb1675acd815dc42d7 From: "Lathika Wijerathne" To: Subject: User Define Functions Date: Wed, 27 Jul 2005 11:51:28 +0600 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0098_01C592A1.89EB3410" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 thread-index: AcWSbzrr8r62sX68T+eLehfu/oR8+Q== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-Id: <20050726224915.55373F6D@dm16.mta.everyone.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200507/212 X-Sequence-Number: 18268 This is a multi-part message in MIME format. ------=_NextPart_000_0098_01C592A1.89EB3410 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I have created the database with 3 schemas. Example : Schema names : Newyorlk, Atlanta,California Each schema has a similar tables. But there can be schema specific tables too. I want to create a user define functions to retrieve information. ---------------------------------------------------------------------- CREATE OR REPLACE FUNCTION Newyorlk.get_customer_name (custid integer, invoice integer) RETURNS varchar AS $$ DECLARE m_display varchar (100); m_status varchar(10); BEGIN SELECT cname INTO m_display from Newyorlk.CUSTOMER WHERE id = custid; SELECT status INTO m_status from Newyorlk.CUSTOMER_INVOICE WHERE id = invoice; m_display := m_display||'-'|| m_status ; RETURN m_display; END; $$ LANGUAGE 'plpgsql' VOLATILE; -------------------------------------------------------------------- In the above function if I change Newyorlk.CUSTOMER to CUSTOMER . It gives a runtime error saying table not available. I think when I remove the schema name, posgresSql checks the table in the public schema. But in Oracle, when we give the schema name with the function name, it assumes all the objects within the functions are referring to that schema. Do you know any other way to do a user define function, without hard cording schema name each time when referring to a table. Thanks in Advance Lathika ------=_NextPart_000_0098_01C592A1.89EB3410 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

I have created the database with 3 schemas. =

Example : Schema names : Newyorlk, Atlanta,California

 

Each  schema has a similar  tables. But = there can be schema specific tables too.

 

I want to create a user define functions to retrieve = information.

 

------------------------------------------------------= ----------------

CREATE OR REPLACE FUNCTION Newyorlk.get_customer_name = (custid integer, invoice integer)

  RETURNS varchar = AS

$$

 

DECLARE

 m_display      varchar = (100);

 m_status      &nbs= p; varchar(10);

  BEGIN

 

   SELECT cname   INTO m_display = from Newyorlk.CUSTOMER

  WHERE   id =3D = custid;

 

  SELECT  status   INTO = m_status   from Newyorlk.CUSTOMER_INVOICE<= /font>

  WHERE   id =3D = invoice;

 

 m_display :=3D m_display||’-‘|| = m_status  ;

 

   RETURN = m_display;

  END;

$$

  LANGUAGE 'plpgsql' = VOLATILE;

------------------------------------------------------= --------------

 

In the above function if I change Newyorlk.CUSTOMER  to CUSTOMER . It = gives a runtime error saying table not available.

I think when I remove the schema name, posgresSql = checks the table in the public schema.

 

But in Oracle, when we give the schema name with the = function name, it assumes all the objects within the functions are referring to = that schema.

Do you know any other way to do a user define = function, without hard cording schema name each time when referring to a = table.

 

Thanks in Advance

Lathika

 

 

------=_NextPart_000_0098_01C592A1.89EB3410--