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!
01-28-2001, 12:52 PM
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,
01-28-2001, 06:31 PM
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).
01-29-2001, 10:02 AM
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.
01-29-2001, 06:51 PM
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.
01-30-2001, 05:34 PM
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.