Results 1 to 5 of 5

Thread: Problem calling stored procedure.. Help!

  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Problem calling stored procedure.. Help!

    hi,

    im having trouble calling stored procedure..

    sample code:
    Qt Code:
    1. DELIMITER $$
    2.  
    3. DROP PROCEDURE IF EXISTS `rdmssql`.`hello`$$
    4. CREATE PROCEDURE `rdmssql`.`hello` ()
    5. BEGIN
    6.  
    7. SELECT * FROM RD0500;
    8.  
    9. END$$
    10.  
    11. DELIMITER ;
    To copy to clipboard, switch view to plain text mode 

    it my code
    Qt Code:
    1. QSqlQuery sql("Call hello()");
    2. qDebug(sql.lastError().text());
    To copy to clipboard, switch view to plain text mode 

    but it return an error

    PROCEDURE mydatabase.hello can't return a result set in the given context QMYSQL3: Unable to execute query
    how to solve this?

    im using Qt3.3.6 right now..
    thanks.

  2. #2
    Join Date
    Jun 2008
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling stored procedure.. Help!

    Hello,

    i use SqlQuery and SPs only with prepare, execute and ODBC driver. With some databases i have trouble without setting setForwardOnly.

    For example :
    Qt Code:
    1. QSqlQuery oQuery;
    2.  
    3. // Use ODBC with shown call syntax
    4. oQuery.setForwardOnly( true);
    5. oQuery.prepare( "{call hello()}");
    6. oQuery.exec();
    7. ...
    To copy to clipboard, switch view to plain text mode 

    bye

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling stored procedure.. Help!

    using query.setforwardOnly(TRUE) is not working..

    insert procedure
    Qt Code:
    1. DELIMITER $$
    2.  
    3. DROP PROCEDURE IF EXISTS `MYDB`.`qtestproc`$$
    4. CREATE PROCEDURE `qtestproc`(TABLENAME char(20),TABLEVALUES LONGTEXT)
    5.  
    6. BEGIN
    7. SET @s =CONCAT("INSERT INTO ",TABLENAME," values(",TABLEVALUES,")");
    8. PREPARE stmt FROM @s;
    9. EXECUTE stmt;
    10. END$$
    11. DELIMITER ;
    To copy to clipboard, switch view to plain text mode 

    qt code
    Qt Code:
    1. q.setForwardOnly( true);
    2. q.prepare("Call `MYDB`.`qtestproc`("mytable","values");
    3. q.exec();
    4. qDebug(q.lastError().text());
    To copy to clipboard, switch view to plain text mode 

    still got same error : MYDB.qtestproc cant return a result set in a given context QMYSQL3: unable to execute query

    im using qt3.3.6 with QMYSQL3

  4. #4
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem calling stored procedure.. Help!

    hi,

    after searching i found out that this problem is a bug found at Qt 4.0.1 then later fixed in Qt4.1.3 (see http://trolltech.com/developer/task-...entry&id=93292)

    trolltech suggest a solution,

    Patch from Trolltech:

    ==== //depot/qt/4.1/src/sql/drivers/mysql/qsql_mysql.cpp#7 (text) ====

    @@ -947,7 +947,12 @@
    if (isOpen())
    close();

    - unsigned int optionFlags = 0;
    + /* This is a hack to get MySQL's stored procedure support working.
    + Since a stored procedure _may_ return multiple result sets,
    + we have to enable CLIEN_MULTI_STATEMENTS here, otherwise _any_
    + stored procedure call will fail.
    + */
    + unsigned int optionFlags = CLIENT_MULTI_STATEMENTS;
    const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));

    // extract the real options from the string
    since i found it in Qt 3 should i edit qsql_mysql.cpp too? and put the same code above?

    if i dont have qsql_mysql.cpp should i configure qt again with sql support?

    thanks

  5. #5
    Join Date
    Apr 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem calling stored procedure.. Help!

    try one of this :
    1) mummy solution (don't forget { and })
    2) use an exec statement instead of call(if you have only DDL statement int your SP).

Similar Threads

  1. Accessing REF CURSOR in Stored Procedure from Qt
    By sureshbabu in forum Qt Programming
    Replies: 3
    Last Post: 11th August 2010, 15:51
  2. Stored procedure and ODBC
    By filya in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2010, 08:40
  3. Accessing array (TABLE TYPE) in Stored Procedure from Qt
    By sureshbabu in forum Qt Programming
    Replies: 0
    Last Post: 26th September 2007, 11:36
  4. Stored procedure return values problem
    By jgreetham in forum Qt Programming
    Replies: 7
    Last Post: 10th September 2007, 17:38
  5. no record returns from stored procedure
    By mandal in forum Qt Programming
    Replies: 0
    Last Post: 26th April 2007, 14:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.