I am new to Oracle programming and I'm in the process of writing a new and simple query. However, I'm getting an error that I don't know how to resolve. Just not sure what I'm doing wrong. I have attached a screenshot.
A fair bit of time, the syntax error is not with the line that is highlighted, but the line before. Looking at the line before, it seems you have a bit of a dangling statement. What are you opening the records for?
I'm not exactly sure what that 'Open' statement is doing. I kinda copied all the code except the query from another query. All I'm trying to do is return a set of data that will populate a DataGridView in a VB.Net application.
(The error codes are useful, so use them! You're not the first one who's new to programming, and you're not the first one to get an error - there are many articles on the internet that will tell you how to resolve them, just google the error code and/or error message. By all means ask if you're stuck, but don't be afraid to try working it out for yourself first )
Last edited by cis_groupie; 08-31-16 at 03:08.
90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.
CORRECT. Nice catch. When you define a ref_cursor you are opening a query and passing a memory pointer to the calling program. The calling program then pulls in the result of the cursor. By not having the open clause as part of the query, the procedure has no open ref_cursor to return a pointer to. You also made it overly complex. In oracle you can have the following code in a query so there would be no need for the if statement. You will also notice that I am using the parameter MODELNO directly. There is no need to copy the parameter to an internal variable unless you plan to modify the value.
OPEN RECORDS FOR
where item_type in ('FSH','QSH','SBA')
AND (MODELNO IS NULL OR MODEL = MODELNO)
ORDER BY MODEL,DECODE(MODELNO,NULL,NULL,STATUS),CODE;
You do not need a parachute to skydive. You only need a parachute to skydive twice.