> Dne Čt 20. května 2010 09:08:11 José Arcángel Salazar Delgado napsal(a):
> > > Hello,
> > > yes i though there could be query problem - but how can examine the
> > > query generated? I'm using postgresql.
> > >
> > > I have this model (simplified)
> > >
> > > CREATE TABLE Employee (
> > >
> > > id serial NOT NULL,
> > > name varchar(255) NOT NULL,
> > > surname varchar(255) NOT NULL,
> > > PRIMARY KEY (id));
> > >
> > > CREATE TABLE EduPlan (
> > >
> > > Employeeid int4 NOT NULL,
> > > "date" date NOT NULL,
> > >
> > > );
> > >
> > > I have the realtional model like this:
> > >
> > > model.setTable("eduplan");
> > > model.setRelation(0, new QSqlRelation("employee", "id", "surname"));
> > > model.setEditStrategy(QSqlTableModel.EditStrategy.OnFieldChange);
> > > ui.planTable.setItemDelegate(new QSqlRelationalDelegate());
> > > model.select();
> > >
> > > really simple - almost as the example
> >
> > I'm only guessing, but I thing the problem is that you don't have any PK
> > in the EduPlan Column. Can you try to add some id field to the table and
> > try again?
>
> Oh I forgot, there is a foreign key of course like this:
> ALTER TABLE EduPlan ADD CONSTRAINT plans FOREIGN KEY (Employeeid)
> REFERENCES Employee (id);
>
> or did you mean I shoould add separate primary key column?
yes, I think that you need a separate PK for the table Eduplan, some database
do strage things if there is no PK in a table.
try with something like:
CREATE TABLE EduPlan (
id serial NOT NULL,
Employeeid int4 NOT NULL,
"date" date NOT NULL,
PRIMARY KEY (id));
> > > thanks
> > >
> > > Dne St 19. května 2010 17:05:00 José Arcángel Salazar Delgado napsal(a):
> > > > > Hello,
> > > > > i'm trying to use relationalTableModel as described in doc and
> > > > > examples. Everything is pretty simple almost the same as in
> > > > > example. The model has OnFieldChange EditStrategy However i'm not
> > > > > able to change the relation column value nor delete the row.
> > > > >
> > > > > While updating the model.lastError() gives:
> > > > > QSqlError(0, "Unable to bind parameters", "The column index is out
> > > > > of range: 4, number of columns: 3. (22023)")
> > > > >
> > > > > which is strange because the table has 4 columns (including foreign
> > > > > key column)
> > > > >
> > > > > while deleting (using model.removeRows()) it gives:
> > > > > QSqlError(0, "Unable to execute query", "ERROR: column "surname"
> > > > > does not exist (42703)")
> > > > >
> > > > > the "surname" is displayColumn of QSqlRelation :(
> > > >
> > > > This normaly happend when your query is wrong. What Database are you
> > > > using? This happend to me when I forgot to add the table name to the
> > > > parameters or the schema name.
> > > >
> > > > If you can give us more information we could help you.
> > > >
> > > > > Please can someone give me an advice what could be wrong, or how to
> > > > > investigate the problem deeply (for instance how to debug into
> > > > > code).
> > > > >
> > > > > Using 4.5.2_01 still because the newest distro for linux doesn't
> > > > > contain a designer binary ;-)
> > > > >
> > > > > Regards
> > > > >
> > > > > Jiri Mikulasek
> > > > >
> > > > > AURA, s.r.o. Czech Republic
> > > > > _______________________________________________
> > > > > Qt-jambi-interest mailing list
> > > > > [email protected]
> > > > > http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
> > >
> > > _______________________________________________
> > > Qt-jambi-interest mailing list
> > > [email protected]
> > > http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
>
> _______________________________________________
> Qt-jambi-interest mailing list
> [email protected]
> http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
--
Ing. José Arcángel Salazar Delgado
Nettrace
Av 27 #6 col. Venustiano Carranza.
Boca del río, Ver.
Tel. Oficina 9-27-54-78
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest