pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedPROBLEM WITH FUNCTIONS IN POSTGRES
3+ messages / 2 participants
[nested] [flat]
* PROBLEM WITH FUNCTIONS IN POSTGRES
@ 2003-03-20 17:07 Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-20 17:22 ` Re: PROBLEM WITH FUNCTIONS IN POSTGRES Victor Yegorov <viy@pirmabanka.lv>
0 siblings, 1 reply; 3+ messages in thread
From: Mario Alberto Soto Cordones @ 2003-03-20 17:07 UTC (permalink / raw)
To: pgsql-admin
Hi...
i create a function in postgres to return a data of a table but when try
to create say
PostgreSQL ha dicho: ERROR: parser: parse error at or near "text"
Your query:
CREATE FUNCTION sinomemp(text)
RETURNS text
AS 'DECLARE sinomemp TEXT;
BEGIN
SELECT name
FROM simaemp
WHERE cod = $1;
RETURN sinomemp;
END;'
LANGUAGE 'sql'
please help me
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PROBLEM WITH FUNCTIONS IN POSTGRES
2003-03-20 17:07 PROBLEM WITH FUNCTIONS IN POSTGRES Mario Alberto Soto Cordones <mario_soto@compuall.cl>
@ 2003-03-20 17:22 ` Victor Yegorov <viy@pirmabanka.lv>
2003-03-21 07:19 ` Re: PROBLEM WITH FUNCTIONS IN POSTGRES Victor Yegorov <viy@pirmabanka.lv>
0 siblings, 1 reply; 3+ messages in thread
From: Victor Yegorov @ 2003-03-20 17:22 UTC (permalink / raw)
To: Mario Alberto Soto Cordones <mario_soto@compuall.cl>; +Cc: pgsql-admin
* Mario Alberto Soto Cordones <mario_soto@compuall.cl> [20.03.2003 19:09]:
> Hi...
>
> i create a function in postgres to return a data of a table but when try
> to create say
>
> PostgreSQL ha dicho: ERROR: parser: parse error at or near "text"
> Your query:
>
> CREATE FUNCTION sinomemp(text)
> RETURNS text
> AS 'DECLARE sinomemp TEXT;
> BEGIN
> SELECT name
> FROM simaemp
> WHERE cod = $1;
> RETURN sinomemp;
> END;'
> LANGUAGE 'sql'
Actually, this question is for SQL list, not ADMIN.
You have `return' statement in your code, it is part of plpgsql language,
not sql.
So, changing last line to:
LANGUAGE plpgsql;
will solve your problem.
One note: it seems, that sinomemp variable is not in use.
May be this is what you need:
CREATE or replace FUNCTION sinomemp(text) RETURNS text AS '
SELECT name
FROM simaemp
WHERE cod = $1;'
LANGUAGE sql;
--
Victor Yegorov
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PROBLEM WITH FUNCTIONS IN POSTGRES
2003-03-20 17:07 PROBLEM WITH FUNCTIONS IN POSTGRES Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-20 17:22 ` Re: PROBLEM WITH FUNCTIONS IN POSTGRES Victor Yegorov <viy@pirmabanka.lv>
@ 2003-03-21 07:19 ` Victor Yegorov <viy@pirmabanka.lv>
0 siblings, 0 replies; 3+ messages in thread
From: Victor Yegorov @ 2003-03-21 07:19 UTC (permalink / raw)
To: Mario Alberto Soto Cordones <mario_soto@compuall.cl>; +Cc: pgsql-admin
* Mario Alberto Soto Cordones <mario_soto@compuall.cl> [20.03.2003 20:15]:
> Victor the sintaxis it`s my error sorry.
> now how i to suscribe the list SQL
> and finaly question
> the function what you return me work very good, but return only one field,
> but i want to return two or many field
> how i do
>
> gracias
Well, you can subscribe to any list you wish here:
<http://www.postgresql.org/lists.html;
Select list you wish to subscribe and follow the instructions.
You'd better read yourself about server-side programming in postgres, you
can find everything you need in PostgreSQL Programmers Guide
<http://www.postgresql.org/docs/;. There you'll see Extending SQL: Functions
paragraph (it's numbered as 9th in docs for postgres 7.3.1). You'll find
everything about functions there.
--
Victor Yegorov
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-03-21 07:19 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-20 17:07 PROBLEM WITH FUNCTIONS IN POSTGRES Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-20 17:22 ` Victor Yegorov <viy@pirmabanka.lv>
2003-03-21 07:19 ` Victor Yegorov <viy@pirmabanka.lv>
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