MySQL create function時報錯
MySQL create function時報錯
mysql> delimiter $$
mysql> CREATE FUNCTION is_ChangeDescColumnExist (THE_VERSION_LEVEL_TABLE_NAME VARCHAR(35)) RETURN INT DETERMINISTIC
-> BEGIN
-> DECLARE nbr INT;
-> SET nbr =0;
-> /* DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN 0;*/
-> select count(*) into nbr from information_schema.columns where table_name = THE_VERSION_LEVEL_TABLE_NAME and
-> (column_name ='C_CHANGE_DESCRIPTION');
-> IF nbr = 1 THEN
-> RETURN 1;
-> ELSE
ELSE ELSEIF
-> ELSE
-> RETURN 0;
-> END IF;
-> END$$
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURN INT DETERMINISTIC
BEGIN
DECLARE nbr INT;
SET nbr =0;
sel' at line 1
報錯原因:
RETURN INT DETERMINISTIC語句中返回關鍵字應該是RETURNS
修改後,建立函式正常
delimiter $$
CREATE FUNCTION is_ChangeDescColumnExist (THE_VERSION_LEVEL_TABLE_NAME VARCHAR(35)) RETURNS INT DETERMINISTIC
BEGIN
DECLARE nbr INT;
SET nbr =0;
/* DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN 0;*/
select count(*) into nbr from information_schema.columns where table_name = THE_VERSION_LEVEL_TABLE_NAME and
(column_name ='C_CHANGE_DESCRIPTION');
IF nbr = 1 THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
END$$
mysql> delimiter $$
mysql> CREATE FUNCTION is_ChangeDescColumnExist (THE_VERSION_LEVEL_TABLE_NAME VARCHAR(35)) RETURN INT DETERMINISTIC
-> BEGIN
-> DECLARE nbr INT;
-> SET nbr =0;
-> /* DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN 0;*/
-> select count(*) into nbr from information_schema.columns where table_name = THE_VERSION_LEVEL_TABLE_NAME and
-> (column_name ='C_CHANGE_DESCRIPTION');
-> IF nbr = 1 THEN
-> RETURN 1;
-> ELSE
ELSE ELSEIF
-> ELSE
-> RETURN 0;
-> END IF;
-> END$$
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURN INT DETERMINISTIC
BEGIN
DECLARE nbr INT;
SET nbr =0;
sel' at line 1
報錯原因:
RETURN INT DETERMINISTIC語句中返回關鍵字應該是RETURNS
修改後,建立函式正常
delimiter $$
CREATE FUNCTION is_ChangeDescColumnExist (THE_VERSION_LEVEL_TABLE_NAME VARCHAR(35)) RETURNS INT DETERMINISTIC
BEGIN
DECLARE nbr INT;
SET nbr =0;
/* DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN 0;*/
select count(*) into nbr from information_schema.columns where table_name = THE_VERSION_LEVEL_TABLE_NAME and
(column_name ='C_CHANGE_DESCRIPTION');
IF nbr = 1 THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
END$$
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2124694/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 關於使用toFixed()函式時報錯”toFixed() is not a function”的問題函式Function
- IDEA啟動時報Failed to create JVM錯誤的解決IdeaAIJVM
- oracle create function 例項2OracleFunction
- MySQL 授權時報錯 ERROR 1819MySqlError
- 啟動mysql時報錯的解決(mysql 5.0.45 redhat as 43)MySqlRedhat
- oracle create function的兩個例項OracleFunction
- PostgreSQL DBA(165) - pgAdmin(Create Function選項)SQLFunction
- MySQL建立觸發器時報錯Error Code: 1064MySql觸發器Error
- MySQL 8.0版本連線報錯:Could not create coMySql
- create table of mysql databaseMySqlDatabase
- 安裝PostgreSQL 時報錯SQL
- create pfile時報ORA-27037問題的處理
- MySQL 建立函式時報錯'ERROR 1336 (0A000): Dynamic SQL'MySql函式Error
- Kettle: create_sampledata_mysqlMySql
- dimp時報錯,字串截斷字串
- yii執行phpunit時報錯PHP
- 安裝informix for nt時報錯ORM
- PD連線oracle時報錯Oracle
- $(function{})裡面的onclick報錯Function
- Java專案連線資料庫Mysql報錯create connection SQLExceptionJava資料庫MySqlException
- MySQL 5.7 Invalid default value for 'CREATE_TIME'報錯的解決方法MySql
- 靜默安裝oracle時報錯Oracle
- 跪問:java編譯時報錯Java編譯
- 跪問:java編譯時報錯!!!Java編譯
- laravel11: 安裝時報錯Laravel
- php在iis上配置時報mysql_connect錯誤解決辦法PHPMySql
- mysql啟動時報錯Can't read from messagefile errmsg.sysMySql
- Laravel NO_AUTO_CREATE_USER 錯誤Laravel
- mysql主給備賦予許可權時報錯,MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clauseMySqlExpress
- 【MySQL】5.6.x sha256_password外掛登入使用者時報錯MySql
- MySQL5.6 create table原理分析MySql
- 使用 Composer 安裝 Laravel 時報錯Laravel
- laravel 資料庫遷移時報錯Laravel資料庫
- EF:開啟Oracle連線時報錯Oracle
- MUI-picker 報錯 getSelectedItem is not a functionUIFunction
- MySQL建立使用者報錯 ERROR 1396 (HY000): Operation CREATE USER failed for 'afei'@'%'MySqlErrorAI
- IE9 平時報錯,F12不報錯IE9
- pg_basebackup 報錯could not create directory