function and passing the table name to be used with SQL stmnt - Mailing list pgsql-general

From kamiseq
Subject function and passing the table name to be used with SQL stmnt
Date
Msg-id 1193685486.126960.251720@57g2000hsv.googlegroups.com
Whole thread Raw
Responses Re: function and passing the table name to be used with SQL stmnt  (kamiseq <kamiseq@gmail.com>)
List 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;


pgsql-general by date:

Previous
From: "Peckham, Martin"
Date:
Subject: nonstandard use of
Next
From: rski
Date:
Subject: plperl ubuntu problem