Search Postgresql Archives

Re: pgpsql help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx so that your
>      message can get through to the mailing list cleanly

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux