pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Victor Yegorov <viy@pirmabanka.lv>
To: Mario Alberto Soto Cordones <mario_soto@compuall.cl>
Cc: pgsql-admin@postgresql.org
Subject: Re: PROBLEM WITH FUNCTIONS IN POSTGRES
Date: Thu, 20 Mar 2003 19:22:42 +0200
Message-ID: <20030320172242.GA20481@pirmabanka.lv> (raw)
In-Reply-To: <1454.192.168.1.100.1048180049.squirrel@mail.compuall.cl>
References: <1454.192.168.1.100.1048180049.squirrel@mail.compuall.cl>

* 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

view thread (3+ messages)  latest in thread

Message-ID: <20030320172242.GA20481@pirmabanka.lv>
Permalink:  ../20030320172242.GA20481@pirmabanka.lv/
Also on:    postgresql.org/message-id/20030320172242.GA20481@pirmabanka.lv

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: viy@pirmabanka.lv, mario_soto@compuall.cl
  Subject: Re: PROBLEM WITH FUNCTIONS IN POSTGRES
  In-Reply-To: <20030320172242.GA20481@pirmabanka.lv>
  References: <1454.192.168.1.100.1048180049.squirrel@mail.compuall.cl> <20030320172242.GA20481@pirmabanka.lv>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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