Hello,
I am fresh in Oracle and I encounter a problem when I want to update a field from a table which is joined with itself.
Functional description:
Into a table, it is possible to have a new line which should be sent to the company's customers.
In order to not be sent each time same line, there exists a flag (field TO_SEND). The line which should be sent can be canceled and for this a new line is inserted in same table. If 1st line wasn't sent to the customer and it is canceled, in that moment will exists 2 lines with flag TO_SEND = Y and both of them will be sent to customer. The goal is to send only the 2nd line (the cancel line and not both of them).
For this, I was thinking to use the following script:
update order_table C
set C.TO_SEND = 'N'
from order_table C, order_table S
where C.BU = S.BU
and C.PO_NUM = S.PO_NUM
and C.PO_LINE = S.PO_LINE
and C.CARRIER = S.CARRIER
and C.PO_DATE = S.PO_DATE
and C.PRODUCT_ID = S.PRODUCT_ID
and C.TO_SEND = S.TO_SEND
and C.BU = 'Ac2'
and C.TO_SEND = 'Y'
and C.STATUS = 'CREATION'
and S.STATUS = 'SUPPRESSION';
The error returned is:
Error at Command Line:3 Column:1
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Do, someone have any clue why it doesn't work?
Thanks.
I am fresh in Oracle and I encounter a problem when I want to update a field from a table which is joined with itself.
Functional description:
Into a table, it is possible to have a new line which should be sent to the company's customers.
In order to not be sent each time same line, there exists a flag (field TO_SEND). The line which should be sent can be canceled and for this a new line is inserted in same table. If 1st line wasn't sent to the customer and it is canceled, in that moment will exists 2 lines with flag TO_SEND = Y and both of them will be sent to customer. The goal is to send only the 2nd line (the cancel line and not both of them).
For this, I was thinking to use the following script:
update order_table C
set C.TO_SEND = 'N'
from order_table C, order_table S
where C.BU = S.BU
and C.PO_NUM = S.PO_NUM
and C.PO_LINE = S.PO_LINE
and C.CARRIER = S.CARRIER
and C.PO_DATE = S.PO_DATE
and C.PRODUCT_ID = S.PRODUCT_ID
and C.TO_SEND = S.TO_SEND
and C.BU = 'Ac2'
and C.TO_SEND = 'Y'
and C.STATUS = 'CREATION'
and S.STATUS = 'SUPPRESSION';
The error returned is:
Error at Command Line:3 Column:1
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Do, someone have any clue why it doesn't work?
Thanks.
Comment