Master Detail pipelines using stored procedures

I have two pipelines in my report template, one is a detail dataset of the other (master). The detail pipeline is actually a stored procedure and requires an input parameter which identifies the unqique master record value to run the report for. The parameterized SQL does not help me, because I need the parameter in the input of the stored proc.

For example the stored procedure SQL looks like this:Select * from GET_DETAIL_VALUES(:In_Master_Value)

If I use the parameterized SQL, it just appends a where clause on, but I have no way of adjusting the original parameter IN_MASTER_VALUE.

I have come to the conclusion that I should use an event of one of the data pipeline (onmasterrecordchanged, or ontraversal), but I dont know how to refer to the "built-in" data pipeline objects in code. The pipelines are not on a delphi form, they are built into the template file.