Welcome Guest! Log in

Topic-icon Question Scripting and Session Variables

  • Yassine HAMMOUCHE
  • Yassine HAMMOUCHE's Avatar Topic Author
  • Offline
More
25 Feb 2015 14:39 #1 by Yassine HAMMOUCHE
Scripting and Session Variables was created by Yassine HAMMOUCHE
Hello,

I have a basic mapping which populate a table. I want to create a process to store into a log table the name of the target table, the number of inserted rows, the mapping name, .... And finaly only put this process behind one or more mapping, in order to use only one process to log the flows.

I could use the stambia log tables, but i believe that all those informations are available into the sessions variables.

So i tried to do something like :

insert into %x{$LOG_TABLE/tech:physicalPath()}x%
values (
'${/CORE_SESSION_ID}$',
null,
%e(rhino){__ctx__.sumVariable("SQL_STAT_INSERT","../MAP_TST_RLA_100")}e(rhino)%,
'${../MAP_TST_RLA_100/CORE_BEGIN_DATE}$',
'${../MAP_TST_RLA_100/CORE_END_DATE}$',
'${../MAP_TST_RLA_100/CORE_DURATION}$'
);

It is ok, but in this example i need to put manually the mapping name (how to do it automatically ??), so i created a variable to store the mapping name and i tried this one :

insert into %x{$LOG_TABLE/tech:physicalPath()}x%
values (
'${/CORE_SESSION_ID}$',
null,
%e(rhino){__ctx__.sumVariable("SQL_STAT_INSERT","../%{V_MAP_NAME}%")}e(rhino)%,
'${../%{V_MAP_NAME}%/CORE_BEGIN_DATE}$',
'${../%{V_MAP_NAME}%/CORE_END_DATE}$',
'${../%{V_MAP_NAME}%/CORE_DURATION}$'
);

It is ok for the line with "rhino..." but not possible for the others.

Is there a way to do this ?

How can i know the different methods like "sumVariable" that i can use ? Cause it it should be possible to do it only with scripting. I found nothing into the documentation

Thank a lot

Please Log in or Create an account to join the conversation.

More
25 Feb 2015 18:12 #2 by Nicolas Verscheure
Replied by Nicolas Verscheure on topic Scripting and Session Variables
As far as I know, it is not possible to dynamise the path to the variable.
An alternative solution is to use the getVariableTreeByName function (describe in Stambia Designer Help : Stambia > Designer User's Guide > Working with Processes
) :

%e(groovy){
def a = ""
def tree = __ctx__.getVariableTreeByName("CORE_BEGIN_DATE","../%{V_MAP_NAME}%",true)
if (tree.size() != 0) {
	def es=tree.entrySet()
	es.each{
	  	a = a+ "-- ACTION --> " + it.key + "\n"
	  	a = a+ it.value.getValue() +"\n\n"
	}
	println("a = " + a);
}
}e(groovy)%

Please Log in or Create an account to join the conversation.

More
27 Feb 2015 14:35 #3 by Thomas BLETON
Replied by Thomas BLETON on topic Scripting and Session Variables
You can also use this method:
%e(rhino){__ctx__.getVariableValue("../Mapping2/CORE_BEGIN_DATE")}e(rhino)%

Please Log in or Create an account to join the conversation.

  • Yassine HAMMOUCHE
  • Yassine HAMMOUCHE's Avatar Topic Author
  • Offline
More
27 Feb 2015 16:30 #4 by Yassine HAMMOUCHE
Replied by Yassine HAMMOUCHE on topic Scripting and Session Variables
Parfait !! Merci beaucoup

Please Log in or Create an account to join the conversation.

More
27 Feb 2015 16:36 #5 by Nicolas Verscheure
Replied by Nicolas Verscheure on topic Scripting and Session Variables

Thomas BLETON wrote: You can also use this method:
%e(rhino){__ctx__.getVariableValue("../Mapping2/CORE_BEGIN_DATE")}e(rhino)%


Great !

Note for later : add this function in the Stambia Designer's Help.

Please Log in or Create an account to join the conversation.

More
27 Feb 2015 16:46 #6 by Thomas BLETON
Replied by Thomas BLETON on topic Scripting and Session Variables
Yes Nicolas, we will get this documented :)

Please Log in or Create an account to join the conversation.