How to define / declare and use a variable in Squirrel SQL client 3

I am using SQuirreL SQL Client Version 3.2.1 software and I want to declare a variable as

define dateFrom = '13/04/2012';
define dateTo = '13/04/2012'

And use it in my sql query like this

SELECT * FROM table_name WHERE TRUNC(column_name) BETWEEN to_date('&dateFrom','YYYY-MM-DD') AND to_date('&dateTo','YYYY-MM-DD');

But that will not work. How to define and use a variable in SQuirreL.

+5
source share
3 answers

Perhaps not quite what you want, but have you tried downloading the 'sqlparam' plugin? It offers variable substitution, for example.

SELECT * FROM table_name WHERE TRUNC(column_name) BETWEEN :dateFrom and :dataTo

When executing this query, Squirrel will request values.

0
source

, , , . SquirrelSQL 3.8.1 oracle.

SELECT * FROM table_name WHERE TRUNC(column_name) BETWEEN to_date( :dateFrom ,'YYYY-MM-DD') AND to_date( :dateTo,'YYYY-MM-DD');

: - .

0

"SQuirreL (like Oracle SQL-Plus) should know when you finish your anonymous procedure. This is usually done by adding a line at the end of your procedure with a smoothing character (/). For example:"

DECLARE
v1  NUMBER(3);

BEGIN
  v1 := 3;
  select 1 from dual
END;
/

Please see here: http://sourceforge.net/p/squirrel-sql/mailman/message/28580491/

Now, when you select your SQL, including the slash, you can start it with Ctrl + Enter.

-1
source

All Articles