Mysql : Not allowed to return a result set from a function

前端 未结 2 1835
陌清茗
陌清茗 2021-01-27 17:46

I have write one function but getting this error Not allowed to return a result set from a function

DEL         


        
相关标签:
2条回答
  • 2021-01-27 18:02

    Mysql complains about SELECT statement in your function,

    probably it understands SELECT p_KeyValue = ListName + '.' + Value as comparison

    change it to

    SELECT CONCAT(ListName, '.', Value) INTO p_KeyValue
    
    0 讨论(0)
  • 2021-01-27 18:18

    You want to assign the result of a query to a variable, but in fact you're just selecting. That's why MySQL's complaining.

    You have to change this

                SELECT  p_KeyValue = ListName + '.' + Value
                FROM ListsTable
                WHERE EntryID = p_ParentID  LIMIT 1 ;
    

    to

                SELECT CONCAT(ListName, '.', `Value`)
                INTO p_KeyValue
                FROM ListsTable
                WHERE EntryID = p_ParentID  LIMIT 1 ;
    

    And you should add an ORDER BY. A LIMIT without ORDER BY doesn't make sense, since there's no guaranteed order in a relational database.

    0 讨论(0)
提交回复
热议问题