It is created with create.
The querymode is set to YES.
There are actually several datawindows each associated with a different table. The user might put search criteria into several datawindows and then click our Select button.
My code grabs the WHERE clauses from all of these and assembles them into a SELECT with (potentially) multiple subqueries.
For example, here is what is being sent to the database:
SELECT ... FROM dbo.Samples
WHERE
(((dbo.Samples.datereceived > '1-1-2012 0:0:0.000')))
AND (dbo.Samples.speciesid in ( SELECT dbo.Species.id FROM dbo.Species WHERE (((dbo.Species.commoname like '%[Rr][Yy][Ee]%'))) ) )
AND (dbo.Samples.varietyid in ( SELECT dbo.Varieties.id FROM dbo.Varieties WHERE (((dbo.Varieties.name like '%[Rr][Ee][Dd]%'))) ) )
AND (dbo.Samples.growerid in ( SELECT dbo.Clients.id FROM dbo.Clients WHERE (((dbo.Clients.name like '%[Ff][Aa][Rr][Mm]%'))) ) )
The WHERE clauses come to me by asking each data window for its datawindow.table.select and grabbing everything from WHERE on.
So, the WHERE's that I grabbed were:
- WHERE (((dbo.Samples.datereceived > '1-1-2012 0:0:0.000')))
- WHERE (((dbo.Species.commoname like '%[Rr][Yy][Ee]%')))
- WHERE (((dbo.Varieties.name like '%[Rr][Ee][Dd]%')))
- WHERE (((dbo.Clients.name like '%[Ff][Aa][Rr][Mm]%')))
And then our code assembles the select. When we go to Oracle, there will be lots of quotes around the table and column names.
SELECT * FROM dbo.Clients
WHERE
((("DBO"."CLIENTS"."ID" > 13000)))
AND (dbo.Clients.id in ( SELECT dbo.ClientClasses.id FROM dbo.ClientClasses WHERE ((("DBO"."CLIENTCLASSES"."CLASS" = 2))) ) )
It would take more text processing than I am comfortable with to inject calls to upper() or lower() programmatically on the char columns. I think bugs would be introduced that would only be noticed years from now. I wish PowerBuilder had a checkbox in the Properties area so that I would indicate that I want case insensitive selection. Solving this at the database level is sounding appealing.
I will do the messagebox('dw object',dw.dataobject) and post later. Thanks for the reply.