John Francis Ochotorina wrote:When I try to run the project and insert a existing data. It shows nothing. It doesn't print the value that I desire the show. Any help or tips would appreciated!
John Francis Ochotorina wrote:While running my project and entered a existing record. It gives me a null it doesn't print anything. The changes only is the textfield become enabled.
Roel De Nijs wrote:
John Francis Ochotorina wrote:While running my project and entered a existing record. It gives me a null it doesn't print anything. The changes only is the textfield become enabled.
And what happens if you execute the stored procedure on your database using the same id? Does it return the correct value?
Which database and JDBC driver are you using?
John Francis Ochotorina wrote:I still didn't try running it on my Stored Procedure.
Paul Clapham wrote:I haven't used stored procedures in the past so correct me if I'm wrong, but if the query inside the procedure returns no rows then the value of the output parameter should be null, correct? And since the value of the output parameter is in fact null, then one might suspect that the query is returning no rows.
Roel De Nijs wrote:That's clearly illustrated in the code snippet I have posted. Although the stored procedure GetPlayerName doesn't return any rows, the value of the OUT parameter is populated with the appropriate name.
Paul Clapham wrote:Sorry, no it isn't. At least not "clearly". Of course the stored procedure doesn't return any rows, we already know that. But the SELECT query inside the stored procedure might not return any rows -- or should I say it might not select any rows? -- and if that happens then I don't see how the OUT parameter is populated with anything at all. That's what I find unclear about your explanation.
Roel De Nijs wrote:[Now the last statement of this stored procedure is a SELECT statement, so that will result in one row being returned (if the id of course exists in the table).
Paul Clapham wrote:
Roel De Nijs wrote:[Now the last statement of this stored procedure is a SELECT statement, so that will result in one row being returned (if the id of course exists in the table).
And if the ID doesn't exist in the table?
Roel De Nijs wrote:An empty result set will (obviously) be returned.
Paul Clapham wrote:
Roel De Nijs wrote:An empty result set will (obviously) be returned.
Not obviously at all. The original question was one which didn't return a result set. You've changed it to one which does, and then yes, obviously that result set is going to be empty. I see that my question, which I thought was fairly straightforward, isn't being understood. So let me ask a different one. Consider the stored procedure in the original post, the one which doesn't return a result set but instead has an output parameter. And assume that the table it's looking at is empty. Now there's no result set being returned, so obviously an empty result set is not returned. And no value is assigned by the procedure to the output parameter either.
So when the Java code asks for the value of the output parameter, what happens? (1) Null is returned (2) An exception is thrown (3) Something else.
Paul Clapham wrote:So when the Java code asks for the value of the output parameter, what happens? (1) Null is returned (2) An exception is thrown (3) Something else.
The selected values are assigned to the variables. The number of variables must match the number of columns. The query should return a single row. If the query returns no rows, a warning with error code 1329 occurs (No data), and the variable values remain unchanged. If the query returns multiple rows, error 1172 occurs (Result consisted of more than one row). If it is possible that the statement may retrieve multiple rows, you can use LIMIT 1 to limit the result set to a single row.
John Francis Ochotorina wrote:I changed my OUT parameter to myName instead of NAME. I notice that NAME I think is a reserved keyword because the color the syntax is blue. So I replace with myName. And successfully! I can retrieve my values using Stored Procedure via Call syntax. Sample code and screenshot below.
John Francis Ochotorina wrote:What I'm trying to do I search a existing record in the textfield. It will print out the values to the Section Name: __________ textfields. If the value's is existing. If not the Message Dialog will print out to the user if the name is not existing. Thank you responding.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |