我在java中使用了以下存储过程来处理我的项目。但我没有得到任何结果集。请帮我解决这个存储过程中的任何错误。
我想在MySQL中创建存储过程。如果你可以帮助我在MySQL中创建它,那将是很棒的。
请检查以下存储过程。
CREATE DEFINER=`Archu`@`localhost` PROCEDURE `UserReportAdminProc`(IN `WHEREClause` VARCHAR(1), IN `grname` VARCHAR(100), IN `goldcpa` VARCHAR(100), IN `username` VARCHAR(50), IN `fname` VARCHAR(50), IN `lname` VARCHAR(50), IN `ssn` VARCHAR(50), IN `email` VARCHAR(50), IN `gtxkey` VARCHAR(50), IN `dcn` VARCHAR(50), IN `pin` VARCHAR(50), IN `and_or` VARCHAR(16), IN `regdate1` VARCHAR(16), IN `regdate2` VARCHAR(16), IN `efileddate1` VARCHAR(16), IN `efileddate2` VARCHAR(16), IN `paiddate1` VARCHAR(16), IN `paiddate2` VARCHAR(16), IN `efiled` VARCHAR(1), IN `federalstatus` VARCHAR(10), IN `pkg` VARCHAR(10), IN `cpaname` VARCHAR(1000), IN `ExtraWHEREClause` VARCHAR(1000), OUT `colnames` VARCHAR(400))
DETERMINISTIC
Begin
declare SQLStatement varchar(8000);
if(WHEREClause !='') then
if(and_or='and') then
SELECT SQLStatement ='SELECT '+colnames+' FROM user_states_ord_return_list where username is not null ';
else if(and_or='or') then
SELECT SQLStatement ='SELECT '+colnames+' FROM user_states_ord_return_list where username is null ';
else if((regdate1!='' and regdate1 != ' 00:00') and (regdate2!='' and regdate2 != ' 23:59')) then
SELECT SQLStatement = SQLStatement+and_or+' User_Created_Date BETWEEN '+regdate1+' and '+regdate2;
else if(grname!='' and goldcpa!='') then
SELECT SQLStatement = SQLStatement+' and GroupName in ('+grname+', '+goldcpa+') ';
else if(username!='') then
SELECT SQLStatement = SQLStatement+and_or+' username Like '+username+'%';
else if(fname!='') then
SELECT SQLStatement = SQLStatement+and_or+' First_Name Like '+fname+'%';
else if(lname!='') then
SELECT SQLStatement = SQLStatement+and_or+' Last_Name Like '+lname+'%';
else if(ssn!='') then
SELECT SQLStatement = SQLStatement+and_or+' SSN Like '+ssn+'%';
else if(email!='') then
SELECT SQLStatement = SQLStatement+and_or+' EMail Like '+email+'%';
else if(gtxkey!='') then
SELECT SQLStatement = SQLStatement+and_or+' GTXKey Like '+gtxkey+'%';
else if(dcn!='') then
SELECT SQLStatement = SQLStatement+and_or+' DCN Like '+dcn+'%';
else if(pin!='') then
SELECT SQLStatement = SQLStatement+and_or+' PIN Like '+pin+'%';
else if((efileddate1!='' and efileddate1 != ' 00:00') and (efileddate2!='' and efileddate2 != ' 23:59')) then
SELECT SQLStatement = SQLStatement+and_or+' EFile_Created_Date BETWEEN '+efileddate1+' and '+efileddate2;
else if((paiddate1 != '' and paiddate1 != ' 00:00') and (paiddate2 != '' and paiddate2!= ' 23:59')) then
SELECT SQLStatement = SQLStatement+and_or+' Paid_Date BETWEEN '+paiddate1+' and '+paiddate2;
else if(efiled != '') then
SELECT SQLStatement = SQLStatement+and_or+' EFile_Status='+efiled;
else if(federalstatus != '') then
SELECT SQLStatement = SQLStatement+and_or+' Federal_EFile_Status='+federalstatus;
else if(pkg != '') then
Begin
SELECT SQLStatement = SQLStatement+and_or+' Package_Selected='+pkg;
End;
else if(cpaname != '') then
SELECT SQLStatement = SQLStatement+and_or+' CPA_Name Like'+cpaname;
else if(ExtraWHEREClause != '') then SELECT SQLStatement = SQLStatement+ ExtraWHEREClause;
else
SELECT SQLStatement ='SELECT '+colnames+' FROM user_states_ord_return_list ';
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
End IF;
End IF;
End IF;
End If;
End IF;
End IF;
SET colnames = SQLStatement;
End