View wit 3 column remove row work with 4 column dont work



  • Hi
    Table Pracownicy
    [code]
    | Pracownicy | CREATE TABLE Pracownicy (
    IDPracownika int(11) NOT NULL AUTO_INCREMENT,
    IDStanowiska int(11) DEFAULT NULL,
    Imie char(20) NOT NULL,
    Nazwisko char(20) NOT NULL,
    DataUrodzenia date DEFAULT NULL,
    Ulica char(20) DEFAULT NULL,
    NrDomu char(10) DEFAULT NULL,
    KodPocztowy char(5) DEFAULT NULL,
    Miasto char(20) DEFAULT NULL,
    DataZatrudnienia date DEFAULT NULL,
    DataZwolnienia date DEFAULT NULL,
    Pensja float DEFAULT NULL,
    PRIMARY KEY (IDPracownika),
    KEY FK_R1 (IDStanowiska)
    ) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=latin1 |
    [/code]

    View
    [code]
    CREATE VIEW V1 AS
    SELECT IDPracownika,Imie,Nazwisko
    FROM Pracownicy

    CREATE VIEW V2 AS
    SELECT IDPracownika,Imie,Nazwisko,IDStanowiska
    FROM Pracownicy
    [/code]

    Now Qt Code
    [code]
    Part 1) //Selecting Table
    Login to DB ....

    QSqlRelationalTableModel model;
    model.setTable("V1");
    model.select();

    QTableView table;
    table.setModel(&model);
    table.show();

    Part 2) //Delete rows
    QModelIndexList t_SelectedRow = table.selectionModel()->selectedRows();
    foreach(QModelIndex i, t_SelectedRow)
    model.removeRow(i.row());
    [/code]

    So, why delete work on V1 but on V2 dont work ??
    In V1 and V2 edit rows work.



  • New tip.
    [code]
    CREATE VIEW V3 AS
    SELECT IDPracownika,Imie,Nazwisko,IDStanowiska,DataUrodzenia
    FROM Pracownicy
    [/code]

    For V3 row in model can't edit ???
    Some body can help me ??



  • I have solutnion, i cant remove row if some column is empty (if all column in view have data then i can delete row).
    WHY ????



  • Somebody know, why if columns IDStanowiska or DataUrodzenia is emplt (have Value NULL) then cant delete this row ??
    Columns Imie and Nazwisko can by emplty, because they are NOT NULL and MySQL automatically add empty String .

    Somebody Know how delete row if in View exist column how have NULL value ??


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.