Results 1 to 10 of 10

Thread: PostgreSQL and QT4 automate id problem!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    13
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and QT4 automate id problem!

    Ok, it works now.
    Wysota thank you for your advice, I'll keep that on my mind when I make some more complex forms...
    I didn't understand your solution Jacek. What is serial exactly? A new data type? Sorry I am not so familiar with PostgreSQL.
    GreyGeek you solution works! I don't need any transactions now as I am under the PostgreSQL protections? Am I right?

    And some of you mentioned trigers. No clue so far... Is it a complex explanation to drop a few lines before I read a tutorial?

    Marry Christmas to all of you that celebrates...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: PostgreSQL and QT4 automate id problem!

    Quote Originally Posted by nnidza View Post
    And some of you mentioned trigers. No clue so far... Is it a complex explanation to drop a few lines before I read a tutorial?
    http://en.wikipedia.org/wiki/Database_trigger

    Marry Christmas to all of you that celebrates...
    Thanks

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and QT4 automate id problem!

    Quote Originally Posted by nnidza View Post
    I didn't understand your solution Jacek. What is serial exactly? A new data type?
    Yes, it's a special data type. It's an equivalent of GreyGeek's solution, only shorter.

    http://www.postgresql.org/docs/8.2/s...ATATYPE-SERIAL

  4. #4
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and QT4 automate id problem!

    Quote Originally Posted by jacek View Post
    Yes, it's a special data type. It's an equivalent of GreyGeek's solution, only shorter.

    http://www.postgresql.org/docs/8.2/s...ATATYPE-SERIAL
    Last week I upgraded from PostgreSQL 8.1.4 to 8.2 on my W2K workstation. My compiles stopped with an error while attempting to load a dll.

    qsqlpsql.dll loaded ssleay32.dll which loaded leay32.dll which failed because the first dll was looking for functions which weren't present on one of the secure shell dlls. Dependencychecker showed the problem, but I am at home and don't have access to my notes. But, basically, when Qt attempts to load a library and it fails, it is marked so that it won't load again until the library is recompiled, or at least touched, so that the timestamp changes. Then Qt will attempt to load it again.

    When I reverted back to 8.1.4 Qt4.2.2 apps compiled OK.

  5. #5
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and QT4 automate id problem!

    Quote Originally Posted by nnidza View Post
    I don't need any transactions now as I am under the PostgreSQL protections? Am I right?
    No. You still may need to use transactions.

    A classic example is the General Journal posting. Say you have a table containing daily postings of debits and credits to various accounts. You want to post those amounts to their specific debit and credit accounts to that your accounts remain balanced. If any of them fail you want to revert all of them. You do that by
    Begin;
    post the daily transactions to the general ledger
    Commit;
    (or Rollback if things didn't go well).
    See http://www.postgresql.org/docs/8.1/i...nsactions.html

    This avoids the "dirty read" problem:
    http://www.informit.com/articles/art...&seqNum=6&rl=1

  6. #6
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: PostgreSQL and QT4 automate id problem!

    Triggers are very useful. Their use is only limited by your imagination.

    A simple use is backing up changes made by clerks. A trigger on the UPDATE would save the *.NEW or *.OLD record in a history table automatically. Then, if a question arises as to who changed what and when you can consult the history table. If you need to revert a change you can use the history table as the source of the previous record.

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.