Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible print a variable in stored procedure.I am adding my code below

SQL
create procedure dist_profit_pairs1(IN user_id varchar(20),IN plan varchar(20))
begin
DECLARE left_bvs,right_bvs Float DEFAULT 0;
SELECT sum(businessvalues)as left_bvs from bv_history where userid=user_id and type='Distribution Profit' and position='Left';
SELECT sum(businessvalues)as right_bvs from bv_history where userid=user_id and type='Distribution Profit' and position='Right';

IF left_bvs < right_bvs  THEN
    SELECT left_bvs;
ELSE
    SELECT right_bvs;
Posted
Comments
What is the problem with the code?
Deepthi.21456 8-Feb-13 3:32am    
I am getting syntax error at SELECT left_bvs;The above code is correct.

1 solution

SELECT left_bvs; does not look like a valid statement. I think you should be using RETURN to return the requisite results.
 
Share this answer
 
Comments
Deepthi.21456 8-Feb-13 6:21am    
I tried that one also.But,it is not working.It is throwing the error like this it is not a function

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