how to use variable as i do in sql server?

hanwee

Member
i can use variable in sql server in some simple code.

declare @code varchar(400) set @test = 'A00.000'
select * from A where a.icd = @test
select * from B where b.code = @test

but how to make it in pl/sql developer ?
i can band variable in command window,but not in sql window?
how to use variable in sql window?

 
In the SQL Window you can use substitution variables:

select * from A where a.icd = '&test';
select * from B where b.code = '&test';

 
yes!;thx!;that's really a solution,but it's not perfect yet.
we got a little problem

once we shutdown plsql developer,
the value of those variables will forget.

shall we keep those value?
 
Last edited:
You can assign a default value:

select * from A where a.icd = '&';
select * from B where b.code = '&test';

See also the "Substitution variables" section of the User's Guide.
 
wondfull, this scriopt can store the value

but why the default value won't change after i change that default = "A00.000"

if i change a00.000 to a00.001 ,i have to reboot the sql window

how to improve it
 
Back
Top