I am a first time user of Squirrel SQL client for Oracle DB.
When I am executing the below queries it is not popping up with a user input dialog box, instead just displaying empty rows
Query
Select * from employees e
Where e.id in ('&emp_id');
The same query when executed in SQL Developer gives an user input dialog pop up.
Tried with = and other minor tweaks, nothing has worked for me
CodePudding user response:
I don't use Squirrel SQL, but - from my point of view - your code doesn't work because the engine searches for ID values that are equal to string, literally '&emp_id'
.
If you want to be prompted for a parameter value, try colon:
select * from employees e where e.id = :emp_id;
-------
this
You used IN
; that's OK as long as you enter a single value for a parameter. If you planned to use several values (e.g. comma-separated list of values), that won't work just because. There's a way to do it - for example, you'd split those values into rows and use them as a subquery, but - that's beyond your current problem. First try to make it work with a single value passed as a parameter.
CodePudding user response:
Squirrel SQL does not support input prompts in the way that SQL Developer does. One way to achieve similar functionality would be to use a prepared statement instead of a prompt.
You can do this by replacing the prompt with a bind variable, like this:
Select * from employees e Where e.id = ?
Then, when you run the query, Squirrel SQL will prompt you to enter the value for the bind variable (in this case, the value of emp_id). This will be done in a separate window in Squirrel.