Ad
Declare Output Parameter And Select It Like A Result Of Query, T-SQL, JAVA
I have a sql query:
DECLARE @output varchar(100) exec map.GetGenreStatusName 'Genre', '2018-03-16', @output OUTPUT select @output;
It returns smth like:
<anonymous>
Completed
I need take it from java code. My variant is:
final String statusCheck = "DECLARE @output varchar(100) exec map.GetGenreProtocolStatusName ?, ?, ? OUTPUT select @output;";
List<String> chekList = new ArrayList<>();
try (CallableStatement statement = connection.prepareCall(statusCheck)) {
statement.setString(1, packageName);
statement.setDate(2, date);
statement.registerOutParameter("output", 12);
statement.execute();
ResultSet checkStatusResult = (ResultSet) statement.getObject(0);
chekList.add(checkStatusResult.getString(0));
}
How do I take this string "Completed" from select to my list? I tried different variant with "?" setting and registering in/out parameters, I tried execute it like a query, but nothing.
Ad
Answer
Have changed a string to:
final String statusCheck = "exec map.GetGenreProtocolStatusName ?, ?, ?;";
Code to:
final Connection connection = DriverManager.getConnection(dataSourceUrl, dbProperties);
List<TvScheduleInterval> scheduleIntervals = new ArrayList<>();
List<String> checkList = new ArrayList<>();
try (CallableStatement statement = connection.prepareCall(statusCheck)) {
statement.setString(1, packageName);
statement.setDate(2, date);
statement.registerOutParameter(3,12);
statement.execute();
checkList.add(statement.getString(3));
}
Working now.
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad