mysql>CREATE FUNCTION HelloWorld4()
->RETURNS VARCHAR(20)
->BEGIN
-> RETURN 'Hello World!'
->END
->//
Query OK, 0 rows affected (0.00 sec)
mysql>select HelloWorld4() //
+---------------+
| HelloWorld4() |
+---------------+
| Hello World! |
+---------------+
1 row in set (0.00 sec) ...展开mysql>CREATE FUNCTION HelloWorld4()
->RETURNS VARCHAR(20)
->BEGIN
-> RETURN 'Hello World!'
->END
->//
Query OK, 0 rows affected (0.00 sec)
mysql>select HelloWorld4() //
+---------------+
| HelloWorld4() |
+---------------+
| Hello World! |
+---------------+
1 row in set (0.00 sec)
DELIMITER $$CREATE FUNCTION `ChkInsert`(in_pk int) returns int
begin
declare _count int
declare _returnValue int
set _count = 0
select count(列1) into _count from 你的表 where 列1 = in_pk
if _count >0 then
set _returnValue = 2
else
insert into 你的表 ( 列1 ) values ( in_pk )
set _returnValue = 0
end if
return _returnValue
end $$
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)