Andron
21st March 2003, 08:12
table tabA |Main table
|field tabA.F1, F2 is primary key of tabA

table tabB
|field tabB.F2 is primary key of tabB

before.program:

N=argv$(1) - export from other session

|This is don't work correctly
query.extension="tabA.F1=:N and tabB.F2=:tabA.F2 and tabB.F3 = const1"

*********** OR **************

|It works correctly
main.table.io:
after.read:
select tabB.F3 from tabB
where tabB.F2=:tabA.F2
selectdo
if tabB.F3 <> const1 then
skip.io("")
endif
endselect

How correctly to design query.extension in section "before.program"?

morpheus
21st March 2003, 08:41
Andy,
First of all query.extension works for the main table of the session.
Secondly, I am not sure whether :tabA.F2 has got any value!!

evesely
21st March 2003, 15:51
You can add elements that contain other tables to the query.extension, but since the query itself is on the main table, these extra elements should be subqueries. This, however, will not allow the population of fields from the secondary table(s); it is for limiting the records selected.

Example with main table tdsls045 where you only want to show deliveries from orders with order type 123.

query.extension = "exists (select tdsls040.cotp
from tdsls040
where tdsls040._index1 = {tdsls045.orno}
and tdsls040.cotp = ""123"")"

Dikkie Dik
21st March 2003, 16:14
When using BaanERP query.extend can work on more than only the main table. The following fucntions exists:

query.extend.select()
query.extend.select.from.in.zoom()
query.extend.from()
query.extend.from.in.zoom()
query.extend.where()
query.extend.where.in.zoom()

So in your case (assuming tabA is the main table) you probably should say:

query.extend.from(", tabB")
query.extend.where ="tabA.F1=:N and tabB.F2=:tabA.F2 and tabB.F3 = const1"

Hope this helps,
Dick

srkndnsn
13th January 2020, 09:55
It works when use query.extend.from, query.extend.where keywords.
Thanks :)

Best
Serkan