Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to run one pl/pgSQL function

Status
Not open for further replies.

Bouchon

Programmer
Jun 20, 2002
2
BE
Hello,

I've written a little pl/pgSQL function in order to use it on a little postgreSQL database :

Code:
CREATE function tuple_add(VARCHAR(200)) RETURNS text AS
'
DECLARE
Response text;
PeopleName ALIAS FOR $1;
BEGIN
INSERT INTO PEOPLES VALUES(SEQUENCE_Id.NEXTVAL),PeopleName);
return Response;
END;
'   LANGUAGE 'plpgsql';
When I add this function to my database, I don't receive any error message.

But I don't success to use this function... :-(

I've unsucessfuly tried that :

mabd=> SELECT tuple_add('One try');
ERROR: parser: parse error at or near "("
mabd=> SELECT tuple_add("One try");
ERROR: Attribute 'One try' not found

The PEOPLE database just contains two columns : an INTEGER and one VARCHAR(200). And the SEQUENCE_Id sequence I use is existing. I've also checked that pl/pgSQL has been activated to my database.

The Response variable is to be used to get the eventual exception, but I have to find how I can do that.

Can you explain me how can I use my pl/pgSQL function ?

Thanks in advance ! :)

Bouchon.
 
Hi:

This is a typo?:

INSERT INTO PEOPLES VALUES(SEQUENCE_Id.NEXTVAL),PeopleName);

because my internal processor says at first sight that there are more ) than ( in the query, what do you think?

Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.

Let me know if this post have actually helped you, by clicking the purple star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top