how to use function from different database

Поиск
Список
Период
Сортировка
От Bhupendra Babu
Тема how to use function from different database
Дата
Msg-id CAOEE2Fc9G2A92SzdghvJE06YOS=XL-mU8184ftDGn30a73Y31Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: how to use function from different database  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: how to use function from different database  (Rob Sargent <robjsargent@gmail.com>)
Список pgsql-sql
Hi,

I created a generic function (DATEFIFF) login to postgres database using psql. ANd I wanted to use across the entire instance , from all other databases.

postgres=> CREATE FUNCTION DateDiff (units VARCHAR(30), start_t TIMESTAMP, end_t TIMESTAMP)
postgres->      RETURNS INT AS $$
postgres$>    DECLARE
postgres$>      diff_interval INTERVAL;
...
...

grant execute on function DATEDIFF to public;
grant execute on function DATEDIFF(varchar,timestamp,timestamp) to public;

I tried both the grant one at a time, none of them works.
------------------------------------------
Connected to another database
\c application1

application1=> SELECT * from DATEDIFF('second', '2011-12-30 08:54:55'::timestamp, '2011-12-30 08:56:10'::timestamp);
ERROR:  function datediff(unknown, timestamp without time zone, timestamp without time zone) does not exist
LINE 1: SELECT * from DATEDIFF('second', '2011-12-30 08:54:55'::time...
                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
application1=>
------------------------------------------

How can I use this function across my entire postgresql instance from any databases ?

--
Thanks.
Bhupendra B Babu

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

Предыдущее
От: Steve Midgley
Дата:
Сообщение: Re: UNNEST and multidimensional arrays
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: how to use function from different database