User Define Functions

Поиск
Список
Период
Сортировка
От Lathika Wijerathne
Тема User Define Functions
Дата
Msg-id 20050726224915.55373F6D@dm16.mta.everyone.net
обсуждение исходный текст
Ответы Re: User Define Functions  (Gnanavel S <s.gnanavel@gmail.com>)
Список pgsql-admin

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

 

 

В списке pgsql-admin по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Checkpoint segments
Следующее
От: Gnanavel S
Дата:
Сообщение: Re: User Define Functions