Cannot reference bind variables more than once, in template

Ivan C.

Member³
I'm trying to create a template for the DELETE statement with following content:

Code:
delete [TABLE].[TABLE] [TABLE]
 where

is a list generated from all_tables view.
is a list dependent on bind variable :Table_Owner.
is a hidden variable, also dependent on bind variable :Table_Owner, but it fails.
Here's template's code:

Code:
delete &<name="Table Owner"
         required="yes"
         lowercase="yes"
         list="select username
                 from all_users
                order by 1"
         restricted="yes">.&<name="TableName"
                             required="yes"
                             lowercase="yes"
                             list="select table_name
                                     from all_tables
                                    where owner = upper(:Table_Owner)
                                    order by table_name"> &<name="Table Alias"
                                                            hidden="yes"
                                                            lowercase="yes"
                                                            default="select substr(:Table_Owner,1,1)
                                                                       from dual">
 where [#]

The error I get is a pop-up with following content:
Table Alias: Error executing SELECT statement:
ORA-01008: not all variables bound

Do you have a workaround (or a fix) for it? Am I doing something wrong?
 
I realize what the issue is. :Table_Owner is not yet populated when I invoke the template.

I need a work around. Anyone, ideas? :)
 
Tried changing the default to list, as below (aside from adding the hidden attribute), but that didn't work either.

Code:
delete &<name="Table Owner"
         required="yes"
         lowercase="yes"
         list="select username
                 from all_users
                order by 1"
         restricted="yes">.&<name="TableName"
                             required="yes"
                             lowercase="yes"
                             list="select table_name
                                     from all_tables
                                    where owner = upper(:Table_Owner)
                                    order by table_name"> &<name="Table Alias"
                                                            lowercase="yes"
                                                            hidden="yes"
                                                            list="select substr(:Table_Owner,1,1)
                                                                    from dual"
                                                            restricted="yes">
 where [#]
 
Removed the hidden attribute, to monitor what's being populated in the list. The list is initially empty. The resulting value (alias) is present in the list after I pick a Table Name, but is not selected (picked). How would I force it?
Here's my latest version of the template:

Code:
delete &<name="Table Owner"
         required="yes"
         lowercase="yes"
         list="select username
                 from all_users
                order by 1"
         restricted="yes">.&<name="Table Name"
                             required="yes"
                             lowercase="yes"
                             list="select table_name
                                     from all_tables
                                    where owner = upper(:Table_Owner)
                                    order by table_name"> &<name="Table Alias"
                                                            lowercase="yes"
                                                            hidden="yes"
                                                            required="yes"
                                                            restricted="yes"
                                                            list="select substr(:Table_Name,1,1)
                                                                    from dual">
 where [#]
 
Back
Top