Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48471

QSqlQuery QPSQL Error 42601 When Using "prepare"...

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.5.0, 5.11.2
    • SQL Support
    • None
    • Windows 8.1 64-bit with MSVC2013, OS X 10.10 with Xcode 7 and Mint Linux 17.2

    Description

      When using the following passing in a QString (see below) into QSqlQuery::prepare and then calling QSqlQuery::exec with no arguments we get a postgresql error 42601. However passing the same QString into the QSqlQuery::exec and skipping the QSqlQuery::prepare step functions correctly with no errors.

      **** ERROR:
      int mCategoryNumber = 123;
      QSqlDatabase mDatabase = ...;
      QSqlQuery   lCQuery(mDatabase);
      
      QString lCSql = QString(
                  "CREATE TABLE IF NOT EXISTS category_%1 ("
                  " sn SERIAL PRIMARY KEY,"
                  " istrial int,"
                  " maintexpiration TEXT,"
                  " creation TEXT,"
                  " expiration TEXT,"
                  " lastissue TEXT,"
                  " certificate TEXT,"
                  " privatekey TEXT,"
                  " name TEXT NOT NULL,"
                  " phone TEXT,"
                  " email TEXT NOT NULL,"
                  " notes TEXT,"
                  " organization TEXT,"
                  " organizationunit TEXT,"
                  " country TEXT,"
                  " licensetype int,"
                  " licensecount int );"
                  ).arg(mCategoryNumber);
      
      lCQuery.prepare( lCSql );
      
      return lCQuery.exec();
      
      
      **** SUCCESSFUL:
      int mCategoryNumber = 123;
      QSqlDatabase mDatabase = ...;
      QSqlQuery   lCQuery(mDatabase);
      
      QString lCSql = QString(
                  "CREATE TABLE IF NOT EXISTS category_%1 ("
                  " sn SERIAL PRIMARY KEY,"
                  " istrial int,"
                  " maintexpiration TEXT,"
                  " creation TEXT,"
                  " expiration TEXT,"
                  " lastissue TEXT,"
                  " certificate TEXT,"
                  " privatekey TEXT,"
                  " name TEXT NOT NULL,"
                  " phone TEXT,"
                  " email TEXT NOT NULL,"
                  " notes TEXT,"
                  " organization TEXT,"
                  " organizationunit TEXT,"
                  " country TEXT,"
                  " licensetype int,"
                  " licensecount int );"
                  ).arg(mCategoryNumber);
      
      return lCQuery.exec(lCSql);
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mabrand Mark Brand
              jcohentech Joseph Cohen
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes