我對supplier_search查詢是存儲過程的搜索..與空值
CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_Search`(in strLedgerName varchar(255),in strAddress varchar(255),
in inPhoneNo int(45), in inMobNo int(45), in strPriceLevel varchar(255),in strCountry varchar(255),in strState varchar(255))
BEGIN
if inPhoneNo = '' then SET inPhoneNo =Null ;end if;
if inMobNo = '' then SET inMobNo =Null ;end if;
if strLedgerName ='' then SET strLedgerName = Null; end if;
if strAddress ='' then set strAddress = null; end if;
if strPriceLevel = '' then set strPriceLevel = null; end if;
if strCountry = '' then set strCountry = null; end if;
if strState = '' then set strState = null; end if;
select ledgerName,address, phoneNo , mobNo ,priceLevel,stateName, CountryName from
(
select joined_ab.ledgerName,joined_ab.address ,joined_ab.phoneNo, joined_ab.mobNo ,joined_ab.priceLevel,c.countryName,joined_ab.stateId
from (select a.ledgerName, a.address , a.phoneNo , a.mobNo ,b.priceLevel,
a.countryId,a.stateId from tbl_ledger as a inner join tbl_price_level as b on a.pricingLevelId =b.priceLevelId)
as joined_ab inner join tbl_country as c on joined_ab.countryId = c.countryId
) as joined_abc inner join tbl_state
as d on joined_abc.stateId = d.stateId
where((strLedgerName is null or joined_abc.ledgerName LIKE concat(strLedgerName,"%"))
and(strAddress is null or address LIKE concat(strAddress ,"%"))
and(inPhoneNo is Null or phoneNo lIke concat(inPhoneNo , "%"))
and (strPriceLevel is null or priceLevel Like concat(strPriceLevel,"%"))
and(inMobNo is Null or mobNo Like concat(inMobNo , "%"))
and(strCountry is null or CountryName LikE concat(strCountry,"%"))
and(strState is null or StateName LikE concat(strState,"%")));
END
我想,當一個或一個以上的值傳遞給獲取輸出。 但問題是,當我不mobileNo或PHONENO傳遞價值和執行錯誤是
call db_account.supplier_Search('1', '', '', '', '', '', '')
Error Code: 1366. Incorrect integer value: '' for column 'inPhoneNo' at row 1 0.000 sec
是否有可能使用'null'值調用thw過程,如'調用db_account.supplier_Search('1','null,null,null,null,null,null)' – sevenforce
yes是可以的。你不是嗎? –