Re: query with input variable
From: (wrong string) érôme PERRET <jperret_at_freesurf.fr>
Date: Mon, 8 Jan 2001 16:24:33 +0100
Message-ID: <93cm4n$oi6$1_at_wanadoo.fr>
> hello,
> how can i write a query with input variable in sqlplus: the user will
> be able to input values at runtime.
> many thanks in advance.
>
>
> Sent via Deja.com
> http://www.deja.com/
Received on Mon Jan 08 2001 - 16:24:33 CET
Date: Mon, 8 Jan 2001 16:24:33 +0100
Message-ID: <93cm4n$oi6$1_at_wanadoo.fr>
[Quoted] Use the accept command
sample :
prompt 'Enter code :'
accept codeclt
select desig from client where code=&codeclt
/
Jerome
More about accept :
ACC[EPT] variable [NUM[BER]|CHAR|DATE] [FOR[MAT] format]
[DEF[AULT] default] [PROMPT text|NOPR[OMPT]] [HIDE]
ACCEPT reads a line of input and stores it in a given user variable.
variable
is the name of the variable in which you wish to store a value.
[Quoted] If variable doesn't exist, SQL*Plus creates it.
NUM[BER]
makes the datatype of variable the datatype NUMBER. If the
reply does not match the datatype, ACCEPT gives an error message
[Quoted] and prompts again.
CHAR
makes the datatype of variable the datatype CHAR. The maximum CHAR
[Quoted] length limit is 240 bytes. If a multi-byte character set is used,
[Quoted] one CHAR may be more than one byte in size.
DATE
Expects the reply to be a valid DATE format. If the reply is not
[Quoted] a valid DATE format, ACCEPT gives an error message and prompts
[Quoted] again. The datatype is CHAR.
FOR[MAT]
specifies the input format for the reply. If the reply does not
[Quoted] match the specified format, ACCEPT gives an error message and
prompts again for a reply. The format element must be a text
constant such as A10 or 9.999.
Oracle date formats such as 'dd/mm/yy' are valid when the
datatype is DATE. DATE without a specified format defaults to
[Quoted] the Oracle NLS_DATE_FORMAT of the current session.
DEF[AULT]
sets the default value if a reply is not given. The reply must
[Quoted] be in the specified format if defined.
PROMPT text
displays text on-screen before accepting the value of variable
[Quoted] from the user.
NOPR[OMPT]
skips a line and waits for input; prompt not displayed.
HIDE
suppresses the display as you type the reply.
<ouaatchane76_at_my-deja.com> a écrit dans le message :
93ck17$jki$1_at_nnrp1.deja.com...
> hello,
> how can i write a query with input variable in sqlplus: the user will
> be able to input values at runtime.
> many thanks in advance.
>
>
> Sent via Deja.com
> http://www.deja.com/
Received on Mon Jan 08 2001 - 16:24:33 CET
