Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WwWXxX, udp high ports, d-link extract firmware dsl-2750u, wwwwxxxxx.2G, yxxxcom, WWWXXX, ftp://192.168.100.100, wwwxxx 100, www.xxxcon, wwwxxx

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