datawindowchild arguments dependant on retrieval result in same datawindow

Sorry if the title is confusing, but so is the topic.

I have a one to many relationship between two datawindows so that when you click on a row in dw_1 it shows multiple rows in dw_2.  I have a dwc field in dw_2 that has two arguments, one of which is dependant on the information that comes back when dw_2 is retrieved.  So I can't figure out how dynamically retrieve the data window for each row.

Essentially I am trying to show the number of notes that have been created for a particular provider as follows:

company c
                provider_1   provider_name  dwc_number_of_notes_for_provider (e.g. 6)
                provider_2   provider_name  dwc_number_of_notes_for_provider (e.g. 0)
                provider_3   provider_name  dwc_number_of_notes_for_provider (e.g. 4)

Here is the code, but I cannot figure out where to put it to make it work:

//            DWC to get number of notes for provider

            int rownbr3
            rownbr3 = tab_1.tabpage_1.dw_2.getrow()

            int sp_id3
            sp_id3 = getitemnumber(rownbr3, "service_provider_sp_id")

//            DataWindowChild dwc_provider_notes
            integer rtncode3
//            rtncode3 = tab_1.tabpage_1.dw_2.GetChild('sp_company_notes', dwc_provider_notes)
            rtncode3 = tab_1.tabpage_1.dw_2.GetChild('compute_1', dwc_provider_notes)

            messagebox("Return code is ", string(rtncode3))
            //***MAY NEED MORE HERE
            long iii_row3
            iii_row3 = dwc_provider_notes.insertrow(0)
            int dwcrows3
            dwcrows3 = dwc_provider_notes.Retrieve(gv_effort_id,sp_id3)
            messagebox("Return rows are ", string(dwcrows3))
//            tab_1.tabpage_1.dw_2.settransobject(sqlca);

Perhaps there is an alternate way to do it.  Essentially, I just want a field to display a rowcount for table b that is based on information that in the same row.

Thank you,

Who is Participating?
....Essentially, I just want a field to display a rowcount for table b that is based on information that in the same row....

for this reason no need to take dropdowndatawindow. Following are the two ways to solve the problem.

1) create user defined function udf_getrowcount() which returns long and argument is what u r passing in dropdowndatawindow ( say arg1 and arg2 )

now in function write down

//-- function start
Long ll_rowcount
select count(*) into :ll_rowcount from table_name where col1 = :arg1 and col2 = :arg2 ;
return ll_rowcount
//-- function end

now put computed expression in dw_2 and writedown
udf_getrowcount(arg1,arg2) as a expression in it.

run the application and check's done..

2) create a datawindow on required table with the syntax as described in solution 1, but without 'into :ll_rowcount'...define retrieval argument arg1 and arg2...assign in where clause...put this datawindow as a nested datawindow in dw_2...pass the argument to nested datawindow....that's it...

use any of the solution whatever is convininent to case of any problem do reply...

have a nice day...

>>> So I can't figure out how dynamically retrieve the data window for each row
 if this means u want to retrieve the dddw for each row retrieved in dw_2, then it's not the correct way... because u retireve a dddw in the dw, and it applies to all rows.

what you can do is to retrieve the dddw after data is retrieved in the dw_2, and have another dddw( visible only for current row) that shows filterd record from the first dddw, depending on the row in dw_2.

pemurrayAuthor Commented:

Thank you,

This is my first time creating a user function so please bear with me...

I created the user function and named it: udf_getrowcount

Here is the code:

//-- function start
Long ll_rowcount
select count(*) into :ll_rowcount from service_provider_notes where effort_id = :gv_effort_id and sp_id = :sp_id ;
return ll_rowcount
//-- function end

The function painter whined a bit as the argument names are the same as two global variables, but it let me save it.

I created a computed field and typed this into the expression: udf_getrowcount(gv_effort_id , sp_id)

But I could not save the field because I keep getting the following error in the expression painter: ')' expected to close expression after function.

I spent quite a bit of time researching this but could not come up with an answer.

Thank you again for your help!!

pemurrayAuthor Commented:
Okay, I figured it out by using the colum names for the rows instead of the global variables as the arguments.  Doesn't make sense to me but I did get it done.  I notice that it is not as real time as I would like (e.g., you have to reretrieve after you do not to make it update the dw.  But I am happy with the solution.  Sandeep will get the point, thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.