2013-03-22 73 views
0

當我運行MySQL工作臺即時得到上述的錯誤下面的代碼PLS確實有助於錯誤代碼:1292截斷不正確DOUBLE值:「和」

# IF p_Name is not null THEN 
#     SET m_sql = m_sql +' Name=''' + p_Name + ''' and '; 
# END IF; 


    If p_ReligionID is not null THEN 
        SET m_sql = m_sql + '" ReligionId= "' + 'CAST(p_ReligionID AS CHAR(30))' + 'and'; 
    END IF; 

    If p_CasteID is not null THEN 
        SET m_sql = m_sql + '" CasteId= "' + 'CAST(p_CasteID AS CHAR(30))' + 'and'; 

    END IF; 

    If p_CountryID is not null THEN 
        SET m_sql=m_sql+ '" Countryid= "' + 'CAST(p_CountryID AS CHAR(30))' + 'and'; 
    END IF; 

    If p_MotherTongueID is not null THEN 
        SET m_sql=m_sql+'" MotherTongueID= "' + 'CAST(p_MotherTongueID AS CHAR(30))' + 'and'; 
    END IF; 

回答

0

假設m_sql是入境和至少有效其中一個條件通過,最後的聲明以'和'結尾。這不是我知道的任何方言中的有效SQL。那麼你必須處理看似無關的引用。

我建議的與運算在後續的條件

If p_ReligionID is not null THEN 
       SET m_sql = m_sql + ' and ReligionId = ' + 'CAST(p_ReligionID AS CHAR(30))'; 
END IF; 

(我是一個SQL Server的人,所以MySQL的程序語言的具體細節超出了我的見識)

開頭插入
相關問題