Kushal Jain
Kushal Jain

Reputation: 3186

Re-use sql query result in stored procedure of postgreSQL

I am new to stored procedure in postgres. I know how to write my procedure but it will not work as I want. Let me explain my scenario what kind of output and what I want to achieve.

I am using postgres 8.1 version.

result  = select u.name from users u where u.designation = 'S/w Engg';
select count(c.id) from cars c where c.name in (results)
totals = select count(result)

Here are the 3 steps which I want to write in stored procedure.

In first step I want to store the output of that query which return multiple rows with one column.

In second step, I want to execute another query in which I want to used 1st query result as 'IN' and store again in variable.

In last step, I want to count the no of rows getting from 1st query result.

So, can anyone help me out to write the stored procedure for above conditions.

Upvotes: 1

Views: 299

Answers (0)

Related Questions