0

In Microsoft SQL Server

DECLARE @var INT
SET @var = 1
SELECT @var

What would the equivalent statement be in Aqua Data Studio when querying an Oracle server?

I've tried different variations of this (with GO or ; as statement separators, nothing has worked so far).

DECLARE var INTEGER 
SELECT var FROM DUAL
Matthew Walk
  • 1,014
  • 2
  • 16
  • 36

3 Answers3

1

use 'Parametrized Script' button in Query Analyzer. and var name with & in code:

select * from tabl where id = &id

More info: https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation11/page/51/5-5-Parameterized-Scripts

a16ert
  • 11
  • 1
0

I guess you can use variable binding, but it does have a different syntax. Try the below example query.

=== Query ===

.variable var1, VARCHAR, '10'
.variable var2, VARCHAR, '30'
.executeCallableQuery 'var1,var2',

select * from SCOTT.DEPT

More info here: https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation14/page/196/Aqua-Commands

tariq
  • 615
  • 5
  • 12
  • 2
    Hi, I tried "select var1, var2 from dual" with the code you provided above, but that didn't work. How would you be able to use var1 and var2 in a SQL statement after they were created? – Matthew Walk Mar 10 '17 at 18:21
0

If you don't want to use Parameterized Scripts to declare a variable in Aqua Data Studio, try using the following:

declare var1 varchar(20) := 'Hello world!';
begin
    DBMS_OUTPUT.put_line(var1);
end;