Re: pgpsql help - Mailing list pgsql-general

From Mike G.
Subject Re: pgpsql help
Date
Msg-id 20050117050816.GA21453@thegodshalls.thegodshalls
Whole thread Raw
In response to pgpsql help  (LENGYEL Zoltan <warnew@warnew.nomaam.hu>)
Responses Re: pgpsql help
Call for Beta Testers (PG Lightning Admin)
List pgsql-general
Maybe it is because 'name' is a sql 92/99 non-reserved / key word?

On Mon, Jan 17, 2005 at 05:46:20AM +0100, LENGYEL Zoltan wrote:
> Hi,
>
> I have a pgpsql function:
>
> create or replace function new_uri(varchar,varchar,varchar) returns
> integer as '
> declare
>   src alias for $1;
>   tit alias for $2;
>   uri alias for $3;
>   article_id integer := nextval(''articleid'');
>   src_id integer;
>   state_id integer;
>   urit_id integer;
> begin
>
> select into src_id   id from sources where name = src;
> select into state_id id from state   where name = ''collected'';
> select into urit_id  id from uritype where name = ''original html'';
> raise notice ''insert into article (id,source,title,state) values
> (%,%,%,%)'',article_id,src_id,tit,state_id;
> insert into article (id,source,title,state) values
> (article_id,src_id,tit,state_id);
> raise notice ''insert into uri (articleid,uri,uritype) values
> (%,%,%)'',article_id,uri,urit_id;
> insert into uri (articleid,uri,uritype) values (article_id,uri,urit_id);
>
> return 1;
> end;
> ' language 'plpgsql';
>
> An i also have some output:
>
> ifa=> \i new_uri.sql
> CREATE FUNCTION
> ifa=> select new_uri('index.hu','juscsenko','index.hu/foobar');
> NOTICE:  insert into article (id,source,title,state) values
> (56,3,juscsenko,1)
> NOTICE:  insert into uri (articleid,uri,uritype) values
> (56,index.hu/foobar,3)
> ERROR:  syntax error at or near "$1" at character 14
> CONTEXT:  PL/pgSQL function "new_uri" line 17 at SQL statement
> ifa=>
>
> What should i do?
>
>
> thx,
>
> War_New
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly

pgsql-general by date:

Previous
From: LENGYEL Zoltan
Date:
Subject: pgpsql help
Next
From: Michael Fuhr
Date:
Subject: Re: pgpsql help