I am writing a script to be run in sqlplus 11. I have a user defined variable called compression. If this is true then I want to run the script CreateTablesCompression, otherwise run. I have the following:
decode(compression,'true',@@CreateTablesCompression,@@CreateTables);
However,when I run this I am thrown the error: unknown command beginning “decode…
Am I missing something here, I can’t see why SQLPlus wouldn’t recognise decode?
Decodeis not a SQL*PLUS command, you cannot use it directly in sql*plus only inside a pl/sql block or a query. So here is an example of how a conditional branching can be done:We declare a variable
flagwhich going to regulate which one of two available scripts to run.