Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Function that creates views

Posted on 2005-06-13 11:03:38 by Gerwin Philippo

I would like to make a plpgsql function that creates views depending on
a parameter:

CREATE OR REPLACE FUNCTION "public"."function1" (integer) RETURNS
boolean AS'
begin
create or replace view vw_test as
select * from organisations where org_id = $1;
return true;
end;

What I want is that I call the functions with "1", it creates a view
that says:
select * from organisations where org_id = 1;
Instead, it now creates a view:
select * from organisations where org_id = $1;
How can I make the function use "1" instead of "$1"?

Report this message

#2: Re: Function that creates views

Posted on 2005-06-15 23:44:37 by Ion Chalmers Freeman

What happens in you alias $1 to a local variable?

Gerwin Philippo wrote:
> I would like to make a plpgsql function that creates views depending on
> a parameter:
>
> CREATE OR REPLACE FUNCTION "public"."function1" (integer) RETURNS
> boolean AS'
> begin
> create or replace view vw_test as
> select * from organisations where org_id = $1;
> return true;
> end;
>
> What I want is that I call the functions with "1", it creates a view
> that says:
> select * from organisations where org_id = 1;
> Instead, it now creates a view:
> select * from organisations where org_id = $1;
> How can I make the function use "1" instead of "$1"?

Report this message