RE: to pass a parameter

Поиск
Список
Период
Сортировка
Искать

RE: to pass a parameter

От:
Michael Ansley <Michael.Ansley@intecsystems.co.uk>
Дата:

I'm under the impression that this substitution is performed by SQLPlus (somebody please correct me otherwise).  Hence, it's not the database server that needs to do this, but the client (i.e. shell, or psql).  This should be achievable using shell script, and psql.

MikeA

>>   -----Original Message-----
>>   From: jprem [mailto:jprem@srmsoft.co.in]
>>   Sent: 09 June 2000 07:39
>>   To: pgsql-general@postgresql.org
>>   Subject: [GENERAL] to pass a parameter
>>  
>>  
>>   hello,
>>           how can i pass a table name dynamically to a query ?
>>  
>>   in oracle we  do
>>      select * from &x
>>  
>>   how is it here ?
>>   please help.
>>  
>>  
>>  

to pass a parameter

От:
jprem <jprem@srmsoft.co.in>
Дата:
hello,
        how can i pass a table name dynamically to a query ?

in oracle we  do
   select * from &x

how is it here ?
please help.



Re: to pass a parameter

От:
NRonayette <r97m10@socotec.fr>
Дата:
Michael Ansley wrote:
> 
> I'm under the impression that this substitution is performed by
> SQLPlus (somebody please correct me otherwise).

it's true ! It's only available for SQLPlus.

I'm a beginner with postgres, but i saw in the User's documentation that
we can create a SQL function to pass parameter

(i copy/paste) 
Parameters

A parameter is used to indicate a parameter in a SQL function. Typically
this is used in SQL function definition statement. The
form of a parameter is: 

$number
     
For example, consider the definition of a function, dept, as 

CREATE FUNCTION dept (name)
        RETURNS dept
        AS 'select * from 
            dept where name=$1'
        LANGUAGE 'sql';

(i guess there's something more simple)
Nicolas


  Hence, it's not the
> database server that needs to do this, but the client (i.e. shell, or
> psql).  This should be achievable using shell script, and psql.
> 
> MikeA
> 
> >>   -----Original Message-----
> >>   From: jprem [mailto:jprem@srmsoft.co.in]
> >>   Sent: 09 June 2000 07:39
> >>   To: pgsql-general@postgresql.org
> >>   Subject: [GENERAL] to pass a parameter
> >>
> >>
> >>   hello,
> >>           how can i pass a table name dynamically to a query ?
> >>
> >>   in oracle we  do
> >>      select * from &x
> >>
> >>   how is it here ?
> >>   please help.
> >>
> >>
> >>

Re: to pass a parameter

От:
NRonayette <r97m10@socotec.fr>
Дата:
Sorry, but i made a mistake here !
the function dept or is equivalente coud not solve this problem (pass a
table name as a parameter)

In Oracle exist Dynamic SQL, is there something like that in postgres ? 
Is it possible to execute a query built in a plpgsql function or do we
need to use Perl and the Pg module for exemple ?

Nicolas.


NRonayette wrote:

> (i copy/paste)
> Parameters
> 
> A parameter is used to indicate a parameter in a SQL function. Typically
> this is used in SQL function definition statement. The
> form of a parameter is:
> 
> $number
> 
> For example, consider the definition of a function, dept, as
> 
> CREATE FUNCTION dept (name)
>         RETURNS dept
>         AS 'select * from
>             dept where name=$1'
>         LANGUAGE 'sql';
> 
> (i guess there's something more simple)
> Nicolas
> 

> >
> > >>   -----Original Message-----
> > >>   From: jprem [mailto:jprem@srmsoft.co.in]
> > >>   Sent: 09 June 2000 07:39
> > >>   To: pgsql-general@postgresql.org
> > >>   Subject: [GENERAL] to pass a parameter
> > >>
> > >>
> > >>   hello,
> > >>           how can i pass a table name dynamically to a query ?
> > >>
> > >>   in oracle we  do
> > >>      select * from &x
> > >>
> > >>   how is it here ?
> > >>   please help.
> > >>
> > >>
> > >>
FAQ