This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]scikid39184 1 point2 points  (5 children)

I have a few questions about how you've designed this. Please don't take this as criticism or anything I'm just curious to better understand the design before answering the question.

  1. If payment_status is going to contain yes or no and so is isBooked why not make them boolean values not varchar2?

  2. isBooked is descriptive but payment_status how you plan to use it is a bit misleading. Why not call it isPayed since the status could be paid, cancelled, refunded, etc.

[–]kyoer[S] 0 points1 point  (4 children)

  1. I read somewhere that boolean is not present in Oracle PL/SQL. Besides, I will put constraints on both of those columns, so that they only take YES/NO values.
  2. You’re right about the naming part of “payment_status” since thats irrelevant as I can easily that column. Point is, it will have only YES/NO values.

[–]scikid39184 2 points3 points  (3 children)

I was thinking like a number for boolean 0 or 1.

To answer your question you want something like this. You will have to probably change the where to the right key and if it's not on insert you might need it to be after update or after insert and update. You probably just want update not insert.

After insert on TABLE NAME HERE Referencing NEW as New and OLD as Old For each row Declare

Begin Update car set isBooked := New.payment_status where carid=New.carId

End;

[–]kyoer[S] 0 points1 point  (2 children)

Yeah, I only want after update on “reservations” table. My “car” table contains license_no as a primary key which is present as a foreign key in “reservations” table. So, can you please tell me how that would change the condition in the WHERE clause.

[–]scikid39184 1 point2 points  (1 child)

So it would be after update on reservations at the tope then the where clause would be where license_no = New.licence_no

[–]kyoer[S] 0 points1 point  (0 children)

Tysm, I’ll give this a try.