MySQL中自定义函数总是报错?

测试从一个表中提取出不重复得名字个数,建立的函数执行一直报错,求解
函数:

create function nameNum() returns int
begin
    declare a int;
    select count(distinct name) from score into a;
    return a;
end;

报错:/* SQL错误(1064):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 a' at line 1 */

1个回答

我这里复制直接执行成功了,可能要看下是不是你装的mysql是不是有问题,或者中英文写错了,或者设置编码有问题。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
自定义函数报错
[code=SQL]rncreate function GetRoHSMain()rnRETURNS TABLErnasrnBEGINrn declare @tb table(id int identity,stype varchar(20))rn insert into @tb(stype)rn select '通过' union allrn select '退回' union allrn select '待审核' union allrn select '审核中' union allrn select '编辑中' rn return SELECT ma.mat_id, ma.filestate, ma.cause, ma.stype,rn ma.material, ma.mat_num, ma.FaMatNum, ma.updatetime, rn t.stype AS fstate rn FROM rohs_material_main AS ma CROSS JOIN @tb as trn WHERE (ma.filestate = t.id) AND (ma.state = 1)rnENDrn[/code]rnrn[color=#FF0000]错误rn消息 102,级别 15,状态 31,过程 GetRoHSMain,第 17 行rn'BEGIN' 附近有语法错误。[/color]rnrn单独执行rn[code=SQL]rndeclare @tb table(id int identity,stype varchar(20))rn insert into @tb(stype)rn select '通过' union allrn select '退回' union allrn select '待审核' union allrn select '审核中' union allrn select '编辑中' rn SELECT ma.mat_id, ma.filestate, ma.cause, ma.stype,rn ma.material, ma.mat_num, ma.FaMatNum, ma.updatetime, rn t.stype AS fstate rn FROM rohs_material_main AS ma CROSS JOIN @tb as trn WHERE (ma.filestate = t.id) AND (ma.state = 1)rn[/code]rn正常rnrn如何更改?
mysql中自定义函数出错
照着下面这个输入rnrnmysql> delimiter //rn rnmysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)rn -> RETURN CONCAT('Hello, ',s,'!');rn -> //rnrnrn执行后 rnrnERROR 1307 (HY000):Failed to CREATE FUNCTION hellornrnrn这个错误是什么情况 求解释。。。
MySQL中的自定义函数
1、自定义函数create function f1() returns varchar(20) return date_formate(now(), '%Y年%m月%d日 %H时%i分%s秒); 2、有参函数create function f2(num1 float, num2 float) returns float(10,2) return (num1 + num2)/2; 3、有参聚合函数
MYSQL中自定义函数的问题
[code=SQL]CREATE FUNCTION `zrcrmdb`.`format_phone`(old_phone varchar(15))rn RETURNS varchar(15)rn BEGINrn DECLARE new_phone varchar(15)rn IF LENGTH(old_phone)=8 THENrn SET new_phone=concat('025',old_phone)rn ELSErn SET new_phone=old_phonern END IFrn RETURN new_phonern END[/code]rnrn错误如下:rnrnError Code : 1064rnYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF LENGTH(old_phone)=8 THENrn SET new_phone=concat('025',old_phone)rn ELSErn SET ' at line 5rnrnExecution Time : 00:00:00:000rnTransfer Time : 00:00:00:000rnTotal Time : 00:00:00:000rnrn请求帮助解决。。。
mysql等值连接问题,总是报错
![图片说明](https://img-ask.csdn.net/upload/201511/15/1447559275_779995.png)
mysql 建立procedure总是报错
问题描述:  在mysql 5.6中建立一个procedure,报错如下: product)root@localhost [lots]> CREATE PROCEDURE per2()      -> BEGIN DECLARE num INT; ERROR 1064 (42000): You have an error in your SQL syntax; check the man
Linux下安装Mysql总是报错
我的Linux版本是Ubuntu 14.04.1 LTSrnrn执行到make步骤时,总是报错,报错信息如下:rnrnreadline.c:(.text+0x2bd3): warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrn../cmd-line-utils/libedit/libedit.a(filecomplete.o): In function `fn_tilde_expand':rnfilecomplete.c:(.text+0x114): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrnfilecomplete.c:(.text+0x84): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrn../cmd-line-utils/libedit/libedit.a(readline.o): In function `username_completion_function':rnreadline.c:(.text+0x2bff): warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrnreadline.c:(.text+0x2be1): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrn../libmysql/.libs/libmysqlclient.a(my_net.o): In function `my_gethostbyname_r':rnmy_net.c:(.text+0x2e): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrn../libmysql/.libs/libmysqlclient.a(libmysql.o): In function `mysql_server_init':rnlibmysql.c:(.text+0x2a75): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingrn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_move_to_char':rnterm.c:(.text+0x905): undefined reference to `tgoto'rnterm.c:(.text+0x91f): undefined reference to `tputs'rnterm.c:(.text+0x92c): undefined reference to `tgoto'rnterm.c:(.text+0x947): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_move_to_line':rnterm.c:(.text+0xafd): undefined reference to `tgoto'rnterm.c:(.text+0xb17): undefined reference to `tputs'rnterm.c:(.text+0xc1e): undefined reference to `tgoto'rnterm.c:(.text+0xc39): undefined reference to `tputs'rnterm.c:(.text+0xca4): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_deletechars':rnterm.c:(.text+0xe8c): undefined reference to `tputs'rnterm.c:(.text+0xecd): undefined reference to `tputs'rnterm.c:(.text+0xf25): undefined reference to `tgoto'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_insertwrite':rnterm.c:(.text+0x1032): undefined reference to `tputs'rnterm.c:(.text+0x105e): undefined reference to `tgoto'rnterm.c:(.text+0x1079): undefined reference to `tputs'rnterm.c:(.text+0x1146): undefined reference to `tputs'rnterm.c:(.text+0x1166): undefined reference to `tputs'rnterm.c:(.text+0x11c1): undefined reference to `tputs'rnterm.c:(.text+0x11e6): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o):term.c:(.text+0x12fb): more undefined references to `tputs' followrn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_set':rnterm.c:(.text+0x1d47): undefined reference to `tgetent'rnterm.c:(.text+0x1d63): undefined reference to `tgetflag'rnterm.c:(.text+0x1d77): undefined reference to `tgetflag'rnterm.c:(.text+0x1d8b): undefined reference to `tgetflag'rnterm.c:(.text+0x1d9f): undefined reference to `tgetflag'rnterm.c:(.text+0x1db3): undefined reference to `tgetflag'rn../cmd-line-utils/libedit/libedit.a(term.o):term.c:(.text+0x1dc7): more undefined references to `tgetflag' followrn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_set':rnterm.c:(.text+0x1ddb): undefined reference to `tgetnum'rnterm.c:(.text+0x1def): undefined reference to `tgetnum'rnterm.c:(.text+0x1e11): undefined reference to `tgetstr'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_echotc':rnterm.c:(.text+0x2ca6): undefined reference to `tgetstr'rnterm.c:(.text+0x2dc0): undefined reference to `tgoto'rnterm.c:(.text+0x2de0): undefined reference to `tputs'rnterm.c:(.text+0x2e71): undefined reference to `tgoto'rnterm.c:(.text+0x2e8e): undefined reference to `tputs'rnterm.c:(.text+0x2eb3): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_deletechars':rnterm.c:(.text+0xf07): undefined reference to `tputs'rnterm.c:(.text+0xf45): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o): In function `term_clear_EOL':rnterm.c:(.text+0x1279): undefined reference to `tputs'rn../cmd-line-utils/libedit/libedit.a(term.o):term.c:(.text+0x1326): more undefined references to `tputs' followrncollect2: error: ld returned 1 exit statusrnmake[2]: *** [mysql] Error 1rnmake[2]: Leaving directory `/home/ubuntu/usr/local/src/mysql/mysql-5.0.95/client'rnmake[1]: *** [all-recursive] Error 1rnmake[1]: Leaving directory `/home/ubuntu/usr/local/src/mysql/mysql-5.0.95'rnmake: *** [all] Error 2rnrn由于刚接触Linux下安装mysql,网上搜不到相似的情形,实在不知道该如何去做,还望前辈指点
MySQL自定义函数
UDF(user-dinfine function,UDF)自定义函数 自定义函数的两个必要条件: (1)参数 (2)返回值 创建自定义函数: CREATE FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL} routine_body 函数体: (1)函数体由合法的SQL语句构成 (2)函数体可以是简单的S
mysql 自定义函数
Mysql自定义函数 [url]http://www.bccn.net/Article/sjk/mysql/jszl/200610/4518.html[/url] MySQL procedure 与 function 的区别 [url]http://www.cnblogs.com/cy163/archive/2008/10/15/1311969.html[/url] mysql自定...
mysql自定义函数
mysql自定义函数完成项目功能 CREATE FUNCTION `get_out_storage_qty` ( bill_codes VARCHAR(64), symbol INTEGER ) RETURNS INTEGER BEGIN DECLARE v1 VARCHAR(20); if symbol = 0 THEN SET v1 = '+' ; ELSE S
MySQL 自定义函数
自定义函数 用户自定义函数(user-defined function,UDF)是一种对MySQL扩展的途径,其用法与内置函数相同。   语句结构 CREATE FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL} routine_body 函数体(routine_body) 由合法的SQL语句构成 可以是简...
MySQL—自定义函数
函数 本文是在 navicat 中演示如何创建 自定义函数 ,建议先去看有关的书籍了解一下。我之前分享过一篇 《MySQL 8》的资料 可以参考一下。因为是 navicat 是客户端工具,所以他会给我们省去一些操作,比如 ; 的转义; 参数都是在 新建函数的窗口 里定义而不是在代码里定义了。所以说 先看书,因为书中是 纯代码 实现的,而本文是在数据库客户端工具里实现的。 操作 通过商品ID,...
MySQL之自定义函数
自定义函数:用户定义函数(UDF)是一种对MySQL扩展的途径,其用法与内置函数相同;自定义函数需要两个必要条件:参数和返回值;函数可以返回任意类型的值,同样可以接收这些类型的参数,最多1024个参数; 1.创建自定义函数: CREATE FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL} routine_body(函数体
MYSQL——自定义函数
自定义函数 用户自定义函数(user-defined function,UDF)是一种对MySQL扩展的途径,其用法与内置函数相同。 函数可以返回任意类型的值,同样可以接收任意类型的值。接收和返回两者没有必然关系。 2个必要条件 1.参数 2.返回值 创建自定义函数 CREATE FUNCTION 函数名(参数名1 类型1,参数名2 类型2,…) RETURNS 返回类型 {STRI
Mysql自定义函数
1.自定义函数的要素: 函数名参数列表函数体返回值 2.语法 定义:    Create function  函数名(参数列表) 返回类型    函数体   注:这里的返回类型必须要是mysql的类型,varchar() int 等等 例子:  delimiter $$ create function say() returns varchar(200) begin ret
mysql ---自定义函数
自定义函数 函数可以返回任意类型的值,同样可以接收这些类型的参数 关于函数体 函数体由合法的SQL语句构成 函数体可以是简单的SELECT或INSERT语句 函数体如果为复合结构则是用BEGIN..END语句; 复合结构可以包含声明,循环,控制结构。 创建不带参数的自定义函数 SET NAMES gbk   这
MySQL | 自定义函数
一、是什么 用户自己定义函数 由于设计函数的每一条指令都是一个独立的个体,因此需要语句结束符,因为函数是一个整体,且不能被中断。MySQL 一旦见到语句结束符就会自动开始执行 解决方案 在定义函数之前,修改临时的语句结束符 ; 在 MySQL 中使用 delimiter 来修改临时语句结束符。默认情况下,delimiter是分号 ; 在命令行客户端中,如果有一行命令以分号结束,那么回车后,mysq...
MySQL 自定义函数
用户自定义函数(user-defined function,UDF)是一种对MySQL扩展的途径,其用法与内置函数相同。 自定义函数的两个必要条件: 参数 返回值. 函数可以返回任意类型的值,同样可以接收这些类型的参数 创建自定义函数 CREATE FUNCTION function_ name RETURNS { STRING | INTEGER | REAL | D...
mysql之自定义函数
本文内容:   什么是函数 函数的创建 函数的调用 函数的查看 函数的修改 函数的删除   首发日期:2018-04-18 什么是函数:   函数存储着一系列sql语句,调用函数就是一次性执行这些语句。所以函数可以降低语句重复。【但注意的是函数注重返回值,不注重执行过程,所以一些语句无法执行。所以函数并不是单纯的sql语句集合。】 mysql函数有自己的自定义函数(已经定义...
MYSQL 自定义函数
1、创建函数 create function getSex(param1 int(11))  returns varchar(10) BEGIN     DECLARE result varchar(10);     IF param1 = 1 THEN         set result='男';     ELSEIF param1 = 2 THEN         set re
Mysql 自定义函数
Mysql 自定义函数怎么用rnrn[code=php]rnCREATE FUNCTION `strip_tags`($str text) RETURNS text rnrnBEGIN rnrn DECLARE $start, $end INT DEFAULT 1; rnrn LOOP rnrn SET $start = LOCATE("<", $str, $start); rnrn IF (!$start) THEN RETURN $str; END IF; rnrn SET $end = LOCATE(">", $str, $start); rnrn IF (!$end) THEN SET $end = $start; END IF; rnrn SET $str = INSERT($str, $start, $end - $start + 1, ""); rnrn END LOOP; rnrnEND;rn[/code]
(9)mysql 中的存储过程和自定义函数
概述 存储过程和自定义函数是事先经过编译并存储在数据库中的一段SQL语句的集合。相对普通查询优点: 可以简化应用开发人员的工作,可重用。 减少数据库与应用服务器之间的数据传输。 提高了数据处理的效率。 安全性提高。由于存储过程也可以使用权限控制,而且参数化的存储过程可以防止SQL注入攻击,也在一定程度上保证了安全性。 存储过程与函数的区别在于函数必须有返回值,而存储过程没有,存储过程的参数可以...
delphi 引用自定义函数报错
[code=Delphi(Pascal)]rnfunction TCard.CardNo(PeoNo: string): Boolean;rnbeginrn Form1.qry2.Close;rn Form1.qry2.SQL.Clear;rn Form1.qry2.SQL.Add('select * from Card where CardNo='''+CardNo+''' and cardstatus NOT IN (''''正常'''')' );rn Form1.qry2.Open;rn if Form1.qry2.Eof thenrn Result:=Falsern elsern Result:=True;rnend;rnrnrn if Card.CardNo(edt1.text)=False thenrn beginrn Application.MessageBox('xxx!','xx');rn edt1.Clear;rn edt1.SetFocus;rn Exit;rn end;rnrnrn[/code]rnrn报错:Project1.exe raised exception class EOleException with message '第一行:‘正常’附近有语法错误。'.rnrnProcess stopped. Use Step or Run to continue
自定义函数 报错问题
我想自己写个函数实现把字符串按照 汉字,非汉字进行分隔成2个字符串rn比如‘aaa天ddd' 分割成’aaaddd'和'天'rn我写的是这样。(参数2用来控制用户到底要返回汉字字符串还是飞汉字字符串)rn只是针对我的思路来提供解决,不要告诉我换个思路。返回类型设置成表这样的。rncreate function [dbo].[spilt_eng_chinese]rn(@char varchar(1000),@type int)rnreturns varchar(1000)rnas rnbegin rndeclare @eng varchar(1000)='',@chinese varchar(1000)=''rnif (@type not in(1,2))rnreturn '参数2必须是1或者0'rnelse rnbegin rnwhile PATINDEX('%[吖-咗]%',@char)>0rnbegin rn set @chinese=@chinese+SUBSTRING(@char,PATINDEX('%[吖-咗]%',@char),1)rn set @char=STUFF(@char,PATINDEX('%[吖-咗]%',@char),1,'')rn end rn set @eng=@charrn endrnif(@type=1)rn return @eng rnelsernreturn @chinesern end rnrn我现在有2个问题rn1,我先写判断@type 如果不是0或者1,直接报错‘参数2必须是0或者1’我这种不行。rn2,后面报错。提示函数的最后一行必须是返回值。rn没写过自定义函数。不太懂。rn
这个自定义函数为什么报错?
是不是结构出了问题?rn提示这一句有问题:select snum as 累计 from @tt where i=@UsedMonth rnrn大家帮看看..谢了rnrnrn[code=SQL]rnCREATE FUNCTION FindDisc(@Deadline int,@price decimal(18,2),@UsedMonth int)rnRETURNS varchar(25) AS rnrnBEGIN rndeclare @Str varchar(25)rndeclare @uyear int,@desc decimal(18,2)rndeclare @i int,@num decimal(18,2),@snum decimal(18,2),@tot decimal(18,2)rndeclare @tt table (i int,num decimal(18,2),snum decimal(18,2),nowpric decimal(18,2))rn--初始化变量rnset @i=1rnset @uyear= @Deadline/12rnset @desc=2/@uyearrnset @num=@price*@desc/12rnset @snum=@numrnbeginrnwhile @i<=(@uyear*12)rnbeginrninsert @tt select @i,@num,@snum,@price-@numrnset @snum=@snum+@numrnset @price=@price-@num rnrn if @i%12=0 and (@i-1)/12<@uyear-2 --1-3年rn beginrn if (@i+1)%12>@i%12rn beginrn set @snum=@snum-@numrn set @num=@price*@desc/12rn set @snum=@snum+@numrn endrn endrnrn if @i%12=0 and (@i-1)/12=2 --最后两年rn beginrn set @snum=@snum-@numrn set @num=@price/24rn set @snum=@snum+@numrn endrn rn set @i=@i+1rnrnendrnendrnrnselect snum as 累计 from @tt where i=@UsedMonth /*这一句出问题*/rnGOrnreturn 累计rnrnENDrnrnrnrn[/code]
smarty config_load 和 自定义函数 报错
[color=#000000]temp.tpl[/color]rn[code=HTML]config_load file="../configs/a.conf"rn#s#[/code]rn[color=#000000]a.conf[/color]rn[code=HTML]s='测试测试'[/code]rn[color=#000000]报错[/color]rnFatal error: Uncaught exception 'SmartyException' with message 'Unable to read config file '../configs/a.conf'' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_resource_file.php:68 Stack trace: #0 C:\wamp\www\smarty\libs\sysplugins\smarty_config_source.php(86): Smarty_Internal_Resource_File->getContent(Object(Smarty_Config_Source)) #1 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_config_file_compiler.php(81): Smarty_Config_Source->__get('content') #2 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_config.php(189): Smarty_Internal_Config_File_Compiler->compileSource(Object(Smarty_Internal_Config)) #3 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_config.php(214): Smarty_Internal_Config->compileConfigSource() #4 C:\wamp\www\smarty\templates_c\187938f6ec55068ed23f0f2de8d126b1ae3149c7.file.temp.tpl.php(36): Smarty_Internal_Config->loadConfigVars(NULL, 'local') #5 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php(180): content_4fb7f6591b8ab2_26457252(Object(Smarty_Internal_Template)) #6 C:\w in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_resource_file.php on line 68rnrnrn[color=#000000]自定义函数[/color]rn[code=PHP]register_function("doloop","myfun");rn $smarty->display("temp.tpl");rn?>[/code]rnrn[color=#000000]temp.tpl[/color]rn[code=HTML]doloop times="5"[/code]rnrn[color=#000000]报错[/color]rnFatal error: Uncaught exception 'SmartyException' with message 'Call of unknown method 'register_function'.' in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php:806 Stack trace: #0 [internal function]: Smarty_Internal_TemplateBase->__call('register_functi...', Array) #1 C:\wamp\www\smarty\smarty.php(62): Smarty->register_function('doloop', 'myfun') #2 main thrown in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php on line 806rnrn[color=#0000FF]我从smarty官方网站上下载了Smarty 3.1.8 [Smarty-stable.zip] Feb 20th, 2012文件啊rnstable这个单词是稳定的意思 我就下了这个包 解压后 我把里面的libs文件夹拷贝到我的www/smarty目录下,rn其它像在temp.tpl模板里运行$smarty.server.SERVER_ADDR这个语句可以正常显示啊,为什么就运行上面的config_load和自定义函数就不行啊rn[/color]
Mysql notifier 总是报错的问题 求教
[img=https://img-bbs.csdn.net/upload/201410/28/1414498364_578353.jpg][/img]
为什用Navicat for MySQL总是报错
[img=https://img-bbs.csdn.net/upload/201609/16/1473956265_976814.png][/img]
连接mysql总是报错:ClassNotFoundException(Class.forName(driverName);)
安装了mysql,导入了驱动。但是每次连接总是报错。代码如下:rnprivate String driverName="org.gjt.mm.mysql.Driver";rn private String url= "jdbc:mysql://localhost:3306/PH";rn private String user="root";rn private String password="root";rn private Connection conn=null;rn rn public DBConnection()rn rn tryrn rn Class.forName(driverName);rn conn=DriverManager.getConnection(url,user,password);rn rn catch(Exception e)rn e.printStackTrace(); rn rn rn 。。。。rnrn报错信息如下:rnjava.lang.ClassNotFoundException:com.mysql.jdbc.Driver in EnvironmentClassLoader[web-app:http://localhost:8080/PetHospital]rn at com.caucho.loader.DynamicClassLoader.loadClass(DynamicClassLoader.java:1224)rn at com.caucho.loader.DynamicClassLoader.loadClass(DynamicClassLoader.java:1203)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:169)rn at com.sjh.dbc.DBConnection.(DBConnection.java:16)rn at com.sjh.dao.proxy.UserDAOProxy.(UserDAOProxy.java:16)rn at com.sjh.dao.factory.DAOFactory.getUserDaoInstanceof(DAOFactory.java:12)rn at com.sjh.servlet.loginServlet.doPost(loginServlet.java:33)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:153)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)rn at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)rn at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)rn at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)rn at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)rn at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)rn at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:730)rn at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:649)rn at java.lang.Thread.run(Thread.java:619)rn
Python传mysql语句总是报错
[code=python]from selenium import webdriverrn#将列表里的信息,存入数据库rndef SaveSQL(paperLinks,Teaname):rn infos = []rn for i in paperLinks:rn html = urlopen(i)rn bs0bj = BeautifulSoup(html,"html.parser")rnrn title = bs0bj.find("h2",class_='title').text#.encode()rn fund = bs0bj.find_all("div",'class':'wxBaseinfo')[0].find_all('p')[1].text#.encode()rn keyWord = bs0bj.find_all("div",'class':'wxBaseinfo')[0].find_all('p')[2].text#.encode()rn info=title+' '+fund+ ' '+keyWordrn infos.append(info)rn #print(title + fund + keyWord)rn sql_2 = 'update teacher set information=%s where Tname=%s' % (infos, Teaname)rn cur.execute(sql_2) #报错的地方rn conn.commit()rn[/code]rnrncur.execute(sql_2)这个地方报错,错误是:pymysql.err.ProgrammingError: (1064, "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 '['微博环境下高校网络舆情的监测与引导研究——以政治敏感' at line 1")rnrnsql_2语句里的infos和teaname我都输出过了,没有问题rn想要朋友们帮我看看我的sql_2语句到底哪里错了[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/5.gif][/img]rn
相关热词 c# login 居中 c# 考试软件 c# 自然语言分析 c# 分段读取文件 c# 泛型反射 c#打断点 c# 时间转多少秒 c# 线程函数加参数 c# modbus 读取 c#查询集合表