Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can create a function ?

Hi,

I try to know how I can call a function.

ex:

I make a table:

LOAD

    *

FROM

    Documents



and now I want to use this table in each other table I have without copy/past. Until now I put this table into a variable and I wonder if is it work.

Regards

19 Replies
marcus_sommer

One addition, maybe it's better to remove the COUNTRY_CODE and put the tablename or something similar within these error-load and use an autogenerate 1;

- Marcus

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I see what you are trying to do and I think it's very clever.

You can use either the $(vError); approach as Marcus suggested or an $(incude).

If using the $(include),  be careful that there are no statements in the include before that LOAD, as that would reset the *Error variables..

I think you should also remove the CONCATENATE and just rely on auto concatenation. Then you won't have to pre-create the table.

-Rob

Not applicable
Author

Hi Marcus!

Thanks for your help.

I tried your answer and I got a problem. Do you know why my errors are reset? They are all at NULL and 0

REgards

Not applicable
Author

Thanks for your help.

I always get the same error. All my Error variable turn NULL when I use $(vError) and when I put my all error script next to my table I get everything I need. If you have a idea I take it!

Regards

Not applicable
Author

Thanks for your help,

I try what you sent to me, but the result is NULL after my table. I wonder if this call function doesn't reset my error varible.

marcus_sommer

Please post an example (not your original - a small dummy with a few inline-tables).

- Marcus

Not applicable
Author

<//include-file:

let vLoadTable = TableName(NoOfTables() - 1);

CONCATENATE(ERROR)

LOAD

  //COUNTRY_CODE,

  '$(NbRows)' as NB_ROWS,

  '$(ScriptErrorCount)' as ERROR_SEQ_NUMBER,

  '$(#ScriptError)' as ERROR_ID,

  '$(ScriptError)' as ERROR_NAME,

  '$(ScriptErrorDetails)' as ERROR_DETAIL,

  '$(ScriptErrorList)' as ERROR_LIST,

  now() as ERROR_DATE

resident $(vLoadTable);

/**************************************/

    MaxString(AC) AS "GENERIC_1",
    MaxString(AD) AS "GENERIC_2",
    MaxString(AE) AS "GENERIC_3",
    MaxString(AF) AS "GENERIC_4",
    MaxString(AG) AS "GENERIC_5",
count('*') AS "NB_OF_DUPLICATED"
FROM
[ftp://$(AAA):$(AAA)@$(PATH_ADDRESS)/$(vDirectory)/Prospect.xlsx]
(ooxml, no labels, header is 1 lines, table is DATA)
where (Len("A") > 0)
Group By A, B, '$(vCountry)';
STORE Datas Into (txt); <--- error
$(include=$(vLoadTable));

/******************************************************************************************/

Result:

error inline avec include.PNG

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Insert the code as Marcus suggested, with

$(vError);

that should work. If it doesn't ,please post the script you are using.

-Rob

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The LET statement will reset your error variables.

-Rob

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The CALL will reset the Error variable.

-Rob