[英]MySQL Stored procedure WHERE
Im trying to set procedure for insert row and use the value from parameter to change value in other table. 我试图设置插入行的过程,并使用参数中的值更改其他表中的值。 But ...error, and me and Google = no solution...
但是...错误,我和Google =无法解决...
INSERT INTO transakce (`id_transakce`, `akce_uzivatele_id`, `typ_transakce`, `castka`, `datum_sazky`)
VALUES (NULL, _akceuzivateleid ,_typ_transakce,_castka, _datum);
SET kreditUzivatele := SELECT ` kredit` FROM `uzivatele` WHERE uzivatele.id_uzivatele = _akceuzivateleid ;
SET kreditUzivatele := kreditUzivatele + _castka;
UPDATE `uzivatele` SET `kredit` := kreditUzivatele WHERE uzivatele.id_uzivatele = _akceuzivateleid ;
One or more errors have occurred while processing your request: The following query has failed: "CREATE DEFINER=
marek
@%
PROCEDUREcreditCharge
(IN_akceuzivateleid
INT(9), IN_typ_transakce
VARCHAR(20) CHARSET utf8, IN_castka
INT, IN_datum
TIMESTAMP) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY INVOKER INSERT INTO transakce (id_transakce
,akce_uzivatele_id
,typ_transakce
,castka
,datum_sazky
) VALUES (NULL, _akceuzivateleid ,_typ_transakce,_castka, _datum); SET kreditUzivatele := SELECTkredit
FROMuzivatele
WHERE uzivatele.id_uzivatele = _akceuzivateleid ; SET kreditUzivatele := kreditUzivatele + _castka; UPDATEuzivatele
SETkredit
:= kreditUzivatele WHERE uzivatele.id_uzivatele = _akceuzivateleid ; " MySQL said: #1064 - You have an error in your SQL syntax;处理您的请求时发生一个或多个错误:以下查询失败:“ CREATE DEFINER =
marek
@%
PROCEDUREcreditCharge
(IN_akceuzivateleid
INT(9),IN_typ_transakce
VARCHAR(20)CHARSET utf8,IN_castka
INT,IN_datum
TIMESTAMP )NOT DETERMINISTIC修改SQL数据SQL SECURITY INVOKER INSERT INTO transakce(id_transakce
,akce_uzivatele_id
,typ_transakce
,castka
,datum_sazky
)VALUES(NULL,_akceuzivateleid,_typ_transakce,_castka,_datum); SET kreditUzivatele:= SELECTkredit
FROMuzivatele
WHERE uzivatele.id_uzivatele = _akceuzivateleid ;; SET kreditUzivatele:= kreditUzivatele + _castka; UPDATEuzivatele
SETkredit
:= kreditUzivatele WHERE uzivatele.id_uzivatele = _akceuzivateleid;“ MySQL说:#1064-您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET kreditUzivatele := SELECTkredit
FROMuzivatele
WHERE uzivatele.id_uzi' at line 4检查对应于你的MySQL服务器版本使用附近的正确语法手册“SET kreditUzivatele:= SELECT
kredit
FROMuzivatele
WHERE uzivatele.id_uzi”第4行
Can you try changing the below statement: 您可以尝试更改以下语句:
SET kreditUzivatele := SELECT ` kredit` FROM `uzivatele` WHERE uzivatele.id_uzivatele = _akceuzivateleid ;
to this: 对此:
DECLARE kreditUzivatele;
SELECT ` kredit` into kreditUzivatele FROM `uzivatele` WHERE uzivatele.id_uzivatele = _akceuzivateleid ;
or this: 或这个:
DECLARE kreditUzivatele;
SET kreditUzivatele = (SELECT ` kredit` FROM `uzivatele` WHERE uzivatele.id_uzivatele = _akceuzivateleid);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.