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
49.5k
How to Pass DB Name as Parameter in mysql server ?.
Mar 17 2020 3:38 AM
Hi All ,
I have situation to pass database Name as Parameter in mysql storedprocedure . But i have issue on this i share my procedure .If anyone knows suggest me with example.
DELIMITER //
CREATE PROCEDURE GetRecord
(
IN R_BranchName varchar(100),
IN R_Year Date ,
IN R_Month Date ,
IN R_CurrDate date
)
BEGIN
SET @Db=R_BranchName;
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 '@Db'.transpayment tp left join '@Db'.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,'' as Month ,sum(tp.PaymentAmount) as total from '@Db'.transpayment tp left join '@Db'.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 ;
END
//DELIMITER ;
When pass following values the above stored Procedure Need to Run. (Above procedure Not Run due ' @db' this value
CALL GetRecord('Chive1',Year(Curdate()), Month(Curdate()),Curdate() );
Thanks in Advance
Karthik K
Reply
Answers (
2
)
How to make a Central database for mul pc's in same network?
Get Stored Procedure Result Set values in Mysql server ?