Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numbers in Where clause

Status
Not open for further replies.

haste

Programmer
Feb 27, 2005
96
GH
I'm reformatting a report and the block of the query has the following clause in the select statement:
Code:
select fld1, fld2, fld3
from tabx
WHERE 1=2  --<----

what baffles me is that it returns values when run from the form. How or from where are the values 1 and 2 being loaded or substituted?
 
The numbers are neither loaded nor substituted. This is quite a valid query, however it can not return any data. The constructions like that in WHERE clause used to either return all data, or no data. For example, you may have parameter :p_data and specify
Code:
select * from your_table
where 1 = :p_data
Now, if p_data equals 1, the query will return full set of data. For any other value the query will return no data.
Combinations 1=1 and 1=2 are also often used as initial values for lexical parameters in Oracle Reports.
 
It seems the query is being used to create a temporary structure for holding report values. However I can't find a procedure or form that produces the results. I've checked all the program units. Could 1 and represent field refered to based on there positions?
 
No, that can be done only in ORDER BY clause,
like
Code:
select fldA, fldB, fldC from Table
order by 2,1
which is equivalent to
Code:
select fldA, fldB, fldC from Table
order by fldB,fldA
 
Thanx for the clarification. Will dig deeper into the report and see what the source of the data could be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top