Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
can someone tell me what i am doing wrong in this procedure ?
i will appreciate any help. it gives me a syntax error.

SQL
CREATE PROCEDURE `bank`.`withdraw` (accountId int, customerId  int, amount double)
BEGIN
       Declare var_balance double;
       Declare var_accountId int;
       Declare var_customerId int;
       Declare var_remainder double;

    select account.accountId, customer.customerId, account.balance into var_accountId, var_customerId, var_balance
    from customer, account
    where account.accountId = accountId and customer.customerId = customerId;


    if amount < var_balance then
      set var_remainder = account.balance - amount;

END
Posted
Comments
Sergey Alexandrovich Kryukov 16-Oct-12 17:03pm    
Isn't it nice to say "it gives me a syntax error", not telling us the error information?
--SA
Georges23 16-Oct-12 17:05pm    
the error says unexpected end_of_input, expecting if
[no name] 16-Oct-12 17:07pm    
You need an "end if"
Georges23 16-Oct-12 17:17pm    
thank you very much it worked perfect

1 solution

SQL
if amount < var_balance then
   set var_remainder = account.balance - amount;

should be
SQL
if amount < var_balance then
   set var_remainder = var_balance - amount;
end if
 
Share this answer
 
v2
Comments
Maciej Los 16-Oct-12 17:23pm    
Good work, Marcus ;) +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900