pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedHelp for plpgsql!!
2+ messages / 2 participants
[nested] [flat]
* Help for plpgsql!!
@ 2000-10-18 21:53 joel xue <joel_xue@hotmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: joel xue @ 2000-10-18 21:53 UTC (permalink / raw)
To: pgsql-interfaces
Dear Sir/Madam,
My table is :
Attribute | Type | Modifier
-----------+-----------+----------
empname | text |
salary | integer |
last_date | timestamp |
last_name | name |
My function and trigger is:
create function isFull()
returns opaque as '
begin
select count(*) into tmp1 from emp;
if tmp1.count >= 5 then
select min(last_date) into tmp2 from emp;
delete from emp where last_date=tmp2.min;
drop table tmp2;
end if;
drop table tmp1;
end; '
language 'plpgsql';
create trigger isfull before insert on emp for each row execute procedure
isFull
();
But my error messages is :
ERROR: parser: parse error at or near "tmp1"
I can finish these steps in psql environment,why it could not work well in
plpgsql?Can you help me?
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Help for plpgsql!!
@ 2000-10-20 18:27 hubert depesz lubaczewski <depesz@depesz.pl>
parent: joel xue <joel_xue@hotmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: hubert depesz lubaczewski @ 2000-10-20 18:27 UTC (permalink / raw)
To: pgsql-interfaces
On Wed, Oct 18, 2000 at 09:53:23PM +0000, joel xue wrote:
> create function isFull()
> returns opaque as '
> begin
> select count(*) into tmp1 from emp;
^^^^
you didn't declare tmp1. before begin write
declare
tmp1 int4;
depesz
--
hubert depesz lubaczewski
------------------------------------------------------------------------
najwspanialszą rzeczą jaką dało nam nowoczesne społeczeństwo,
jest niesamowita wręcz łatwość unikania kontaktów z nim ...
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-10-20 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-18 21:53 Help for plpgsql!! joel xue <joel_xue@hotmail.com>
2000-10-20 18:27 ` hubert depesz lubaczewski <depesz@depesz.pl>
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