Subject | Editing record from TIB_Query with JOIN |
---|---|
Author | Marcin Bury |
Post date | 2018-06-01T12:23:02Z |
Hi
I have following SQL in TIB_Query:
SELECT D.OPERATION_ID
,D.DELIVERY_DATE
,D.D_STATUS
,D.REFERENCE_NO
,D.V_TYPE
,D.VEHICLE
,D.TRAILER
,D.DRIVER_FIRST_NAME
,D.DRIVER_LAST_NAME
,D.DRIVER_DOC
,D.DRIVER_MOBILE
,D.TRAIN_ID
,D.ARRIVAL_DATE
,D.ARRIVAL_USER
,D.SURVEY_DATE
,D.SURVEY_USER
,D.SURVEY_NOTES
,D.RFID
,D.RFID_DATE
,D.RFID_USER
,D.WEIGHT_F
,D.WEIGHT_F_DATE
,D.WEIGHT_F_USER
,D.WEIGHT_E
,D.WEIGHT_E_DATE
,D.WEIGHT_E_USER
,D.COMPLETED_DATE
,D.COMPLETED_USER
,D.I_DATE
,D.I_USER
,D.U_DATE
,D.U_USER
,SO.CUSTOMER_ID
,S.WAREHOUSE_ID
,SO.SECTION_ID
,SO.GOODS
,SO.GOODS_GRADE
,SO.OPERATION_DELTA
,SO.EU_CARGO
,CC_REF_NO
,CC_STATUS
FROM DELIVERIES D
LEFT JOIN STOCK_OPERATIONS SO ON SO.OPERATION_ID = D.OPERATION_ID
LEFT JOIN STOCK_SECTIONS S ON S.SECTION_ID = SO.SECTION_ID
WHERE D.OPERATION_ID = :OPERATION_ID
And following EXECUTE_BLOCK in EditSQL:
EXECUTE BLOCK (
IN_OPERATION_ID B_INT = :OPERATION_ID,
IN_CUSTOMER_ID VARCHAR25 = :CUSTOMER_ID,
IN_GOODS VARCHAR50 = :GOODS,
IN_DELIVERY_DATE DATA = :DELIVERY_DATE,
IN_V_TYPE VARCHAR5 = :V_TYPE,
IN_VEHICLE VARCHAR25 = :VEHICLE,
IN_TRAILER VARCHAR25 = :TRAILER,
IN_DRIVER_FIRST_NAME VARCHAR25 = :DRIVER_FIRST_NAME,
IN_DRIVER_LAST_NAME VARCHAR25 = :DRIVER_LAST_NAME,
IN_DRIVER_DOC VARCHAR25 = :DRIVER_DOC,
IN_DRIVER_MOBILE VARCHAR25 = :DRIVER_MOBILE,
IN_REFERENCE_NO VARCHAR50 = :REFERENCE_NO,
IN_EU_CARGO S_INT = :EU_CARGO,
IN_CC_REF_NO VARCHAR50 = :CC_REF_NO,
IN_CC_STATUS S_INT = :CC_STATUS,
IN_GOODS_GRADE VARCHAR5 = :GOODS_GRADE)
AS
BEGIN
UPDATE STOCK_OPERATIONS
SET CUSTOMER_ID = :IN_CUSTOMER_ID
,GOODS = :IN_GOODS
,GOODS_GRADE = :IN_GOODS_GRADE
,EU_CARGO = :IN_EU_CARGO
WHERE OPERATION_ID = :IN_OPERATION_ID;
IF (COALESCE(IN_CC_REF_NO, '') <> '')
THEN IN_CC_STATUS = 1;
ELSE IN_CC_STATUS = 0;
UPDATE DELIVERIES
SET DELIVERY_DATE = :IN_DELIVERY_DATE
,VEHICLE = :IN_VEHICLE
,TRAILER = :IN_TRAILER
,DRIVER_FIRST_NAME = :IN_DRIVER_FIRST_NAME
,DRIVER_LAST_NAME = :IN_DRIVER_LAST_NAME
,DRIVER_DOC = :IN_DRIVER_DOC
,DRIVER_MOBILE = :IN_DRIVER_MOBILE
,REFERENCE_NO = :IN_REFERENCE_NO
,CC_REF_NO = :IN_CC_REF_NO
,CC_STATUS = :IN_CC_STATUS
WHERE OPERATION_ID = :IN_OPERATION_ID;
END
When I'm posting the changes I'm getting an exception
'Multiple rows updated'
Is there any work around for such a case?
Thanks
Marcin
I have following SQL in TIB_Query:
SELECT D.OPERATION_ID
,D.DELIVERY_DATE
,D.D_STATUS
,D.REFERENCE_NO
,D.V_TYPE
,D.VEHICLE
,D.TRAILER
,D.DRIVER_FIRST_NAME
,D.DRIVER_LAST_NAME
,D.DRIVER_DOC
,D.DRIVER_MOBILE
,D.TRAIN_ID
,D.ARRIVAL_DATE
,D.ARRIVAL_USER
,D.SURVEY_DATE
,D.SURVEY_USER
,D.SURVEY_NOTES
,D.RFID
,D.RFID_DATE
,D.RFID_USER
,D.WEIGHT_F
,D.WEIGHT_F_DATE
,D.WEIGHT_F_USER
,D.WEIGHT_E
,D.WEIGHT_E_DATE
,D.WEIGHT_E_USER
,D.COMPLETED_DATE
,D.COMPLETED_USER
,D.I_DATE
,D.I_USER
,D.U_DATE
,D.U_USER
,SO.CUSTOMER_ID
,S.WAREHOUSE_ID
,SO.SECTION_ID
,SO.GOODS
,SO.GOODS_GRADE
,SO.OPERATION_DELTA
,SO.EU_CARGO
,CC_REF_NO
,CC_STATUS
FROM DELIVERIES D
LEFT JOIN STOCK_OPERATIONS SO ON SO.OPERATION_ID = D.OPERATION_ID
LEFT JOIN STOCK_SECTIONS S ON S.SECTION_ID = SO.SECTION_ID
WHERE D.OPERATION_ID = :OPERATION_ID
And following EXECUTE_BLOCK in EditSQL:
EXECUTE BLOCK (
IN_OPERATION_ID B_INT = :OPERATION_ID,
IN_CUSTOMER_ID VARCHAR25 = :CUSTOMER_ID,
IN_GOODS VARCHAR50 = :GOODS,
IN_DELIVERY_DATE DATA = :DELIVERY_DATE,
IN_V_TYPE VARCHAR5 = :V_TYPE,
IN_VEHICLE VARCHAR25 = :VEHICLE,
IN_TRAILER VARCHAR25 = :TRAILER,
IN_DRIVER_FIRST_NAME VARCHAR25 = :DRIVER_FIRST_NAME,
IN_DRIVER_LAST_NAME VARCHAR25 = :DRIVER_LAST_NAME,
IN_DRIVER_DOC VARCHAR25 = :DRIVER_DOC,
IN_DRIVER_MOBILE VARCHAR25 = :DRIVER_MOBILE,
IN_REFERENCE_NO VARCHAR50 = :REFERENCE_NO,
IN_EU_CARGO S_INT = :EU_CARGO,
IN_CC_REF_NO VARCHAR50 = :CC_REF_NO,
IN_CC_STATUS S_INT = :CC_STATUS,
IN_GOODS_GRADE VARCHAR5 = :GOODS_GRADE)
AS
BEGIN
UPDATE STOCK_OPERATIONS
SET CUSTOMER_ID = :IN_CUSTOMER_ID
,GOODS = :IN_GOODS
,GOODS_GRADE = :IN_GOODS_GRADE
,EU_CARGO = :IN_EU_CARGO
WHERE OPERATION_ID = :IN_OPERATION_ID;
IF (COALESCE(IN_CC_REF_NO, '') <> '')
THEN IN_CC_STATUS = 1;
ELSE IN_CC_STATUS = 0;
UPDATE DELIVERIES
SET DELIVERY_DATE = :IN_DELIVERY_DATE
,VEHICLE = :IN_VEHICLE
,TRAILER = :IN_TRAILER
,DRIVER_FIRST_NAME = :IN_DRIVER_FIRST_NAME
,DRIVER_LAST_NAME = :IN_DRIVER_LAST_NAME
,DRIVER_DOC = :IN_DRIVER_DOC
,DRIVER_MOBILE = :IN_DRIVER_MOBILE
,REFERENCE_NO = :IN_REFERENCE_NO
,CC_REF_NO = :IN_CC_REF_NO
,CC_STATUS = :IN_CC_STATUS
WHERE OPERATION_ID = :IN_OPERATION_ID;
END
When I'm posting the changes I'm getting an exception
'Multiple rows updated'
Is there any work around for such a case?
Thanks
Marcin