Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error odbc load fetch without select

    Hi,

    I’m having some issues with ODBC in Stata. I have been using it extensively without problem until recently I started having problems loading data. The error appears when I try to load sequentially many datasets. The command I use is:

    odbc load in 1/l, table(“`sometable'") conn("DSN=somedsn;UID=someuser;PWD=somepassword") sqlshow noquote

    It usually works fine during the loop (the loop is over `sometable’), until I get the error message:

    The ODBC driver reported the following diagnostics
    [MySQL][ODBC 5.3(a) Driver][mysqld-5.7.21]Fetch without a SELECT
    SQLSTATE=24000

    I have been trying a whole set of different variants of this command I found online

    odbc load in 1/l, exec(`"SELECT * FROM sometable"') clear conn("DSN=somedsn;UID=someuser;PWD=somepassword”)
    odbc load in 1/l, exec("SELECT * FROM sometable") clear conn("DSN=somedsn;UID=someuser;PWD=somepassword”)
    odbc load in 1/10, exec(`"SELECT * FROM sometable"') clear conn("DSN=somedsn;UID=someuser;PWD=somepassword”)

    but nothing seems to work. Any suggestion would be more than appreciated.

    Thank you
    Best,
    Andres

  • #2
    The "Fetch without a SELECT" error message seems to be MySQL parlance, but what does the -sqlshow- show? Does it show a proper SELECT statement for the offending query?

    Maybe your nth sometable doesn't exist (misspelling etc.) in the database.

    Comment


    • #3
      It does show a proper SELECT statement and I checked that the table exists and has observations.

      Comment


      • #4
        Maybe add
        Code:
        sleep 2500
        to the loop.

        Comment

        Working...
        X