Passing parameters to PL/SQL while in a Sparse Lookup

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
AntRan
Participant
Posts: 7
Joined: Tue Sep 18, 2012 2:49 pm
Location: United States

Passing parameters to PL/SQL while in a Sparse Lookup

Post by AntRan »

from document:

if the Read mode property is set to PL/SQL and the Lookup type is set to Sparse, the connector matches by name the reference link columns with the parameters in the PL/SQL block. The connector maps the columns marked as key columns to PL/SQL input/output parameters and maps the remaining columns to the PL/SQL output parameters.

If the connector cannot match the names, the connector attempts to use the column order to associate link columns and parameters. Therefore, the connector associates the first column on the link with the first parameter, associates the second column on the link with the second parameter, and so on.

Note: For PL/SQL blocks, you must use the Oracle syntax. If you use DataStage syntax, the connector logs an error and the operation stops. If you use integer values for parameter names, you must specify the integers in increasing order; otherwise, the connector logs a Fatal message, and the operation stops.
===========================================

Yes, passing a paramter isnt quite the correct terms to use but i want to use variables i have in the lookup stage to be used in the pl/sql statements.

I have done hundreds of sparse lookups using just the normal sql but everything i try (and it was countless different attempts) to get a pl/sql to read my :MY_VARIABLE in my sql text, it was complete hopeless. I do not have parameters like calling a procedure, i just wanted to write some pl/sql code and use some variables i have in the lookup stage. Everything i did ended in:

Lookup_13: The connector could not find a column in the input schema to match parameter MY_VARIABLE. (CC_OraUtils::bindDBParamsByName, file CC_OraUtils.cpp, line 808)

Obviously i have MY_VARIABLE set as an input field going into the lookup. Has anyone been able to pass a parameter to a pl/sql statement and got it to work. The returning variables work fine. If i hardcode the MY_VARIABLE, then it works and gives me my results. I try to pass a variable to the routine, and it fails.

Here is the shortened code:
declare


v_rc CALL_PKG.c_realtime_tdp_ref_cursor ;


o_tran number;
begin

CALL_PKG.npp_main
(
:MY_VARIABLE ,
v_rc
) ;
loop
fetch v_rc into o_tran
exit when v_rc%NOTFOUND;

end loop;
close v_rc;

:RETURN_TRAN := o_tran;

end ;
iShoreETL
Premium Member
Premium Member
Posts: 36
Joined: Wed Sep 05, 2012 9:40 pm

Post by iShoreETL »

Did you ever figure this out?
iShoreETL
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

Variables from the lookup stage are not local to Oracle and need to be concatenated in PL/SQL statement using pipes.
iShoreETL
Premium Member
Premium Member
Posts: 36
Joined: Wed Sep 05, 2012 9:40 pm

Post by iShoreETL »

Not clear yet.

In example above, suppose the value of the input field going into the lookup is MY_VARIABLE='ABCXYZ'


How should the pl/sql look like? Please provide an example.
iShoreETL
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

I suspect that your question may be different from that of OP. Are you trying to use Sparse lookup stage to call a package/function or run a Select query?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

iShoreETL - you really should open a NEW post with the details behind whatever issue it is that you are having.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply