Subject | Problem with KeyLinks |
---|---|
Author | Salvatore Besso |
Post date | 2004-10-20T08:21:21Z |
hello all,
sorry for the long post, but it seems that I still have to learn a lot about IBO
:-)
Let's start with the definition of these two tables in my database:
CREATE TABLE Anagraphics(
ID_Anagraphic INT_ID, /* PK */
Prefix INT_PREFIX,
Unit INT_UNIT,
Call_Sign CH_CALL_SIGN,
Operator_Name CH_OP_NAME,
City CH_CITY,
TX_Province INT_ID, /* INT_ID = INTEGER, NOT NULL, > 0 */
TX_Region INT_ID,
Own_Province INT_ID,
Own_Region INT_ID,
Class CH_CLASS,
Op_2_Prefix INT_PREFIX_CAN_BE_NULL,
Op_2_Unit INT_UNIT_CAN_BE_NULL,
Op_2_Call_Sign CH_CALL_SIGN_CAN_BE_NULL,
Op_2_Name CH_OP_NAME_CAN_BE_NULL,
Op_3_Prefix INT_PREFIX_CAN_BE_NULL,
Op_3_Unit INT_UNIT_CAN_BE_NULL,
Op_3_Call_Sign CH_CALL_SIGN_CAN_BE_NULL,
Op_3_Name CH_OP_NAME_CAN_BE_NULL,
Last_Progressive INT_ANAGRAPHIC_PROGRESSIVE,
Can_Delete_Last LOGICAL,
Certificates INT_CERTIFICATES,
Amount NUM_AMOUNT);
CREATE TABLE Provinces(
ID_Province INT_SPECIAL_ID, /* PK, INT_SPECIAL_ID = INTEGER, NOT NULL, >= 0 */
Short_Name CH_PROVINCE_SHORT_NAME,
Long_Name CH_PROVINCE_LONG_NAME,
ID_Region INT_SPECIAL_ID,
Award LOGICAL);
Then, I have three TIB_Query (and associated TIB_DataSource) in the data-module,
the first query has this SQL:
SELECT A.ID_ANAGRAPHIC, A.PREFIX, A.UNIT, A.CALL_SIGN,
A.OPERATOR_NAME, A.CITY, A.TX_PROVINCE,
(SELECT P1.SHORT_NAME FROM PROVINCES P1 WHERE P1.ID_PROVINCE = A.TX_PROVINCE)
AS TX_PROV,
A.TX_REGION, A.OWN_PROVINCE,
(SELECT P2.SHORT_NAME FROM PROVINCES P2 WHERE P2.ID_PROVINCE = A.OWN_PROVINCE)
AS OWN_PROV,
A.OWN_REGION, A.CLASS,
A.OP_2_PREFIX, A.OP_2_UNIT, A.OP_2_CALL_SIGN, A.OP_2_NAME,
A.OP_3_PREFIX, A.OP_3_UNIT, A.OP_3_CALL_SIGN, A.OP_3_NAME,
A.CERTIFICATES, A.AMOUNT
FROM ANAGRAPHICS A
ORDER BY A.PREFIX, A.UNIT
The second and third query are used to retrieve province ID's for Anagraphics
and also to show TIB_LookupCombo's in the grid:
Second query:
SQL: SELECT * FROM PROVINCES ORDER BY SHORT_NAME
KeyLinks: ID_PROVINCE=ANAGRAPHICS.TX_PROVINCE
KeyLinksAutoDefine: False
KeyDescLinks: SHORT_NAME=TX_PROV
Third query:
SQL: SELECT * FROM PROVINCES ORDER BY SHORT_NAME
KeyLinks: ID_PROVINCE=ANAGRAPHICS.OWN_PROVINCE
KeyLinksAutoDefine: False
KeyDescLinks: SHORT_NAME=OWN_PROV
Well, using that SQL in the first query the dataset is perfectly editable (of
course the query's RequestLive is True), but as you can see, I had to use a
non-SQL92 syntax.
Now I modify the SQL of the first query to be SQL92 compliant:
SELECT A.ID_ANAGRAPHIC, A.PREFIX, A.UNIT, A.CALL_SIGN,
A.OPERATOR_NAME, A.CITY, A.TX_PROVINCE, P1.SHORT_NAME TX_PROV,
A.TX_REGION, A.OWN_PROVINCE, P2.SHORT_NAME OWN_PROV,
A.OWN_REGION, A.CLASS, A.OP_2_PREFIX, A.OP_2_UNIT, A.OP_2_CALL_SIGN,
A.OP_2_NAME, A.OP_3_PREFIX, A.OP_3_UNIT, A.OP_3_CALL_SIGN,
A.OP_3_NAME, A.CERTIFICATES, A.AMOUNT
FROM ANAGRAPHICS A
JOIN PROVINCES P1 ON P1.ID_PROVINCE = A.TX_PROVINCE
JOIN PROVINCES P2 ON P2.ID_PROVINCE = A.OWN_PROVINCE
ORDER BY A.PREFIX, A.UNIT
Well, now I cannot edit or insert in the Anagraphics table any more, receiving
an error of:
"Cannot insert a row" or
"Cannot edit row"
I have tried several combinations of KeyLinks for the first query (that with the
first SQL was blank) but without luck. I have also given a look at the KeyLinks
project in the Demos folder, but it wasn't of any help.
Can you give me a guide line on how the KeyLinks of the first query could be to
make the query editable again, stated that leaving KeyLinks blank doesn't work?
Thank you
Salvatore
sorry for the long post, but it seems that I still have to learn a lot about IBO
:-)
Let's start with the definition of these two tables in my database:
CREATE TABLE Anagraphics(
ID_Anagraphic INT_ID, /* PK */
Prefix INT_PREFIX,
Unit INT_UNIT,
Call_Sign CH_CALL_SIGN,
Operator_Name CH_OP_NAME,
City CH_CITY,
TX_Province INT_ID, /* INT_ID = INTEGER, NOT NULL, > 0 */
TX_Region INT_ID,
Own_Province INT_ID,
Own_Region INT_ID,
Class CH_CLASS,
Op_2_Prefix INT_PREFIX_CAN_BE_NULL,
Op_2_Unit INT_UNIT_CAN_BE_NULL,
Op_2_Call_Sign CH_CALL_SIGN_CAN_BE_NULL,
Op_2_Name CH_OP_NAME_CAN_BE_NULL,
Op_3_Prefix INT_PREFIX_CAN_BE_NULL,
Op_3_Unit INT_UNIT_CAN_BE_NULL,
Op_3_Call_Sign CH_CALL_SIGN_CAN_BE_NULL,
Op_3_Name CH_OP_NAME_CAN_BE_NULL,
Last_Progressive INT_ANAGRAPHIC_PROGRESSIVE,
Can_Delete_Last LOGICAL,
Certificates INT_CERTIFICATES,
Amount NUM_AMOUNT);
CREATE TABLE Provinces(
ID_Province INT_SPECIAL_ID, /* PK, INT_SPECIAL_ID = INTEGER, NOT NULL, >= 0 */
Short_Name CH_PROVINCE_SHORT_NAME,
Long_Name CH_PROVINCE_LONG_NAME,
ID_Region INT_SPECIAL_ID,
Award LOGICAL);
Then, I have three TIB_Query (and associated TIB_DataSource) in the data-module,
the first query has this SQL:
SELECT A.ID_ANAGRAPHIC, A.PREFIX, A.UNIT, A.CALL_SIGN,
A.OPERATOR_NAME, A.CITY, A.TX_PROVINCE,
(SELECT P1.SHORT_NAME FROM PROVINCES P1 WHERE P1.ID_PROVINCE = A.TX_PROVINCE)
AS TX_PROV,
A.TX_REGION, A.OWN_PROVINCE,
(SELECT P2.SHORT_NAME FROM PROVINCES P2 WHERE P2.ID_PROVINCE = A.OWN_PROVINCE)
AS OWN_PROV,
A.OWN_REGION, A.CLASS,
A.OP_2_PREFIX, A.OP_2_UNIT, A.OP_2_CALL_SIGN, A.OP_2_NAME,
A.OP_3_PREFIX, A.OP_3_UNIT, A.OP_3_CALL_SIGN, A.OP_3_NAME,
A.CERTIFICATES, A.AMOUNT
FROM ANAGRAPHICS A
ORDER BY A.PREFIX, A.UNIT
The second and third query are used to retrieve province ID's for Anagraphics
and also to show TIB_LookupCombo's in the grid:
Second query:
SQL: SELECT * FROM PROVINCES ORDER BY SHORT_NAME
KeyLinks: ID_PROVINCE=ANAGRAPHICS.TX_PROVINCE
KeyLinksAutoDefine: False
KeyDescLinks: SHORT_NAME=TX_PROV
Third query:
SQL: SELECT * FROM PROVINCES ORDER BY SHORT_NAME
KeyLinks: ID_PROVINCE=ANAGRAPHICS.OWN_PROVINCE
KeyLinksAutoDefine: False
KeyDescLinks: SHORT_NAME=OWN_PROV
Well, using that SQL in the first query the dataset is perfectly editable (of
course the query's RequestLive is True), but as you can see, I had to use a
non-SQL92 syntax.
Now I modify the SQL of the first query to be SQL92 compliant:
SELECT A.ID_ANAGRAPHIC, A.PREFIX, A.UNIT, A.CALL_SIGN,
A.OPERATOR_NAME, A.CITY, A.TX_PROVINCE, P1.SHORT_NAME TX_PROV,
A.TX_REGION, A.OWN_PROVINCE, P2.SHORT_NAME OWN_PROV,
A.OWN_REGION, A.CLASS, A.OP_2_PREFIX, A.OP_2_UNIT, A.OP_2_CALL_SIGN,
A.OP_2_NAME, A.OP_3_PREFIX, A.OP_3_UNIT, A.OP_3_CALL_SIGN,
A.OP_3_NAME, A.CERTIFICATES, A.AMOUNT
FROM ANAGRAPHICS A
JOIN PROVINCES P1 ON P1.ID_PROVINCE = A.TX_PROVINCE
JOIN PROVINCES P2 ON P2.ID_PROVINCE = A.OWN_PROVINCE
ORDER BY A.PREFIX, A.UNIT
Well, now I cannot edit or insert in the Anagraphics table any more, receiving
an error of:
"Cannot insert a row" or
"Cannot edit row"
I have tried several combinations of KeyLinks for the first query (that with the
first SQL was blank) but without luck. I have also given a look at the KeyLinks
project in the Demos folder, but it wasn't of any help.
Can you give me a guide line on how the KeyLinks of the first query could be to
make the query editable again, stated that leaving KeyLinks blank doesn't work?
Thank you
Salvatore