Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2016
    Posts
    5

    Unanswered: New to Oracle Programming?

    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.
    Attached Thumbnails Attached Thumbnails Oracle_Query.jpg  

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    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?

  3. #3
    Join Date
    Aug 2016
    Posts
    5
    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.

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    OK, so if you remove that line, what happens?

  5. #5
    Join Date
    Aug 2016
    Posts
    5
    I still got an error...

    See Image
    Attached Thumbnails Attached Thumbnails Oracle_Query.jpg  

  6. #6
    Join Date
    Jun 2004
    Posts
    796
    Provided Answers: 1
    You need to spend some time googling the error message & reading up on it, & then you'll understand why you have the error. Another thread from this forum will help you get started....

    http://www.dbforums.com/showthread.p...se-is-expected


    (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 04:08.
    90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.

  7. #7
    Join Date
    Aug 2016
    Posts
    5
    I figured it out. Not sure why it made a difference but I put the "Open" statement within the IF statement and that work.

  8. #8
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    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.

    Code:
    OPEN RECORDS FOR
    select model,code,def,status
    from producst_v
    where item_type in ('FSH','QSH','SBA')
    AND (MODELNO IS NULL OR MODEL = MODELNO)
    ORDER BY MODEL,DECODE(MODELNO,NULL,NULL,STATUS),CODE;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  9. #9
    Join Date
    Aug 2016
    Posts
    5
    Thanks for the clarification!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •