Re: select .... where 1 = 2
Posted in 1996
aaron@silo-alcazar.com (Aaron Pelton) writes:
> I have an ace report which is used to print an invoice based on 2
> different scenarios. In one case, I want to print all unprinted
> invoices. In another, I want to print a specific invoice. At the
> moment I'm trying to be clever and use the same report for both
> instances. So, what I ended up with is (grossly oversimplified):
> select field1, field2 from a,b
> where f3 = f4 and printed_date is null and "A" = $pass_param dummy_inv
> union
> select field-from-as-above
> where f3 = f4 and invoice num = $inv and "S" = $pass_param 312
> My thought was: with the the report called as "sacego blah A #", I'd
> get the first select to work and "sacego blah S #" the second select
> would work, the joins creating a single set without temp tables.
Perhaps I'm missing something, but couldn't you do something silly like
what's below? I agree though with the person who suggested splitting it
into two separate reports. The code below should work, but it's highly
inefficient for what (I think) you're trying to accomplish.
define
param[1] blah char(1)
variable is_group integer
end
select 1 which_param, field1, field2 from a, b
where printed_date is null...
union
select 2 which_param, field1, field2 from a, b ...
where invoice_num=$inv
end
format
first page header
let is_group=0
before group of which_param
if blah = "A" then let is_group=1
else if blah = "B" then let is_group=2
on every row
if which_param=is_group then
print field1, field2 ...
end
--
--------------------------------------------------------------------------------
Daniel James - Database Administrator djames@statsci.com
StatSci, a div of MathSoft, Inc. (206) 283-8802 x284