Variable treatment in 10.5.1

I just upgraded to Toad For Oracle 10.5.1.

I use variables alot in my queries since I have many schemas to manage.

In this release it appears that Toad wants me to provide a value for the same variable every time it used. For instance I have a query that unions about 10 queries together. The each are going against the same schema using the same variable &SCHEMA.

Select *
From $SCHEMA.table1 A,
$SCHEMA.table2 B
Where…
union
Select *
From $SCHEMA.table1 A,
$SCHEMA.table2 B
Where…
union…

Since this variable is used twice in each query I getting about 20 SCHEMA values to fill in (SCHEMA(1) through SCHEMA(20). Older versions such a 9.7.2 correctly intrpretted that like variables only need to prompted for once.

I have not been able to find a way to change this behavior in options or in the onlne help.

Does anyone know if this behavior configurable?

Sounds like you need to use the && notation, not the & notation. Search for SQL*Plus substitution variables and review the differences between each. There is a lot of information out there.

Michael

Morning Joe,

...
In this release it appears that Toad wants me to provide a
value for the same variable every time it used. For instance
I have a query that unions about 10 queries together. The
each are going against the same schema using the same
variable &SCHEMA.

Select *
From $SCHEMA.table1 A,
$SCHEMA.table2 B
...
Is the '$' a typo? It should be an ampersand '&' or two '&&'. Also, I
think you need two dots between the &SCHEMA and the table name:

Select *
From &SCHEMA..table1 A,
&SCHEMA..table2 B
...

Because the first dot tells SQL*Plus/Toad to "stop substitution", as in:

Since this variable is used twice in each query I getting
about 20 SCHEMA values to fill in (SCHEMA(1) through
SCHEMA(20). Older versions such a 9.7.2 correctly
intrpretted that like variables only need to prompted for once.
In SQL*Plus, which Toad emulates to a certain degree, the '&' is used to
prompt for each and every occurrence of a variable (unless it has been
DEFINEd or ACCEPTed first of course) and the '&&' only prompts for the
first occurrence and then uses it again for each subsequent occurrence.

It sounds remarkably like 9.7.2 was broken!

I tried this in 9.5:

SELECT * FROM &SCHEMA..dual
UNION ALL
SELECT * FROM &SCHEMA..dual;

The variables prompt showed two separate variables. When I filled in the
first and clicked OK, I was prompted that "one variable is still empty,
do you want to fix it?".

When I ran it like this:

SELECT * FROM &&SCHEMA..dual
UNION ALL
SELECT * FROM &&SCHEMA..dual;

There was one single variable in the list, and I only received the one
prompt.

Cheers,
Norm. [TeamT]

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else. We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes. If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Morning Joe,

I wrote:

Also, I think you need two dots between the &SCHEMA and the table
name:

Select *
From &SCHEMA..table1 A,
&SCHEMA..table2 B
...

Well, I just tried this in Toad 10.5.1.3 and with two dots, it fails
with "Error: ORA-00903: invalid table name" but with one dot, it works
fine.

This is not how SQL*Plus works with substitutions. :frowning:

Cheers,
Norm. [TeamT]

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else. We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes. If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Norm,
Running with F5 gives the error?

Greg

On Aug 11, 2010, at 3:28 AM, "Dunbar, Norman (Capgemini)" wrote:

Morning Joe,

I wrote:

Also, I think you need two dots between the &SCHEMA and the table
name:

Select *
From &SCHEMA..table1 A,
&SCHEMA..table2 B
...

Well, I just tried this in Toad 10.5.1.3 and with two dots, it fails
with "Error: ORA-00903: invalid table name" but with one dot, it works
fine.

This is not how SQL*Plus works with substitutions. :frowning:

Cheers,
Norm. [TeamT]

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else. We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes. If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Hi Greg,

you're up early!

Norm,
Running with F5 gives the error?

It looks like F5 runs things correctly as it only works with two dots -
SQL*Plus style. F9 appears to be broken.

With F9 I need only one dot or it won't work. If I use two dots I get
this in a pop-up:

SELECT * FROM &&SCHEMA..dual
UNION ALL
SELECT * FROM &&SCHEMA..dual;

ORA-00903: invalid table name

Spooling the sql to screen shows nothing (except the error message) but
SQL Tracker shows this:

The ‘.’ bug was fixed at the beginning of the 10.6 beta cycle so look for it next GA. It was a bug in 10.5 and likely 10.0/1 as well.

Michael