Subject | Unusual Query |
---|---|
Author | lobolo2000 |
Post date | 2003-01-07T21:20:36Z |
Hi,
Items from a table should be grouped dynamically throug a user interface:
CREATE TABLE ITEMS (
ID DM_ID,
DESCRIPTION CHAR(200),
MGROUP INTEGER NOT NULL,
PRIMARY KEY (ID));
Items belong to the same group if and only if they share the same MGROUP
value.
The user interface consists of a main IB_Grid showing all the items (through
a main IB_Query), and a secondary IB_Grid showing all the items within the
same group (ie having the same MGROUP value) as the 'current' item in the
main grid.
The secondary query has:
SQL: SELECT * FROM ITEMS
DeleteSQL: UPDATE ITEMS SET MGROUP=-1 WHERE ID=:OLD_ID (a trigger takes care
of assigning a unique MGROUP value if we try to set a NULL or negative
MGROUP value, essentially putting the item in a new group)
KeyLinks: ID
MasterLinks: ITEMS.MGROUP=ITEMS.MGROUP
MasterSource: main DataSource
Browsing and deleting in the secondary grid work as expected.
1- Inserting a row in the secondary grid and setting its ID column value to
that of an item should put that item into the same group as the current item
in the main grid (by changing the MGROUP value of that item). What would the
InsertSQL be? I trust it should be something close to: UPDATE ITEMS SET
MGROUP=:MGROUP WHERE ID=:ID
2- Changing the ID column value of a row in the secondary grid should set
the MGROUP of the item with the old ID value to -1
and the MGROUP of the item with the new ID value to the current MGROUP. What
would the EditSQL be?
3- Is it possible to store 2 SQL statements in EditSQL (other than using a
stored procedure)?
It is always possible to resort to client side intervention (such as
trapping events
through code), but it would be nice to have a clean 'IBO encapsulated'
solution.
Regards,
Wassim
[Non-text portions of this message have been removed]
Items from a table should be grouped dynamically throug a user interface:
CREATE TABLE ITEMS (
ID DM_ID,
DESCRIPTION CHAR(200),
MGROUP INTEGER NOT NULL,
PRIMARY KEY (ID));
Items belong to the same group if and only if they share the same MGROUP
value.
The user interface consists of a main IB_Grid showing all the items (through
a main IB_Query), and a secondary IB_Grid showing all the items within the
same group (ie having the same MGROUP value) as the 'current' item in the
main grid.
The secondary query has:
SQL: SELECT * FROM ITEMS
DeleteSQL: UPDATE ITEMS SET MGROUP=-1 WHERE ID=:OLD_ID (a trigger takes care
of assigning a unique MGROUP value if we try to set a NULL or negative
MGROUP value, essentially putting the item in a new group)
KeyLinks: ID
MasterLinks: ITEMS.MGROUP=ITEMS.MGROUP
MasterSource: main DataSource
Browsing and deleting in the secondary grid work as expected.
1- Inserting a row in the secondary grid and setting its ID column value to
that of an item should put that item into the same group as the current item
in the main grid (by changing the MGROUP value of that item). What would the
InsertSQL be? I trust it should be something close to: UPDATE ITEMS SET
MGROUP=:MGROUP WHERE ID=:ID
2- Changing the ID column value of a row in the secondary grid should set
the MGROUP of the item with the old ID value to -1
and the MGROUP of the item with the new ID value to the current MGROUP. What
would the EditSQL be?
3- Is it possible to store 2 SQL statements in EditSQL (other than using a
stored procedure)?
It is always possible to resort to client side intervention (such as
trapping events
through code), but it would be nice to have a clean 'IBO encapsulated'
solution.
Regards,
Wassim
[Non-text portions of this message have been removed]