COGNOiSe.com - The IBM Cognos Community

ETL, App Development and other tools => COGNOS DecisionStream/Data Manager => Topic started by: eknight on 17 Jul 2012 10:37:52 AM

Title: How does the Exit() control function work?
Post by: eknight on 17 Jul 2012 10:37:52 AM
I'm trying to write a function that accepts a type and performs an SQL request based on the value. In the case that an invalid value is passed to the function I would like to print an error message and end the job rather than send a mangled SQL to the DB.

On the left side of the Implementation tab of the Function properties is a (I assume comprehensive) list of the syntax possibilities within this language. The Exit() function seems to be exactly what I'm looking for but when I run the job it is simply ignored. The System() call directly afterwards is still called and the job runs successfully.

Are there maybe specific code values that I need to pass to Exit() in order for it to end execution of the job?

if TYPE NOT IN ('CHR','NUM','AMT','TS','D')
then begin
        System(concat('echo ERROR: Invalid TYPE passed to READ_VAR: ', TYPE));
        Exit(-1);
        System('echo Why am I able to read this?');
     end
else begin
           <SQL REQUEST>       
     end


Edit: Forgot an apostrophe.
Title: Re: How does the Exit() control function work?
Post by: MFGF on 17 Jul 2012 05:54:06 PM
Why are you trying to do this all in one node? Couldn't you set a variable based on the results of your test then use a condition node afterwards to look at the variable contents and either proceed with an SQL node or else link to a procedure node displaying a message that has no successors in the stream?

Just a thought.

MF.
Title: Re: How does the Exit() control function work?
Post by: eknight on 18 Jul 2012 01:57:05 AM
It's not a node, it's a function that is being called by the variable initialization of many DS Jobs.
Title: Re: How does the Exit() control function work?
Post by: eknight on 18 Jul 2012 07:27:44 AM
I think I've found my problem.

Apparently the Exit() function has no meaning outside of builds (http://publib.boulder.ibm.com/infocenter/cbi/v10r1m0/index.jsp?topic=%2Fcom.ibm.swg.im.cognos.fnct_ds.10.1.0.doc%2Ffnct_ds_id1780Exit.html).

Which explains why it's not working. As far as I can tell though there is no comparable function that exists at the Job level. So I guess I'm just going to have to rethink my solution entirely.