TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Karthik K
1.3k
479
50.1k
Get Stored Procedure Result Set values in Mysql server ?
Mar 18 2020 10:27 PM
Hi All ,
I want to read Result set values of this Procedure in Mysqlserver Database .
CALL GetRecord('chive5',@R_TotalSales ,@R_MonthlySale);
Total sale
Total
21132.6000
386.6000
The above procedure Return like this , I want read and update this value in another table. I have get TotalSale as well as Total. Can Anyone suggest with example stored Procedure.
my Procedure :
DELIMITER $$
CREATE
DEFINER=`root`@`%`
PROCEDURE
`chivehq`.`GetRecord`(
IN
R_BranchName
varchar
(100),
OUT
R_TotalSales
decimal
(15,2),
OUT
R_MonthlySale
decimal
(15,2)
)
BEGIN
DECLARE
SQLStmt TEXT;
declare
R_Year
date
;
declare
R_Month
date
;
declare
R_CurrDate
date
;
SET
@Branch=R_BranchName;
set
@R_Year=
Year
(Curdate());
set
@R_Month=
Month
(Curdate());
set
@R_CurrDate=Curdate();
SET
@R_TotalSales=0;
SET
@R_MonthlySale=0;
SET
@SQLStmt=CONCAT
(
'
select
sum
(H.TotalSales)
As
TotalSales ,H.
Month
,
sum
(H.total)
as
Total
from
(
select
(
sum
(tp.PaymentAmount))
as
Totalsales,Monthname(tp.BusinessDate)
as
Month
,0
as
Total
from
',R_BranchName,'
.transpayment tp
left
join
',R_BranchName,'
.trans t
on
tp.TransID=t.TransID
where
t.TransStatus
in
(2,3,4)
and
year
(tp.BusinessDate)=
',@R_Year,'
and
MONTH
(tp.BusinessDate)=
',@R_Month,'
union
All
select
0.00
as
Totalsales,
null
as
Month
,
sum
(tp.PaymentAmount)
as
total
from
',R_BranchName,'
.transpayment tp
left
join
',R_BranchName,'
.trans t
on
tp.TransID=t.TransID
where
tp.BusinessDate
between
','
@R_CurrDate
','
and
','
@R_CurrDate
','
and
t.TransStatus
in
(2,3,4)
)
as
H
');
PREPARE
Stmt
FROM
@SQLStmt;
EXECUTE
Stmt;
DEALLOCATE
PREPARE
Stmt;
END
$$
DELIMITER ;
Thanks in Advance ,
Karthik K
Reply
Answers (
1
)
How to Pass DB Name as Parameter in mysql server ?.
Event Scheduling not Running in Mysql Server ?