Use Variables

Variables can be defined using command vset. Few variables are system variables, used by DbConsole. Any other user-defined variable will be replaced in SQL text if the system variable replace_variables=true: Use help to list all system variables. Execute show variables to list the already defined variables.
vset spool.separator=|
vset format.timestamp=YYYY-MM-dd'T'hh:mm:ss'Z'
vset replace_variables=true

vset myid=6230
connect db4
execute export.sql
Where the export.sql script is :
spool /tmp/export_&myid.csv
select * from some_table where id=&myid;