I want to do something like the following
PROMPT Enter something please;
But inside a PL-SQL block. How can I do it? I could use DBMS_OUTPUT to replace the prompt, but what can I use instead of the ACCEPT ? (I search for a DBMS_InPUT package but that doesn't seem to exists :-) ).
Any help would be appreciated!
did you try using a substitution variable.
Select ename, mgr from emp where empno = &eno
Here, eno is the substitution variable ( it is preceeded by a & to indicate that it is a substitution variable ) and oracle prompts the user to provide value for this variable. This may not be the exact alterntive to ACCEPT, but some what usefull in certain cases.
Also i haven't figured out how to use the value the user had given for this sunstitution variable ( eno ) elsewhere in the PLSQL block. Using it as &eno will cause oracle to prompt again and using it as eno gave me errors.
Hope this helps you,
You cannot use ACCEPT in PL/SQL.
Is it possible to split your PL/SQL in two blocks, one before and one after the ACCEPT command? (As mentioned by Ad in the Development Forum).
Or you can use a substitution variable, as Wolf mentioned.
If you need the substitution variable (&your_variable) more then one time in your code, use double ampersands (&&your_variable) or asing it once to a variable you use in the rest of your code (my_used_variable := &my_substitition_variable).
Thanks you two for your answers!!
I try a substitution variable and it work, but I still have one problem:
What I want to do is a validation loop, where my user enter a password until it is valid. The problem is, once I have given a value for my substitution variable, it stay the same, causing an infinite loop.
With the SQL*PLUS command:
you delete the substitution variable, a next time SQL*Plus finds the substitution variable it will ask for a value.
Because UNDEFINE is a SQL*Plus command, like ACCEPT, you cannot use it in PL/SQL.
Since what I try to do is a validaiton loop where the user enter a password until it is valid, I'm stuck inside a PL-SQL block. I guess that what I try to do isn't possible after all. :-(
But thanks for your answers, it isn't lost! I have learned something new that could be useful another time.