cancel
Showing results for 
Search instead for 
Did you mean: 

How to Save SQL query template as a text file

Former Member
0 Kudos

Hi,

How to save a SQL query template in my server as a Text file?? I tried using Text saver but it is not getting saved in the path specified.

Sweety

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you really want to save the query template ? Or the query results?

Have you checked if the input to the text saver is correct? And the output path is correct?

Are there any errors when executing the text saver action?

Michael

Former Member
0 Kudos

Hi,

I want to save the Query Template... there is no Error

Sweety

agentry_src
Active Contributor
0 Kudos

If you are trying to save the sql script as a text file, use the query property of the SQL Query action block and map it to the Text Saver action block. If you are trying to store more information, perhaps concatenating the properties using some sort of delimiter or field name (preceding the contents) would also work.

Regards,

Mike

Former Member
0 Kudos

You may also save the whole query template file. Load the query xml file (file extension "tq*", depending on the query type) with a XML or Text Loader, and save it. However, the query xml is not very readable without MII.

Michael

Former Member
0 Kudos

Hi,

When you say Query Property do you mean Query Template?? I am using 11.5.1 version.

I'll try and get back to you

Sweety

agentry_src
Active Contributor
0 Kudos

Hi Sweety,

In the transaction editor (for business logic), add your query template to a transaction. Add a Tracer after and link the Query property of the SQL Query action block to the Message property of the transaction. Run the transaction and you will see your Action Block's sql script as the message from the Tracer. You can do the same with the Server property, SD and ED, etc.

Also if you wish to dynamically load the sql script into the query, you can do that at run time by linking a script source to the query property. Useful to have if you have to use a complex expression to dynamically create your script. This sometimes occurs when you have multiple filtering inputs from a webpage and you can reduce the number of tables in a complex join when the fields are left empty. Normally this would be done as a way to improve the performance of the query.

Hopefully this is clear. If not I can probably provide some sample expressions.

Regards,

Mike

Former Member
0 Kudos

Hi

Michael Otto,

If I use XML or Text loader its not getting the query template as input...

Michael Appleby,

In the Tracer the path of the Query template is showing but it is not getting saved in the system.

Sweety

agentry_src
Active Contributor
0 Kudos

Hi Sweety,

You have linked the Query Template property, not the Query property. Scroll down about 2/3 of the way through the properties (it is right after all the Param properties).

Good luck,

Mike

Answers (1)

Answers (1)

erik_schrampf
Active Participant
0 Kudos

I have one question what is your use case/reason for doing this? Are you trying to build some type of content mgmt system or save backups or your content? If so in version 12.1 MII can use NWDI for this.

Former Member
0 Kudos

Hi Eric,

I am new to xMII...I am learning... and I am using 11.5.1 version

Sweety

Former Member
0 Kudos

Hi Michael Appleby,

Yes, now I assigned it to the Query property and It is getting saved.

Thank you

In case if have to save the Results of SQL Query what to do?? If i use XML or Text Saver it is getting saved along with the tags.

like

<Name>ABC</Name>

Sweety

agentry_src
Active Contributor
0 Kudos

Hi Sweety,

You can save the results either way, but without doing post processing, it will be in an xml format. So the tags will come along with the data. If you wish you can extract the data and put it into some other format (csv, for example), but if you work much with MII, you will quickly get used to working with xml data. It is the native data format used within MII.

Regards,

Mike