Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3

From: Patrick B <patrickbakerbr(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
Date: 2016-06-07 04:01:43
Message-ID: CAJNY3iuo6hE52VkqmS0TJxLYttcU6BtaJPM5LM=cz6O6XMPNoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ok so guys....

CREATE or REPLACE FUNCTION function_data_1()

RETURNS SETOF bigint AS $$

declare

row record;

BEGIN

[...]

FOR row IN EXECUTE '

SELECT

t1.file_id,

t1.path,

t1.account_id

FROM

table1 t1

JOIN

table3 t3 ON t3.file_Id = t1.file_id

WHERE

t3.migrated = 0

AND

*t3.account_id = 1112*

ORDER BY 1 LIMIT 30 '

[...]

How can I make the function works with account_id?

*Example: select function_data_1(1112)*

and then it will do all the work just for that specific account_id?

If you guys please could give me the way to do that..
thanks
Patrick

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nikhil 2016-06-07 10:24:01 2 node bdr setup gives error in replication slots
Previous Message Sridhar N Bamandlapally 2016-06-07 03:37:45 Re: [HACKERS] OUT parameter and RETURN table/setof