Results 1 to 7 of 7

Thread: A multithreading question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2009
    Location
    Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: A multithreading question

    Hi,

    I suggest you to take a look here:

    http://lists.trolltech.com/qt-intere...ad00370-0.html

    and here:
    http://www.potu.com/man/doc.trolltec...4.0/qtsql.html

    in particular:
    Qt Code:
    1. QSqlDatabase::database().transaction();
    2. QSqlQuery query;
    3. query.exec("SELECT id FROM employee WHERE name = 'Torild Halvorsen'");
    4. if (query.next()) {
    5. int employeeId = query.value(0).toInt();
    6. query.exec("INSERT INTO project (id, name, ownerid) "
    7. "VALUES (201, 'Manhattan Project', "
    8. + QString::number(employeeId) + ")");
    9. }
    10. QSqlDatabase::database().commit();
    To copy to clipboard, switch view to plain text mode 

    Transactions can be used to ensure that a complex operation is atomic (for example, looking up a foreign key and creating a record), or to provide a means of canceling a complex change in the middle.

    Regards,
    Giuseppe 'Evilcry' Bonfa'
    Happiness depends on being self-sufficient, and a master of mental attitude, self-sufficiency is achieved by living a life of Virtue - Cynics

  2. The following user says thank you to GiuseppeBonfa for this useful post:

    sepehr (1st February 2009)

Similar Threads

  1. SQL Question
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 19:36
  2. Exceptions / setjmp/longjmp question
    By Aceman2000 in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2008, 17:14
  3. Replies: 2
    Last Post: 21st February 2008, 22:35
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

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
  •  
Qt is a trademark of The Qt Company.