Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2006
QSqlRelationTableModel + Firebird


Message 1 in thread

Hello

i have found that the setRelation method of the QSqlRelationTableModel
doesnt work with Firebird.
i have 2 tables :
T_CITY
code integer (PK)
name varchar(40)

T_CLIENT
code integer (PK)
name varchar(40)
city integer (FK to T_CITY) 
....


here the code


1- model = new QSqlRelationalTableModel(this, db);
2 - model->setEditStrategy(QSqlTableModel :: OnManualSubmit);
3 - model->setTable("T_CLIENT");
4 - cityIdx = model->fieldIndex("city");
5 - model->setRelation(cityIdx , QSqlRelation("city", "code", "name"));
6 - if (!model->select()) {
7 - showError(model->lastError());
8 - return;
9 - }
10 - qDebug("last query : %s", model->query().lastQuery().ascii());

 


i got an error when i select the model
when i comment the line 5, i got no errors.

i find that the cause of the error is in the statement query which add "as"
after the table name of the table reference.



 

last query : SELECT T_CLIENT.CODE,CLIENT.NAME,relTblAl_5.NAME 
FROM T_CLIENT,T_CITY AS relTblAl_5 WHERE (T_CLIENT.CITY=relTblAl_5.CODE)

 

 

thanks