🗄️ Databases Pa help po sa sql

Status
Not open for further replies.

bryan_16

Forum Veteran
Nilito kasi ako dito sa begin transaction ehh meron naman dun sa banda una hindi ko alam bakit error padin kanina pa ako dito error na eto, baka meron may alam diyan pa help sana
thanks in advance.

BEGIN TRAN UPDATE Students SET Balance = Balance - 15000 WHERE S_ID = 20 DECLARE @BalanceMo INT SET @BalanceMo = (SELECT Balance FROM Students WHERE S_ID = 20) IF @BalanceMo >= 0 BEGIN BEGIN TRAN SELECT 'Transaction is succesful' INSERT INTO Payment (P_ID,date,amount,S_ID) VALUES(5,'2020-08-01',15000,20) END ELSE IF @BalanceMo <= 0 BEGIN Rollback Tran DECLARE @PayMo INT SET @PayMo = (SELECT Amount FROM Payment WHERE P_ID = 4) Print 'Transaction could not proceed, the payment has been received is overpaid. Please try again. Your tuition balance is: ' +CAST(@BalanceMo AS VARCHAR) + ' | Your payment: '+CAST(@PayMo AS VARCHAR) ; END COMMIT



Screenshot (469).webp
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 539
    Views
  • 1
    Participants
Last reply from:
bryan_16

Trending Topics

Online now

Members online
1,211
Guests online
3,200
Total visitors
4,411

Forum statistics

Threads
2,308,141
Posts
29,183,470
Members
1,191,857
Latest member
buddhi p r s
Back
Top