| From: | "Mike G(dot)" <mike(at)thegodshalls(dot)com> | 
|---|---|
| To: | LENGYEL Zoltan <warnew(at)warnew(dot)nomaam(dot)hu> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: pgpsql help | 
| Date: | 2005-01-17 05:08:16 | 
| Message-ID: | 20050117050816.GA21453@thegodshalls.thegodshalls | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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(at)postgresql(dot)org so that your
>      message can get through to the mailing list cleanly
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2005-01-17 05:31:43 | Re: pgpsql help | 
| Previous Message | Michael Fuhr | 2005-01-17 05:02:16 | Re: pgpsql help |