pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedassign count() result to a declared variable in plpgsql
3+ messages / 3 participants
[nested] [flat]
* assign count() result to a declared variable in plpgsql
@ 2002-06-24 15:25 Joseph Syjuco <joseph@asti.dost.gov.ph>
2002-06-24 16:12 ` Re: assign count() result to a declared variable in plpgsql Tom Lane <tgl@sss.pgh.pa.us>
2002-06-24 18:06 ` Re: assign count() result to a declared variable in plpgsql Jeff Eckermann <jeff_eckermann@yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Syjuco @ 2002-06-24 15:25 UTC (permalink / raw)
To: pgsql-sql
i want to put my count() result in a plpgsql declared integer variable
declare f_count_var integer;
begin
select into f_count_var count(empno) from employee
end;
tried this one but it doesnt work
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: assign count() result to a declared variable in plpgsql
2002-06-24 15:25 assign count() result to a declared variable in plpgsql Joseph Syjuco <joseph@asti.dost.gov.ph>
@ 2002-06-24 16:12 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2002-06-24 16:12 UTC (permalink / raw)
To: Joseph Syjuco <joseph@asti.dost.gov.ph>; +Cc: pgsql-sql
Joseph Syjuco <joseph@asti.dost.gov.ph> writes:
> i want to put my count() result in a plpgsql declared integer variable
> declare f_count_var integer;
> begin
> select into f_count_var count(empno) from employee
> end;
> tried this one but it doesnt work
Works for me:
regression=# create function foo() returns int as '
regression'# declare f_count_var integer;
regression'# begin
regression'# select into f_count_var count(unique1) from tenk1;
regression'# return f_count_var;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo();
foo
-------
10000
(1 row)
What PG version are you using?
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: assign count() result to a declared variable in plpgsql
2002-06-24 15:25 assign count() result to a declared variable in plpgsql Joseph Syjuco <joseph@asti.dost.gov.ph>
@ 2002-06-24 18:06 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Eckermann @ 2002-06-24 18:06 UTC (permalink / raw)
To: Joseph Syjuco <joseph@asti.dost.gov.ph>; pgsql-sql
try:
f_count_var := count(empno) from employee;
--- Joseph Syjuco <joseph@asti.dost.gov.ph> wrote:
>
> i want to put my count() result in a plpgsql
> declared integer variable
>
>
> declare f_count_var integer;
> begin
> select into f_count_var count(empno) from employee
> end;
>
> tried this one but it doesnt work
>
>
>
>
>
>
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to majordomo@postgresql.org
> so that your
> message can get through to the mailing list cleanly
>
>
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-06-24 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-24 15:25 assign count() result to a declared variable in plpgsql Joseph Syjuco <joseph@asti.dost.gov.ph>
2002-06-24 16:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-06-24 18:06 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox