1

Issue: I am supposed to call and execute a PL/SQL procedure which is previously defined in DB and requires an input value. In addition, there must be a checking statement that controls the input (which will later provide by entering it at runtime) is not zero. (This is a business condition even though it is possible it is not logically needed.)

Solution:

  1. I have created an ODI variable with a background code, used this variable as input value of the called procedure. I mean, if the variable name is tst_var:
begin 
my_schema.procedure_name(#ODI_PROJECT.tst_var);
end;
  1. I have created an ODI package and put these ODI variable and procedure sequentially in it. Also I have selected type of set variable for my variable. The output is as following:

enter image description here

This stream that I explained, works well. But as it is evident, there is no checking statement. Can anyone help me with issue that how can I add an IF-ELSE statement to control the value of variable tst_var?

Actually, if I want to put my thought down on paper, it would be:

current_Date= TO_CHAR(TO_DATE(SYSDATE - 1),'YYYYMMDD');
if #ODI_PROJECT.tst_var<> 0 then my_schema.procedure_name(#ODI_PROJECT.tst_var);
else my_schema.procedure_name(current_Date);

Now, I have no idea of implementing the equivalent of above logic in ODI.

1 Answer 1

1

That logic can be implemented directly in the PL/SQL block in the ODI Procedure :

DECLARE
  L_CURRENT_DATE VARCHAR2(8);
BEGIN
  L_CURRENT_DATE := TO_CHAR(SYSDATE - 1,'YYYYMMDD');
  IF #ODI_PROJECT.tst_var <> 0 THEN
    my_schema.procedure_name(#ODI_PROJECT.tst_var);
  ELSE
    my_schema.procedure_name(L_CURRENT_DATE);
  END IF;
END;

Note that:

  1. There is no need for the TO_DATE on SYSDATE-1 as this is already a date.
  2. The variable L_CURRENT_DATE is optional, you can also directly use my_schema.procedure_name(TO_CHAR(SYSDATE - 1,'YYYYMMDD'));
Sign up to request clarification or add additional context in comments.

1 Comment

Such a great solution! Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.