how to pass tablename to a function
От
A L.
Тема
how to pass tablename to a function
Дата
Msg-id
SNT148-W762FB7B83F3C7B735DD48697C50@phx.gbl
Список
Дерево обсуждения
how to pass tablename to a function A L. <e_toner@hotmail.com>
Re: how to pass tablename to a function David G Johnston <david.g.johnston@gmail.com>
Re: how to pass tablename to a function Adrian Klaver <adrian.klaver@aklaver.com>
Hi, All
I like to pass the tablename to function but not using execute clause, here is my script
CREATE OR REPLACE FUNCTION functions.pgsql_event_unpack_batch(IN _tbl text, IN jobid bigint, IN jobtime timestamp with time zone, IN startid bigint, IN stopid bigint)
RETURNS TABLE(events bigint, errors bigint[]) AS
$BODY$
BEGIN
RETURN QUERY
WITH
unpacking (raw_id, time, userid, eventtype, pagename, userhost, application, status, error)
AS (
select
id as raw_id,
(up).time,
(up).userid,
coalesce((up).eventtype, ''),
coalesce((up).pagename, ''),
(up).userhostaddress as userhost,
coalesce((up).application, ''),
(up).status,
(up).error
from(
select id,
functions.python_events_unpack(event_object) up
from _tbl
where id between startid and stopid
) a
where (up).userid is not NULL
)
I want to pass the _tbl to the select query integrated in the unpacking(), how can I make it?
thanks
Alec
I like to pass the tablename to function but not using execute clause, here is my script
CREATE OR REPLACE FUNCTION functions.pgsql_event_unpack_batch(IN _tbl text, IN jobid bigint, IN jobtime timestamp with time zone, IN startid bigint, IN stopid bigint)
RETURNS TABLE(events bigint, errors bigint[]) AS
$BODY$
BEGIN
RETURN QUERY
WITH
unpacking (raw_id, time, userid, eventtype, pagename, userhost, application, status, error)
AS (
select
id as raw_id,
(up).time,
(up).userid,
coalesce((up).eventtype, ''),
coalesce((up).pagename, ''),
(up).userhostaddress as userhost,
coalesce((up).application, ''),
(up).status,
(up).error
from(
select id,
functions.python_events_unpack(event_object) up
from _tbl
where id between startid and stopid
) a
where (up).userid is not NULL
)
I want to pass the _tbl to the select query integrated in the unpacking(), how can I make it?
thanks
Alec
В списке pgsql-general по дате отправления
От: Adrian Klaver
Дата: