cancel
Showing results for 
Search instead for 
Did you mean: 

Script Logic

Former Member
0 Kudos

In SQL scripts, how do I specify and capture a to and from selection? For instance, I want to perform calculations based ona data from a category and store it to a different category? If I use %CATEGORY_SET%, it always provides me the source category. My code is listed below:

PROMPT(COPYMOVEINPUT,[%SELECTION%] [%TO_SELECTION%],%CATEGORY_DIM%,)

In my logic, how do I read %TO_SELECTION% and assign it to desination category. I tried the following

*XDIM_MEMBER CATEGORY = %SELECTION% to %TO_SELECTION%

But it assigned category for the new records to be %TO_SELECTION%.

Any ideas is appreciated.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member204026
Active Participant
0 Kudos

You can make use of the script from the standard "move from fact table.dtsx" pakcage. The %SELECTION% and %TOSELECTION% variables in the COPYMOVEINPUT gives out the where clause for the SQL sytax.

<br>

Please note the below extract from the "move from fact table.dtsx" package where you can see that the "Dump Data" (dump and load task) is making use of the SQL syntax created using the %SELECTION% to export the data. Also it makes use of %FACTCONVERSION_INSTRUCTIONS% variable for converting the data to the intended target member.

<br>

Then finally clears and loads the converted data in the system.

<br>

Try this and let me know if this helps. Thanks....

<br><br>

'DEBUG(ON)<BR>PROMPT(RADIOBUTTON,%CLEARDATA%,"Select the method for importing the data from the source file to the destination database",0,{"Merge data values (Imports all records, leaving all remaining records in the destination intact)","Replace && clear data values (Clears the data values for any existing records that mirror each entity/category/time combination defined in the source, then imports the source records)"},{"0","1"})<BR>PROMPT(COPYMOVEINPUT,%SELECTION%,%TOSELECTION%,"Select the members to MOVE and where to",%DIMS%)<BR>PROMPT(MESSAGE,"When this package is running, end user functionality will be affected (i.e. data cannot be sent to the database or incorrect numbers can be retrieved from the database while this package is running)")<BR>INFO(%TEMPFILE1%,%TEMPPATH%%RANDOMFILE%)<BR>INFO(%TEMPFILE2%,%TEMPPATH%%RANDOMFILE%)<BR>TASK(DUMP data,APPSET,%APPSET%)<BR>TASK(DUMP data,APP,%APP%)<BR>TASK(DUMP data,USER,%USER%)<BR>TASK(DUMP data,DATATRANSFERMODE, 2)<BR>TASK(DUMP data,TIMEIDFORMAT,1)<BR>TASK(DUMP data,FILE,%TEMPFILE1%)<BR>TASK(DUMP data,SQL,"Select %FACTDIMS%,sum([signeddata]) as [SIGNEDDATA] from (select %FACTDIMS%,[signeddata] from [tblfact%APP%] where %SELECTION% union all select %FACTDIMS%,[signeddata] from [tblfac2%APP%] where %SELECTION% union allselect %FACTDIMS%,[signeddata]from [tblfactwb%APP%] where %SELECTION% ) as TotalTable Group by %FACTDIMS% OPTION(MAXDOP 1)")<BR>TASK(CONVERT data,INPUTFILE,%TEMPFILE1%)<BR>TASK(CONVERT data,OUTPUTFILE,%TEMPFILE2%)<BR>TASK(CONVERT data,CONVERSIONFILE,%FACTCONVERSION_INSTRUCTIONS%)<BR>TASK(CLEAR SOURCE,APPSET,%APPSET%)<BR>TASK(CLEAR SOURCE,APP,%APP%)<BR>TASK(CLEAR SOURCE,USER,%USER%)<BR>TASK(CLEAR SOURCE,DATATRANSFERMODE,5)<BR>TASK(CLEAR SOURCE,SELECTION,%SELECTION%)<BR>TASK(LOAD AND PROCESS,APPSET,%APPSET%)<BR>TASK(LOAD AND PROCESS,APP,%APP%)<BR>TASK(LOAD AND PROCESS,USER,%USER%)<BR>TASK(LOAD AND PROCESS,DATATRANSFERMODE,1)<BR>TASK(LOAD AND PROCESS,CLEARDATA,%CLEARDATA%)<BR>TASK(LOAD AND PROCESS,SELECTION,%TOSELECTION%)<BR>TASK(LOAD AND PROCESS,PROCESSCUBE,1)<BR>TASK(LOAD AND PROCESS,PROCESSMODE,2)<BR>TASK(LOAD AND PROCESS,FILE,%TEMPFILE2%)

Edited by: Badrish Shriniwas on Nov 11, 2009 2:34 PM

former_member204026
Active Participant
0 Kudos

You can make use of the script from the standard "move from fact.dtsx" pakcage. The %SELECTION% and %TOSELECTION%variables in the COPYMOVEINPUT gives out the where clause for the SQL sytax.

Please note hte below extract from the move from fact.dtsx package where you can see that the "Dump Data" (dump and load task) is making use of the SQL syntax created using the %SELECTION% to export the data. Also it makes use of %FACTCONVERSION_INSTRUCTIONS% variable for converting the data to the intended target member.

Try this and let me know if this helps. Thanks....

'DEBUG(ON)

PROMPT(RADIOBUTTON,%CLEARDATA%,"Select the method for importing the data from the source file to the destination database",0,{"Merge data values (Imports all records, leaving all remaining records in the destination intact)","Replace && clear data values (Clears the data values for any existing records that mirror each entity/category/time combination defined in the source, then imports the source records)"},{"0","1"})

PROMPT(COPYMOVEINPUT,%SELECTION%,%TOSELECTION%,"Select the members to MOVE and where to",%DIMS%)

PROMPT(MESSAGE,"When this package is running, end user functionality will be affected (i.e. data cannot be sent to the database or incorrect numbers can be retrieved from the database while this package is running)")

INFO(%TEMPFILE1%,%TEMPPATH%%RANDOMFILE%)

INFO(%TEMPFILE2%,%TEMPPATH%%RANDOMFILE%)

TASK(DUMP data,APPSET,%APPSET%)

TASK(DUMP data,APP,%APP%)

TASK(DUMP data,USER,%USER%)

TASK(DUMP data,DATATRANSFERMODE, 2)

TASK(DUMP data,TIMEIDFORMAT,1)

TASK(DUMP data,FILE,%TEMPFILE1%)

TASK(DUMP data,SQL,"Select %FACTDIMS%,sum([signeddata]) as [SIGNEDDATA] from (select %FACTDIMS%,[signeddata] from [tblfact%APP%] where %SELECTION% union all select %FACTDIMS%,[signeddata] from [tblfac2%APP%] where %SELECTION% union allselect %FACTDIMS%,[signeddata]from [tblfactwb%APP%] where %SELECTION% ) as TotalTable Group by %FACTDIMS% OPTION(MAXDOP 1)")

TASK(CONVERT data,INPUTFILE,%TEMPFILE1%)

TASK(CONVERT data,OUTPUTFILE,%TEMPFILE2%)

TASK(CONVERT data,CONVERSIONFILE,%FACTCONVERSION_INSTRUCTIONS%)

TASK(CLEAR SOURCE,APPSET,%APPSET%)

TASK(CLEAR SOURCE,APP,%APP%)

TASK(CLEAR SOURCE,USER,%USER%)

TASK(CLEAR SOURCE,DATATRANSFERMODE,5)

TASK(CLEAR SOURCE,SELECTION,%SELECTION%)

TASK(LOAD AND PROCESS,APPSET,%APPSET%)

TASK(LOAD AND PROCESS,APP,%APP%)

TASK(LOAD AND PROCESS,USER,%USER%)

TASK(LOAD AND PROCESS,DATATRANSFERMODE,1)

TASK(LOAD AND PROCESS,CLEARDATA,%CLEARDATA%)

TASK(LOAD AND PROCESS,SELECTION,%TOSELECTION%)

TASK(LOAD AND PROCESS,PROCESSCUBE,1)

TASK(LOAD AND PROCESS,PROCESSMODE,2)

TASK(LOAD AND PROCESS,FILE,%TEMPFILE2%)

sorin_radulescu
Employee
Employee
0 Kudos

Hi,

Don't make the confusion between variable from the package with variable from script logic.

Into you Package you have to use

TASK(Execute formulas,SELECTION,%SELECTIONFILE%)

Where Selection file the system expect to be something like:

category in (...) and time in (..) and entity in (...)

So you have to replace variable 5SELECTION% with what you need.

Regards

Sorin Radulescu