Template and conditional generation (check boxes)

Cesare Zecca

Member²
Hi all!

What is, in your opinion, the behaviour of this template code snippet?

Code:
-- The first use of the "foo" option
[foo=1st use (no)/1st use(yes)]
...
-- here a different generation
-- based on the value (selection) of the same "foo" option
[foo=2nd use:not checked/2nd use:checked!!]
We would like to expand, different pieces of code in different points, the generation should be based on the true/false (checked/unchecked) value of a single, unique, check box (option).

Let's assume that the user does NOT check that option: the result is

Code:
-- The first use of the "foo" option
1st use (no)
...
-- here a different generation
-- based on the value (selection) of the same "foo" option
1st use (no)
The template instantiation simply stores the text value of the unchecked/checked path of the first occurence of the "check box macro" and instantiates it everywhere the option has been used.

Instead the expected behavior would be, IMO, to remember the true/false (checked/unchecked) value for the option and to expand the code as indicated in the following uses of that "conditional" macro.
In this specific case we would expect for the

Code:
-- The first use of the "foo" option
1st use (no)
...
-- here a different generation
-- based on the value (selection) of the same "foo" option
2nd use:not checked
Please note that PLSQL Developer does not complain
of other uses of the conditional macro, simply ignores them.

Any way to use a check box macro as if then else code generator?
Thanks in advance.

(PLSQL Developer 6.0.5.926)
 
P.S.
The initial version of the 1st use of the "foo" option macro was

Code:
[foo=1st use:foo:checked/1st use:foo:unchecked]
But that was resulting in a user variable foo with default ""1st use :confused:
Something does not work when the name of the macro occurs in the text to be expanded.
 
I agree with you. I have often run into this limitation. It would be great if one check box would change multiple locations of the code like you said.

Another thing that would be nice is if it would be able to use variables (or even another condition) inside of a condition.

For example:
[Populate table=No: " ",Yes:
"INSERT INTO [table_name] VALUES (... , SYSDATE, :bv_user_id, :bv_user_id, :bv_pkg_num, SYSDATE);"]

Currently, it just lists the text verbatim within the quotes instead of asking for the table name.

Mike

P.S. I know I'm complaining here, but I do like how PL/SQL Developer does templates. It's better than other IDE's, it makes my life easier and I use them a lot.
 
It is currently not possible to change multiple pieces of a template based on a single checkbox, nor is it possible to nest template variables. I have added both to the list of enhancement requests though.
 
Hello,

@Mike:

You can do it using Browser Extender 2.5, just put the following code into onClick event editor and insert Browser Extender substitution variable #oname (object name).

[$WINDOW TYPE = COMMAND]
[Populate table=No: " ",Yes:
"INSERT INTO #oname VALUES (... , SYSDATE, :bv_user_id, :bv_user_id, :bv_pkg_num, SYSDATE);"]

Browser Extender will automatically replace #oname with current object name in PL/SQL developer browser.

@Cesare:

Maybe example below helps you, it is not exactly what you want but that is a way to change code in multiple places (using dropdown list values instead checkbox), currently a workaround.

analyze #otype #object [+Sample size (%)="estimate"] [-Sample size (%)="compute"] statistics
[+Sample size (%)="sample "][Sample size (%)=*,10,20,30,40,50,60,70,80,90][+Sample size (%)=" percent"];

Greetings,
Joachim Rupik
 
Back
Top