mysql 如何调用函数结果_MySQL自定义函数调用不出结果

自定义函数的代码:

DROP FUNCTION IF EXISTS fn_HrStaffBase_GetNameFromidCard

delimiter //

CREATE FUNCTION fn_HrStaffBase_GetNameFromidCard (a VARCHAR(30))

RETURNS VARCHAR(50)

begin

return (SELECT staff_name   FROM hr_staff_base where idCard = a);

END //

-- ---------------------------------------------------------------------------------------------------------------------

函数调用查询:

select fn_HrStaffBase_GetNameFromidCard (‘299012234225‘)

-- ------------------------------------------------------------------------------

出来都是 null,

20180516114444488753.png

处理方法:

新建库时时,必须

也可以修改数据库设置:右键数据库,鼠标点击编辑数据库

要设置数据库如下图:

20180516114444854002.png

原来设置的是:

20180516114445160654.png

数据库只能读取拉丁值,无法读取中文

所以导致调用函数结果为:

20180516114444488753.png

-- ---------------------------------------------------------------

修改数据库设置后 ,查询结果出现:

20180516114445460470.png

#################################################################################

有时候mysql不能建立自定义函数是因为该功能2未开启

输入 show variables like ‘%func%‘; 命令

会看到 log_bin_trust_function_creators 的状态,如果是OFF表示自定义函数功能是关闭的

输入命令 set global log_bin_trust_function_creators=1;

可将 log_bin_trust_function_creators 开启自定义函数功能

但是这样设置是一个临时的方案,因为mysql自动重启后状态又会变为OFF,所以需要在

在服务启动时加上 “--log-bin-trust-function-creators=1 ”参数。 或在my.ini(my.cnf)中的[mysqld]区段中加上 log-bin-trust-function-creators=1。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441435.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【CodeForces - 1066A~E】水题,模拟(有技巧),思维,题意难懂的模拟,二进制问题(有技巧)

A. 题目大意: x坐标上1~L有L个点都是整数,每v个长度就有一个灯亮着,但是有 [ l , r ] 这段区间上有列火车挡住了,问你能看到多少亮灯。 解题报告: 大水题啊,找几个样例就会发现需要特殊处理一下左边界恰好…

【CodeForces - 987C 】Three displays (dp,最长上升子序列类问题,三元组问题)

题干: It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem. There are nn displays placed along a road, and the ii-th of th…

python中with open写csv文件_Python中的CSV文件使用with语句的方式详解

是否可以直接使用with语句与CSV文件?能够做这样的事情似乎很自然:import csvwith csv.reader(open("myfile.csv")) as reader:# do things with reader但是csv.reader不提供__enter__和__exit__方法,所以这不行.但是我可以分两步做&#xff1a…

【UVA - 11383】Claw Golden Tiger (二分图最优匹配,KM算法原理)

题干: 粘贴不过来。。。 题目大意: 500*500带权格子,每行每列要确定一个值,使row[i]col[j] > val[i][j],要使所有row值和col值的和最小 输出每行的row[i],和每列的col[i]。 解题报告: 跑一边KM&#…

git object 很大_这才是真正的Git——Git内部原理

本文以一个具体例子结合动图介绍了Git的内部原理,包括Git是什么储存我们的代码和变更历史的、更改一个文件时,Git内部是怎么变化的、Git这样实现的好处等等。TL;DR本文以一个具体例子结合动图介绍了Git的内部原理,包括Git是什么储存我们的代码…

【CodeForces - 195D】Analyzing Polyline (思维,卡精度的处理方式)

题干: As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son …

【CodeForces - 985D】Sand Fortress (二分,贪心,思维构造,技巧,有坑)

题干: You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbe…

mysql多实例脚本_mysql多实例脚本

mysql多实例脚本##mariadb和mysql-server的通用多实例脚本。vi mdp.sh 脚本内容参考内容如下#!/bin/bashecho ‘等待mariadb-server或mysql-server服务软件安装完毕’while truedoyum install -y mariadb-server mariadb &>/dev/nullyum install -y mysql-serv…

scrapy 分布式 mysql_Scrapy基于scrapy_redis实现分布式爬虫部署的示例

准备工作1.安装scrapy_redis包,打开cmd工具,执行命令pip install scrapy_redis2.准备好一个没有BUG,没有报错的爬虫项目3.准备好redis主服务器还有跟程序相关的mysql数据库前提mysql数据库要打开允许远程连接,因为mysql安装后root用户默认只允许本地连接,详情请看此文章部署过程…

(精)DEVC++的几个实用小技巧

依赖 DEV C 5.11 最新版 下载安装DEV C后,使用DEV C打开一个随便的cpp文件,你看到的应该是这样的界面。(为了节约读者的流量,图片进行了有损压缩,但是字看得清楚) 重点是确认工具栏有AStyle选项。 相信…

win10一按右键就闪屏_升级Win10正式版后屏幕一直闪烁正确的解决办法

Win10正式版屏幕一直闪烁怎么办呢?升级到Win10正式版并进入Windows桌面后,发现屏幕一直不断的闪烁,此时无法执行任务操作。小编最近在升级到Win10正式版后才遇到了这个问题,后台经过反复思考和探索,终于解决了问题&…

KMP 常用模板

写在前面: 代码中有的是i,j,有的是j,k,总之不唯一啊!!!这个一定要弄清楚!!!我没有统一。。 从0开始的字符串,加速版。 void getnext…

在spark的软件栈中_问:Spark Streaming是什么软件栈中的流计算?

问:Spark Streaming是什么软件栈中的流计算?A:不能确定,B:,C:,D:正确答案:绛旓細姣斿皵路鐩栬尐解析:问:Spark Streaming是什么软件栈中的流计算?A:不能确定,B:,C:,D:相关问题:“逻辑与”的运算符是( )。A:&&B:&C:…

【CodeForces - 195A】Let's Watch Football (追及问题,模拟)

题干: Valeric and Valerko missed the last Euro football game, so they decided to watch the games key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, i…

下面不是mysql特性_下面( )不是MySQL的特性。_学小易找答案

【单选题】如何检测 2型糖尿病【填空题】<5>以下do-while语句中循环体的执行次数是( ). a10; b0; do { b2; a-2b; } while (a>0);【单选题】2 型糖尿病 多 发在什么年龄段【填空题】<5>以下程序的输出结果为( )。 #include "stdio.h" main() {int a; …

*【CodeForces - 195B】After Training (多解,模拟)

题干&#xff1a; After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from l…

pandas打印全部列_python——pandas练习题1-5

练习1-开始了解你的数据探索Chipotle快餐数据相应数据集&#xff1a;chipotle.tsvimport pandas as pd chipopd.read_csv("exercise_data/chipotle.tsv",sept) chipo.head(5)chipo.shape[0] #查看有多少行4622chipo.shape[1] #查看有多少列5chipo.columns #打印所…

【POJ - 2406】Power Strings (KMP,最小循环节)

题干&#xff1a; Given two strings a and b we define a*b to be their concatenation. For example, if a "abc" and b "def" then a*b "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative in…

python wmi mac变动_Python WMI参数反转

使用python的wmi模块创建vss快照&#xff0c;我发现除非将它们反向&#xff0c;否则这些参数将不起作用&#xff1a;importwmidefvss_create():shadow_copy_servicewmi.WMI(monikerwinmgmts:\\\\.\\root\\cimv2:Win32_ShadowCopy)resshadow_copy_service.Create(ClientAccessib…

【 HDU - 2594 】Simpsons’ Hidden Talents(KMP应用,求最长前缀后缀公共子串)

题干&#xff1a; Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for example. I want to find out if I have a talent in politics, OK? Marge: OK. Homer: So I take…