function and passing the table name to be used with SQL stmnt

From: kamiseq <kamiseq(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: function and passing the table name to be used with SQL stmnt
Date: 2007-10-29 19:18:06
Message-ID: 1193685486.126960.251720@57g2000hsv.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ok so my probelm is I have a simple function like this
CREATE OR REPLACE FUNCTION bookid(_tabela varchar) RETURNS integer AS $
$
DECLARE
_id integer := 0;
BEGIN
SELECT INTO _id id FROM _tabela order by id desc limit 1;

RETURN _id+1;
END;
$$ LANGUAGE plpgsql;

and the problem is i can run this function cos im passing string to
SQL statement and not the table object. hym what can I do about it to
have function that will give me next id number back;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message U P C Bharat 2007-10-29 19:23:08 reg. rewrite rules
Previous Message Thomas Kellerer 2007-10-29 18:34:47 Re: pg_restore