sql - Use interval to add on timestamp value from other table, in Oracle -
I'm actually starting SQL and I'm working on the Oracle engine. Timestamp Column - To add to integer value, I have a problem in manipulating arithmetic using the interval, which is present in another table and changes it in minutes. I used the data generator to test my schema. As a result, some of the produced data is not reliable and I need to check overlapping between two appointments, when the same patient invited to overlap two therapies.
treatments_appointments (APP_ID number (38) is not NULL, [FK] care_id number (38) is not NULL, [FK] doctor_id number (38) not NULL: I've included treatments_appointments table that features , [FK] room_id number (38) is not NULL, [FK] branch_id number (38) is not NULL, [FK] patient_id number (38) is not NULL, appointment_time timestamp not NULL)
the code I wrote below and get an error message:
treatment_appointment APP1 select join insider app1.app_id treatment_appointment APP2 on app1.patient_id = app2.patient_id where app1.appointment_time & Gt; = App2.appointment_time and app1.appointment_time & lt; Select = app2.appointment_time + interval (TO_CHAR (care_categories.care_duration where app2.care_id = care_categories.care_id)) minutes and app1.app_id = is app2.app_id
Error Message: ORA -00936: Sorry for the missing expression of my English and thanks for this is answering my question!
You can only use a fixed string value, a variable, an expression or a column value But you can use it to change several minutes in one interval. Instead:
select the interval (to_char (care_categories.care_duration where app2.care_id = care_categories.care_id)) min
use:
numtodsinterval (care_categories.care_duration choose where app2.care_id = care_categories.care_id, 'MINUTE')
Although you should join that table in the main table for each row subquery:
treatment_appointment APP1 insider Join treatment_appointment APP2 on app1.patient_id = app2.patient_id insider Join care_categories CC app2.care_id = cc.care_id where selected app1.appointment_time app1.app_id & Gt; = App2.appointment_time and app1.appointment_time & lt; = App2.appointment_time + numtodsinterval (cc.care_duration, 'MINUTE') and app1.app_id = app2.app_id
Comments
Post a Comment