SQL Error

SQL error -514 is being returned in a program. Definition says the cursor is not prepared. Please explain the meaning of this and what I need to look for to fix it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What environment are you using, and do you have a sample of your source code, or at least the SQL statements?
penericAuthor Commented:
sql is being used in cobol/mvs enviroment. return code is generated in a call statement.
I'm assuming you are using DB2. It's been a while so if my suggestion doesn't help, let me know and I'll look into it in more detail.

Before you open a cursor, you need to define it so it knows what parameters are being passed and what the result set returned will look like. So before you open a cursor, you need to prepare it. Look at where you are getting the open cursor. There should be a name that refers to a cursor definition and there should be a prepare somewhere in the program for that as well.

Verify there is a prepare statement, that it's being executed.

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

DB2/400 Implementation (which should be similar to DB" on MVS) requires that you issue the following in the correct sequence. (You might also want to use some whenever clauses as well)

'Declare C1 Cursor for Select * from MYtable ... (etc etc)

Open C1...

Fetch C1.....

etc etc
penericAuthor Commented:
Thank you for the information. I am trying to run down the declaration. It sounds like this will be the answer to my problem
Who gets the points?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.