<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: WFA function to run mysql query : The solution in Active IQ Unified Manager Discussions</title>
    <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142474#M26016</link>
    <description>&lt;P&gt;I am using EDM pack and trying to use this functionality&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below query works fine without function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where nasmapping is a tab in the edm excelsheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt; nasmapping.netappcluster,&lt;BR /&gt; nasmapping.uniqueindentification &lt;BR /&gt;FROM&lt;BR /&gt; edm.nasmapping &lt;BR /&gt;WHERE&lt;BR /&gt; Location= '${Location}' &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when i tried to use same in fucntion getting issues, not able to access property&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function getclusterfromlocation(Location)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;import java.sql.*; &lt;BR /&gt;Connection con=DriverManager.getConnection( &lt;BR /&gt;"jdbc:mysql://localhost:3306/","wfa","Wfa123");&lt;/P&gt;
&lt;P&gt;//Connect to local WFA DB using the built-in credentials&lt;/P&gt;
&lt;P&gt;String query='SELECT nasmapping.netappcluster, nasmapping.uniqueindentification FROM edm.nasmapping WHERE Location= \'' + Location + '\'' ; &lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Statement stmt=con.createStatement(); &lt;BR /&gt;ResultSet rs=stmt.executeQuery(query);&lt;/P&gt;
&lt;P&gt;//Query is executed, loop over every row and fetch the columns.&lt;/P&gt;
&lt;P&gt;String s=''; &lt;BR /&gt;while(rs.next())&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;s = s + rs.getString(1) + ' | ' + rs.getString(2) + '\n';&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;return s;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;appriciate any help&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 15:23:49 GMT</pubDate>
    <dc:creator>CAPATEL_NET1984</dc:creator>
    <dc:date>2018-08-31T15:23:49Z</dc:date>
    <item>
      <title>WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/129183#M23242</link>
      <description>&lt;P&gt;&amp;nbsp;There have been numerous asks for a WFA funtion to execute mysql queries. Functions have a great advantage that it can execute during a workflow planning and hence result can be seen during a preview.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is a sample function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WFA -&amp;gt; Designer -&amp;gt; Functions. Add a new fucntion with the below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function executeMysqlQuery(query)

{

import java.sql.*;  

&lt;FONT color="#FF0000"&gt;//Connect to local WFA DB using the built-in credentials&lt;/FONT&gt;

Connection con=DriverManager.getConnection(  
"jdbc:mysql://localhost:3306/","wfa","Wfa123");

Statement stmt=con.createStatement();  
ResultSet rs=stmt.executeQuery(query);  

&lt;FONT color="#FF0000"&gt;//Query is executed, loop over every row and fetch the column.&lt;/FONT&gt;

String s="DATABASE\n----------\n"; 
while(rs.next())
{

s = s + rs.getString('Database') + '\n';

}

return s;
}&lt;/PRE&gt;&lt;P&gt;Example execution for query 'show databases;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="function_mysql.png" style="width: 645px;"&gt;&lt;img src="https://community.netapp.com/t5/image/serverpage/image-id/6967iCC0A332489F911D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="function_mysql.png" alt="function_mysql.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you can execute any query which the built-in credentials has been granted permission to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This function can also be used to run queries on OCUM mysql DB using the OCUM Database credentials. So you can do resource selection directly from OCUM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sinhaa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 15:18:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/129183#M23242</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2025-06-04T15:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/129344#M23298</link>
      <description>&lt;P&gt;I'm seeing some people are having difficulty in using this fuction. I'll provide some help in using it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Try not to pass the the entire query as parameter to the function. This is not going to be as easy as it was for me in the above example. My query was extremely simple. So pass the variables you want use in your query and then construct your query string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Queries have single quotes in them, so you need to escape them with a back-slash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. You can get columns by respective positions on method getString() and not necessarily using the column name. You can also use getInt() to get Integer columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose your query is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Select cm_storage.vserver.name AS 'VS NAME',&lt;BR /&gt;cm_storage.vserver.admin_state
from cm_storage.vserver, cm_storage.cluster
where
cm_storage.cluster.primary_address = '10.20.30.40'
AND
cm_storage.vserver.name = 'VS001'&lt;/PRE&gt;&lt;P&gt;So my variables are &lt;EM&gt;Cluster Primary Address&lt;/EM&gt; and &lt;EM&gt;Vserver name&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so my function can look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function executeMysqlQuery(cluster_ip, vs_name)

{

import java.sql.*;  

//Connect to local WFA DB using the built-in credentials

String query='Select cm_storage.vserver.name AS \'VS NAME\',
cm_storage.vserver.admin_state
from cm_storage.vserver, cm_storage.cluster
where
cm_storage.cluster.primary_address = \'' + cluster_ip + '\'
AND
cm_storage.vserver.name = \'' + vs_name + '\'';


Connection con=DriverManager.getConnection(  
"jdbc:mysql://localhost:3306/","wfa","Wfa123");



Statement stmt=con.createStatement();  
ResultSet rs=stmt.executeQuery(query);  

//Query is executed, loop over every row and fetch the columns.

String s=''; 
while(rs.next())
{

s = s + rs.getString(1) + ' | ' + rs.getString(2) + '\n';

}

return s;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 13:43:36 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/129344#M23298</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2017-06-13T13:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/130244#M23530</link>
      <description>&lt;P&gt;For OCUM5.X (DFM) 7-mode users, you can use the below function. WFA bundles, Sybase JConnector 3 device driver.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function executeSybaseQuery(query)

{

import java.sql.*;
import com.sybase.jdbcx.*;

SybDriver sybDriver = (SybDriver) Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();

Connection con = DriverManager.getConnection("jdbc:sybase:Tds:10.228.154.88:2638/monitordb", "sinhaa", "sinhaa");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM dfm.disks");
rs.next();
a = rs.getString(1);

return a;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These functions are very useful to get data which is NOT cached by WFA acquistion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sinhaa&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 09:32:13 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/130244#M23530</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2017-04-19T09:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131771#M23908</link>
      <description>&lt;P&gt;First of all Thank you for your post.&lt;/P&gt;&lt;P&gt;I want to create a function with a sql query to get the Snapshot Name back from a specific date which is a user input.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My SQL query against the WFA Db is working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SELECT&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.name AS 'name'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;cm_storage_smsv.snapshot&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;WHERE&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.cluster = '${ClusterName}'+'domainname.xxx'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND snapshot.vserver = '${VserverName}'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND snapshot.volume = '${Volumes}'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND snapshot.timestamp LIKE '${clone_date}%'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ORDER BY&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;timestamp DESC limit 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But it is not work as function in WFA&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Idea what is wrong here, i'm not good in these thing, maybe it is very easy for you&lt;/P&gt;&lt;P&gt;Error Message:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;[Error: failed to access property: executeMysqlQuery(xxxx-baas01, xx_01849_gold_01, xx_01849_gold_01_root, 2017-06-07): [Error: failed to access property: xxxx: [Error: could not access property: xxx]&lt;BR /&gt;[Near : {... Unknown ....}]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Your first example with the main function and input 'show databases'; is working fine.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The error was because of wrong call without '' .&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 11:38:52 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131771#M23908</guid>
      <dc:creator>MaGei</dc:creator>
      <dc:date>2017-06-12T11:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131773#M23909</link>
      <description>&lt;P&gt;Meanwhile i Got no errors but also no result back:&lt;/P&gt;&lt;P&gt;funtion:&lt;/P&gt;&lt;P&gt;--------------------------------------&lt;/P&gt;&lt;P&gt;f&lt;STRONG&gt;unction executeMysqlQuery(clu_name, vs_name, vol_name, clone_date)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import java.sql.*;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;String query='Select snapshot.name AS \'name\'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from cm_storage_smsv.snapshot,cm_storage.cluster&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;cluster.primary_address = snapshot.cluster&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.cluster LIKE \'' + clu_name + '\'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.vserver = \'' + vs_name + '\'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.volume = \'' + vol_name + '\'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;snapshot.timestamp = \'' + clone_date + '\'';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;//Connect to local WFA DB using the built-in credentials&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Connection con=DriverManager.getConnection( &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"jdbc:mysql://localhost:3306/","wfa","Wfa123");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Statement stmt=con.createStatement(); &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ResultSet rs=stmt.executeQuery(query);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;//Query is executed, loop over every row and fetch the column.&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;String s; 
while(rs.next())
{

s = s + rs.getString(1) + ' | ' + rs.getString(2) + '\n';

}

return s;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-------------------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Call the function with -&amp;gt;&amp;nbsp;executeMysqlQuery('CLuster', 'VServer', 'Volume', 'Snapshotdate') and then I got when i click Test Function only an empty &amp;nbsp;Result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint or idea what is wrong with my function.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 11:35:35 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131773#M23909</guid>
      <dc:creator>MaGei</dc:creator>
      <dc:date>2017-06-12T11:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131836#M23916</link>
      <description>&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/46894"&gt;@MaGei&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marcel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will have to work, just need to figure out the right escaping the quotes etc. I'm trying your query, will update&amp;nbsp;you the fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sinhaa&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 12:46:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131836#M23916</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2017-06-13T12:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131838#M23918</link>
      <description>&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/46894"&gt;@MaGei&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To debug this you have a return statement after creating your query string which retruns the query itself.&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;String query='Select snapshot.name AS \'name\'
from cm_storage_smsv.snapshot,cm_storage.cluster
where
cluster.primary_address = snapshot.cluster
AND
snapshot.cluster LIKE \'' + clu_name + '\'
AND
snapshot.vserver = \'' + vs_name + '\'
AND
snapshot.volume = \'' + vol_name + '\'
AND
snapshot.timestamp = \'' + clone_date + '\'';

&lt;FONT color="#FF0000"&gt;return query;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;This shall give you your query as how it will appear for execution. Try this final query on your SQL client and see you are getting the right results and not empty rows or any error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Once staisfied that query is fine, remove the &lt;FONT color="#FF0000"&gt;return query&lt;/FONT&gt; from above and Make&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;String s=''; &lt;/PRE&gt;&lt;P&gt;Else I see its will add a word null in the beginning of the first row. I've updated my original post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Since you are returning only 1 column, you can do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;s = s + rs.getString(1) + '\n';&lt;/PRE&gt;&lt;P&gt;I'm adding the rows as one string because, one string is all I can return. Breaking it back to rows etc, can be done later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this and let me know if this help you resolve it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sinhaa&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 13:42:42 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/131838#M23918</guid>
      <dc:creator>sinhaa</dc:creator>
      <dc:date>2017-06-13T13:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/133849#M24285</link>
      <description>&lt;P&gt;Hi Sinhaa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you very much for your help. I was not available longer time. Therefore i only now checked it.&lt;/P&gt;&lt;P&gt;I found a solution yes it was the way of escaping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help and effort.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Marcel&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 09:58:15 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/133849#M24285</guid>
      <dc:creator>MaGei</dc:creator>
      <dc:date>2017-08-23T09:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/139236#M25379</link>
      <description>&lt;P&gt;Escaping your query like this is rediculous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this method instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="line number1 index0 alt2"&gt;&lt;CODE class="java plain"&gt;def getSetting(name,type)&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number2 index1 alt1"&gt;&lt;CODE class="java plain"&gt;{&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number3 index2 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number4 index3 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;import&lt;/CODE&gt; &lt;CODE class="java plain"&gt;java.sql.*;&amp;nbsp;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number5 index4 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number6 index5 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java comments"&gt;//Connect to local WFA DB using the built-in credentials&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number7 index6 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number8 index7 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number9 index8 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;String query=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="java string"&gt;'SELECT * FROM config.settings WHERE name = ? and type = ?'&lt;/CODE&gt;&lt;CODE class="java plain"&gt;;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number10 index9 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number11 index10 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;Connection con=DriverManager.getConnection(&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number12 index11 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java string"&gt;"jdbc:&lt;A href="mysql://localhost:3306/" target="_blank"&gt;mysql://localhost:3306/&lt;/A&gt;"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;,&lt;/CODE&gt;&lt;CODE class="java string"&gt;"wfa"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;,&lt;/CODE&gt;&lt;CODE class="java string"&gt;"Wfa123"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;);&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number13 index12 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number14 index13 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;PreparedStatement stmt=con.prepareStatement(query);&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number15 index14 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;stmt.setString(&lt;/CODE&gt;&lt;CODE class="java value"&gt;1&lt;/CODE&gt;&lt;CODE class="java plain"&gt;, name);&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number16 index15 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;stmt.setString(&lt;/CODE&gt;&lt;CODE class="java value"&gt;2&lt;/CODE&gt;&lt;CODE class="java plain"&gt;, type);&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number17 index16 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;ResultSet rs=stmt.executeQuery();&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number18 index17 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number19 index18 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;if&lt;/CODE&gt;&lt;CODE class="java plain"&gt;(rs.next()){&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number20 index19 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;return&lt;/CODE&gt; &lt;CODE class="java plain"&gt;(rs.getString(&lt;/CODE&gt;&lt;CODE class="java string"&gt;'value'&lt;/CODE&gt;&lt;CODE class="java plain"&gt;));&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number21 index20 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number22 index21 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;}&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number23 index22 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number24 index23 alt1"&gt;&lt;CODE class="java plain"&gt;}&lt;/CODE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Mar 2018 13:53:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/139236#M25379</guid>
      <dc:creator>mirko</dc:creator>
      <dc:date>2018-03-29T13:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142474#M26016</link>
      <description>&lt;P&gt;I am using EDM pack and trying to use this functionality&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;below query works fine without function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where nasmapping is a tab in the edm excelsheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt; nasmapping.netappcluster,&lt;BR /&gt; nasmapping.uniqueindentification &lt;BR /&gt;FROM&lt;BR /&gt; edm.nasmapping &lt;BR /&gt;WHERE&lt;BR /&gt; Location= '${Location}' &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when i tried to use same in fucntion getting issues, not able to access property&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function getclusterfromlocation(Location)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;import java.sql.*; &lt;BR /&gt;Connection con=DriverManager.getConnection( &lt;BR /&gt;"jdbc:mysql://localhost:3306/","wfa","Wfa123");&lt;/P&gt;
&lt;P&gt;//Connect to local WFA DB using the built-in credentials&lt;/P&gt;
&lt;P&gt;String query='SELECT nasmapping.netappcluster, nasmapping.uniqueindentification FROM edm.nasmapping WHERE Location= \'' + Location + '\'' ; &lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Statement stmt=con.createStatement(); &lt;BR /&gt;ResultSet rs=stmt.executeQuery(query);&lt;/P&gt;
&lt;P&gt;//Query is executed, loop over every row and fetch the columns.&lt;/P&gt;
&lt;P&gt;String s=''; &lt;BR /&gt;while(rs.next())&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;s = s + rs.getString(1) + ' | ' + rs.getString(2) + '\n';&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;return s;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;appriciate any help&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 15:23:49 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142474#M26016</guid>
      <dc:creator>CAPATEL_NET1984</dc:creator>
      <dc:date>2018-08-31T15:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142475#M26017</link>
      <description>&lt;P&gt;attached is a screenshot of excel&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 15:27:12 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142475#M26017</guid>
      <dc:creator>CAPATEL_NET1984</dc:creator>
      <dc:date>2018-08-31T15:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142476#M26018</link>
      <description>&lt;P&gt;Don't escape, but use parameters.&lt;/P&gt;
&lt;P&gt;Use "?" (questionmark) as placeholder&lt;/P&gt;
&lt;P&gt;and use thep prepare statement and setstring methodes.&amp;nbsp; I assume that if your variable is not a string, there wil also be setinteger, setlong, setdate, ... to be verified&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="line number1 index0 alt2"&gt;&lt;CODE class="java plain"&gt;def getSetting(name,type)&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number2 index1 alt1"&gt;&lt;CODE class="java plain"&gt;{&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number3 index2 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number4 index3 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;import&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="java plain"&gt;java.sql.*;&amp;nbsp;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number5 index4 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number6 index5 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java comments"&gt;//Connect to local WFA DB using the built-in credentials&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number7 index6 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number8 index7 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number9 index8 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;String query=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE class="java string"&gt;'SELECT * FROM config.settings WHERE name = ? and type = ?'&lt;/CODE&gt;&lt;CODE class="java plain"&gt;;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number10 index9 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number11 index10 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;Connection con=DriverManager.getConnection(&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number12 index11 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java string"&gt;"jdbc:&lt;A href="mysql://localhost:3306/" target="_blank" rel="nofollow noopener noreferrer"&gt;mysql://localhost:3306/&lt;/A&gt;"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;,&lt;/CODE&gt;&lt;CODE class="java string"&gt;"wfa"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;,&lt;/CODE&gt;&lt;CODE class="java string"&gt;"Wfa123"&lt;/CODE&gt;&lt;CODE class="java plain"&gt;);&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number13 index12 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number14 index13 alt1"&gt;&lt;FONT color="#FF0000"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;PreparedStatement stmt=con.prepareStatement(query);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="line number15 index14 alt2"&gt;&lt;FONT color="#FF0000"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;stmt.setString(&lt;/CODE&gt;&lt;CODE class="java value"&gt;1&lt;/CODE&gt;&lt;CODE class="java plain"&gt;, name);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="line number16 index15 alt1"&gt;&lt;FONT color="#FF0000"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;stmt.setString(&lt;/CODE&gt;&lt;CODE class="java value"&gt;2&lt;/CODE&gt;&lt;CODE class="java plain"&gt;, type);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="line number17 index16 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;ResultSet rs=stmt.executeQuery();&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number18 index17 alt1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number19 index18 alt2"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;if&lt;/CODE&gt;&lt;CODE class="java plain"&gt;(rs.next()){&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number20 index19 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java keyword"&gt;return&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE class="java plain"&gt;(rs.getString(&lt;/CODE&gt;&lt;CODE class="java string"&gt;'value'&lt;/CODE&gt;&lt;CODE class="java plain"&gt;));&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number21 index20 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number22 index21 alt1"&gt;&lt;CODE class="java spaces"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;CODE class="java plain"&gt;}&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="line number23 index22 alt2"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="line number24 index23 alt1"&gt;&lt;CODE class="java plain"&gt;}&lt;/CODE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 Aug 2018 15:28:38 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142476#M26018</guid>
      <dc:creator>mirko</dc:creator>
      <dc:date>2018-08-31T15:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: WFA function to run mysql query : The solution</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142477#M26019</link>
      <description>&lt;P&gt;&lt;A href="https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html&amp;nbsp;" target="_blank"&gt;https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above url is the official docs for this functionality&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 15:30:23 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/WFA-function-to-run-mysql-query-The-solution/m-p/142477#M26019</guid>
      <dc:creator>mirko</dc:creator>
      <dc:date>2018-08-31T15:30:23Z</dc:date>
    </item>
  </channel>
</rss>

