Skip site navigation (1) Skip section navigation (2)

Help for plpgsql!!

From: "joel xue" <joel_xue(at)hotmail(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Help for plpgsql!!
Date: 2000-10-18 21:53:23
Message-ID: F212RelSbxpqyDp6fwq00008e81@hotmail.com (view raw or flat)
Thread:
Lists: 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.


Responses

pgsql-interfaces by date

Next:From: Matthew H. NorthDate: 2000-10-19 16:06:38
Subject: PsqlODBC on W2K conn. to PostgreSQL 7.0.2 on FreeBSD
Previous:From: Scott HolmesDate: 2000-10-18 16:54:25
Subject: Transactions and Errors with ODBC

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group