oracle-databaseoracle11gsquirrel-sql

Squirrel SQL - user input prompt


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


Solution

  • 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.