Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…

Topic-icon Question Store query output in variable/parameter

More
20 Jul 2016 15:15 - 20 Jul 2016 15:18 #1 by Prashant.Sangle
Store query output in variable/parameter was created by Prashant.Sangle
Hi Sir,

I have few question
1: I want to load tables from sql server using windows authentication/ AD authentication.

2: Is it possible to store field value of column in variable.
I running one sql operation which has query like

select City,Region,State from Country where flag=1;

It will return only 1 row.
I want to store Value of City ,Region and State in variable varCity, varRegion and varState respectively.
Reason behind doing this is I want to use those variable in different actions at different level.

If yes then Please guide me to achieve it.

Let me know if any query.

Thanks and Regards,
Prashant Sangle
Last edit: 20 Jul 2016 15:18 by Prashant.Sangle.
More
20 Jul 2016 16:28 #2 by Cyril Dussud
Replied by Cyril Dussud on topic Store query output in variable/parameter
Hi,

1) Can you please open another topic if this question is not linked to this topic ?

2) You have several solutions

a. SQLToParameters
You can use the SQLToParameter action that is designed for that.
It creates process parameters from SQL requests, but your request must return only one column/one row
So you'll need to do multiple requests.

Example:

For more information, please refer to the documentation of the action, that can be found in the designer or here:
stambia.org/di-stbar

b. SQL Operation and Scripting Action
You can bind the result of the SQL Operation to use the values, like explained in this article:
stambia.org/doc/104-process/actions/sql/...-and-sql-action-type

To publish variables from the bind result, you can use a scripting action with the following context function:
__ctx__.publishVariable("variablePath","variableValue");

Example:

The advantage of this solution is that you execute the query only once

Does this help ?
Attachments:
More
21 Jul 2016 09:43 #3 by Prashant.Sangle
Replied by Prashant.Sangle on topic Store query output in variable/parameter
Hi,

thanks for response, both solution working as per requirement. 2nd solution is more better for me.
Just one small query if i want use those variable again in another action then How can use it.

because if use syntax %{variable_name}% in another process.
I am getting error
"Program Information" has encountered a problem.
Error during Compilation (compilation.compilationD) Watch console for more details
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.

Console log suggest :
Fatal Error! XPath syntax error at char 6 on line 6 in {$State/tech:columnName}:
[xslt] Variable $State has not been declared

Please guide me to resolve it.

Thanks and Regards,
Prashant Sangle
More
21 Jul 2016 10:39 #4 by Cyril Dussud
Replied by Cyril Dussud on topic Store query output in variable/parameter
Hi,

The %{variable}% syntax is for Metadata Variables and can only be used for it.
In your case it is Session Variables so the syntax to use is ${path_to_session_variable}$
You have an overview of all the syntaxes in this article if needed:
stambia.org/doc/85-variables-and-paramet...f-different-syntaxes