[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] Manipulating a QSqlRecord in a primeInsert handler
From:       Jorge Godoy <godoy () ieee ! org>
Date:       2005-04-27 14:14:39
Message-ID: 87is28z4q8.fsf () jupiter ! g2ctech
[Download RAW message or body]


Hi, 


I'm trying to use a QDataBrowser to browse and manipulate some records.  The
problem is that I'm not being able to set a new ID before inserting the record
and it is overwriting the only record available all the time.

My table structure -- this is a PostgreSQL database -- is:

symbol -> varchar(9)
name   -> varchar(30)
id     -> serial


My "primeInsert()" handler is:


    def dbGetNewUnitsID(self, record):
        query = QSqlQuery("SELECT NEXTVAL('units_id_seq')")
        query.execQuery()
        query.first()
        record.setValue('id', query.value(0))


It gets invoked correctly, it even executes the query, but it doesn't insert
the record as part of the transaction after getting the new ID.

Is there something else I should be doing?  Is it the correct way to handle
this kind of thing to create a new button to get the correct ID and then use
the 'Insert' button to make the insertion on the database?


Thanks in advance,

-- 
Jorge Godoy      <godoy@ieee.org>


_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic