khaleesi
Member
Hi there,
we are trying to get first element of the dataset retrieved from SQL. and for all the tries I have done, I am not able to get first value in the array.
here is script we are using for Database Connector.
-------------------------
import groovy.transform.CompileStatic;
import com.oracle.e1.common.OrchestrationAttributes;
import java.sql.*;
@CompileStatic
HashMap<String, Object> main(OrchestrationAttributes orchAttr, Connection sqlConnection, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();
//Define the select statement
def selectStmt = "select RTID from F55NDKID where KY <> RTID";
def firstDockID = "";
//Create a prepared statement with the SQL
PreparedStatement preparedStmt = sqlConnection.prepareStatement(selectStmt);
//Execute the query returning the result set
ResultSet resultSet = preparedStmt.executeQuery();
//Use the helper to set the records from the result set to the array variable
returnMap = orchAttr.mapResultSetToDataSet(resultSet, "nextDockID");
List<String> dataset = (List<String>) returnMap.get("RTID")
firstDockID = dataset.get(0);
//Close the result and statement
resultSet.close();
preparedStmt.close();
return returnMap;
}
------------------------
What am I doing wrong here? even ChatGPT is no help... Haha
Any input is really appreciated.
Thanks,
Khaleesi of the Great Grass
we are trying to get first element of the dataset retrieved from SQL. and for all the tries I have done, I am not able to get first value in the array.
here is script we are using for Database Connector.
-------------------------
import groovy.transform.CompileStatic;
import com.oracle.e1.common.OrchestrationAttributes;
import java.sql.*;
@CompileStatic
HashMap<String, Object> main(OrchestrationAttributes orchAttr, Connection sqlConnection, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();
//Define the select statement
def selectStmt = "select RTID from F55NDKID where KY <> RTID";
def firstDockID = "";
//Create a prepared statement with the SQL
PreparedStatement preparedStmt = sqlConnection.prepareStatement(selectStmt);
//Execute the query returning the result set
ResultSet resultSet = preparedStmt.executeQuery();
//Use the helper to set the records from the result set to the array variable
returnMap = orchAttr.mapResultSetToDataSet(resultSet, "nextDockID");
List<String> dataset = (List<String>) returnMap.get("RTID")
firstDockID = dataset.get(0);
//Close the result and statement
resultSet.close();
preparedStmt.close();
return returnMap;
}
------------------------
What am I doing wrong here? even ChatGPT is no help... Haha
Any input is really appreciated.
Thanks,
Khaleesi of the Great Grass