invalid cursor state SQLPrepare (after select)

Posted on 2005-04-15
Medium Priority
Last Modified: 2007-11-27
Hi experts,

I perform 2 statements:  Select and then insert.

The select works fine and in my SQLPrepare(hStatement) for the insert, I get the error.

If I don't do my select, my SQLPrepare and execute on my insert works fine.

Any ideas???

Thanks - and 500 points to the person who helps!  =)

Question by:mikexpert
  • 3
  • 2
LVL 33

Expert Comment

ID: 13792969
This doesn't look like a problem with MySQL. You might get a better answer in the appropiate language TA, such as MFC.

Author Comment

ID: 13793015
yep - thanks...

Author Comment

ID: 13795535
ok snoyes_jw - here's the real issue:

I execute two queries:  one is a select and the other following one is an insert.

The SELECT works fine but then I get the error in in my SQLPrepare for the INSERT.  If I omit the SELECT, I don't get an error in the INSERT...

Any ideas???

Thanks so much... and you're already gonna get the points for this question... (promise).. If you're able to answer this new one, I've posted it in two places - you'll get a total of 1500 points (this question plus two of the new one I'm asking you)...  (I don't really know if you care about points - but I hope you do!)   =)

Thanks a bundle!

LVL 33

Accepted Solution

snoyes_jw earned 1500 total points
ID: 13795900
SQLPrepare is not a MySQL thing; it is specific to some programming language(s), and not any that I know.  You haven't even mentioned which language you are using, and you might have confused MySQL with the Microsoft SQL or SQL Server areas.

A few moments on Google reveals the following, any of which no doubt mean more to you than they do to me:

- You cannot reuse the Statement Handle when the cursor is in use in this memory table.  Try to free the statement handle using some sort of "FreeStatement" function.

- SELECT statements return a result set; INSERTS do not.  Perhaps using the SELECT first sets the handler to expect a result set; when none is returned with the INSERT, the error is raised.

- If you're really using SQL Server, take a look here: http://www.windowsitpro.com/Article/ArticleID/43010/43010.html

Incidentally, in an attempt to curb "point inflation", the maximum legal points for any one question is 500.  That includes asking the same question in multiple areas.

I recommend that you post in the Community Support area and ask a moderator to delete and refund this question, and then post in the topic area related to whatever programming language you are using.

Author Comment

ID: 13820622
Thanks for the help

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question