Friday 23 April 2010

Substitution and bind variables

Substitution and bind variables in execute script f5.

(execute statement f9 handles substitution variables '&' the same , but prompts for bind variables ':' in select update delete... (but not anonymous blocks))

Input



undefine a_value
undefine fred
--Substitution variables ie &...
--prompt if not known and set
prompt &&a_value
--set a value explicitly
define new_value = fred
prompt &fred

--Bind variables ie :...
variable my_bind varchar2
begin
:my_bind := 'value';
end;
/
begin
null;
--(use :my_bind within an anonymous block);
end;
/
--or
print :my_bind




Output


> undefine a_value

> undefine fred

> --Substitution variables ie &...

> --prompt if not known and set

> prompt &&a_value

old:prompt &&a_value
new:prompt set_a_value
set_a_value
> --set a value explicitly

> define new_value = fred

> prompt &fred

old:prompt &fred
new:prompt set_fred
set_fred
> --Bind variables ie :...

> variable my_bind varchar2

> begin
:my_bind := 'value';
end;

anonymous block completed
> begin
null;
--(use :my_bind within an anonymous block);
end;

anonymous block completed
> --or

> print :my_bind

MY_BIND
-----
value

Clearing substitution variables

ScriptRunnerContext substitution variables are cleared

1/if you connect the worksheet to another connection and back via the top right connection chooser.
2/You start a new work sheet
3/undefine variable_name

Saturday 27 February 2010

Using Oracle Client with SQLDeveloper

SQLDeveloper by default has limited connection configuration possibilities (thin jdbc driver) so 'edge cases' may need the Oracle (instant) Client install and full *.ora configuration

- sqldeveloper
- Tools preferences -> database -> advanced -> use oci/thick driver
- oracle client
- connection type TNS->connect identifier
- click kerberos to allow null username/password (or OS authentication but I think that has more consequences)

(and effectively kick the config back to the oracle thick client *.ora files and 'sqlplus' C code (where kerberos may not be configured))