我在Mysql中的用户定义函数下面创建了该函数,希望该函数具有两个输入列名称和属性值。
CREATE FUNCTION hello123 (MAXRATEN CHAR(20),i int)
-> RETURNS VARCHAR(20)
-> NOT DETERMINISTIC
-> BEGIN
-> DECLARE select_var VARCHAR(20);
-> SET select_var = (SELECT MAXRATEN FROM ADM_METERQUEUE WHERE meterqueueid = i);
-> RETURN select_var;
-> END
Query OK, 0 rows affected (0.19 sec)
MySQL [usertest]> desc ADM_METERQUEUE 'maxrate05';
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| maxrate05 | varchar(10) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
我正在传递如下参数,尽管该属性存在于表中,但是却出现以下错误。
MySQL [usertest]> select hello123(maxrate05,38);
ERROR 1054 (42S22): Unknown column 'maxrate05' in 'field list'