Question Prodataset Top level and child query

jmac13

Member
Hi All,

I'm using 10.2b. I'm taking my first steps into prodata sets. after looking at the online course I came up with the following code using the tables we've got in our database. On the course it shows how to query top level query and a child query. This is done by doing two queries which point to their respective tables but in the second query in the query string it references to order table which the query has no knowledge of so I have no idea how this is suppose to work. I've basically followed that example with the two tables we have.. but of course it doesn't work.. so what Do I need to do to get this working?

Thanks


Code:
define temp-table ttGrades like grades.       

define temp-table ttPltgrade like pltgrade.

define dataset dsGradesPltgrade for ttGrades,ttPltgrade
    data-relation drGradesPltgrade for ttGrades,ttPltgrade
        relation-fields (grade-code,grade-code).
           
define query qGrades for grades.
define query qPltgrade for pltgrade.

define data-source srcGrades for query qGrades.
define data-source srcPltgrade for  query qPltgrade.

query qGrades:handle:query-prepare
("for each grades").


query qPltgrade:handle:query-prepare
("for each pltgrade where pltgrade.grade-code = grades.grade-code and pltgrade.preInActive = true").


buffer ttGrades:attach-data-source (data-source srcGrades:handle).
buffer ttpltGrade:attach-data-source (data-source srcPltgrade:handle).


dataset dsGradesPltgrade:fill (). 


for each ttGrades:
    display ttGrades.grd-desc ttgrades.grade-code.
    pause.
end.

for each ttPltgrade:
    display ttPltgrade.grade-code.
    pause.
end.
 

RealHeavyDude

Well-Known Member
You only need to use a query as a data source on the parent table. The fill behavior of the child table is defined by the data relation you define on the ProDataSet and the fill mode you assign the buffer.

Look for the DATA-RELATION option in the DEFINE DATASET statement and the FILL-MODE attribute of the buffer object handle.

Heavy Regards, RealHeavyDude.
 

jmac13

Member
Hi RHD,

I understand if I have a query for the parent table says "for each grades where grades.grade-code = 00012" then it will bring in all the pltgrades that had the same grade-code. But What if i want only the grades thats have pltgrades grades that have preInActive = true?
 

oli

Member
Use the WHERE-STRING attribute of the Data-Relation object.

You can also play with the FILL-WHERE-STRING attribute of the Data-Source object. In this case, keep in mind that you'll have to provide the part of the WHERE clause that is normally automatically generated through the data-relation(s).
 
Top