|
|
|
Проблема с процедурой
|
|||
|---|---|---|---|
|
#18+
Добрый день Есть две таблицы: CREATE TABLE `trm_in_nomenclature` ( `nomenclature_id` int(11) NOT NULL DEFAULT '0', `name` varchar(100) NOT NULL DEFAULT '', `version` int(11) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`nomenclature_id`), KEY `version` (`nomenclature_id`,`version`,`deleted`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; и CREATE TABLE `trm_in_disc_std_items_n_plus_m` ( `nomenclature_id` int(11) NOT NULL DEFAULT '0', `item` varchar(40) NOT NULL DEFAULT '', `discount_type` bigint(20) NOT NULL DEFAULT '0', `quantity_paid` decimal(20,4) NOT NULL DEFAULT '0.0000', `quantity_without_paid` decimal(20,4) NOT NULL DEFAULT '0.0000', `modificator` varchar(40) NOT NULL DEFAULT '', `version` int(11) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`nomenclature_id`,`item`,`discount_type`), KEY `version` (`nomenclature_id`,`version`,`deleted`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; В trm_in_nomenclature хранятся номер и имя справочников товаров, а в trm_in_disc_std_items_n_plus_m - данные об акциях,привязанных к номерам справочников товаров (nomenclature_id), артикулах (item), типе акции (discount_type), остальное не важно. Задача такая - все акции одинаковые и чтобы не заполнять вручную каждую можно заполнить первую и её данные расклонировать на другие. Решил написать процедуру: CREATE PROCEDURE `new_proc1`( IN `acs` BIGINT ) NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT '' BEGIN for select `nomenclature_id` into v_nomenclature_id from `trm_in_nomenclature` where `nomenclature_id` <> 1; for select `item`,`discount_type`,`quantity_paid`,`quantity_without_paid`,`modificator` into v_item,v_discount_type,v_quantity_paid,v_quantity_without_paid,v_modificator from `trm_in_disc_std_items_n_plus_m` where `discount_type` = acs; do begin insert into `trm_in_disc_std_items_n_plus_m` set `nomenclature_id`=v_nomenclature_id,item=v_item,discount_type=v_discount_type,quantity_paid=v_quantity_paid,quantity_without_paid=v_quantity_without_paid,modificator=v_modificator; end END; но она не компилится,не могу понять в чем моя ошибка: 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 'for select `nomenclature_id` into v_nomenclature_id from `trm_in_nomenclature` w' at line 9 Помогите пожалуйста, раньше не писал процедуры на MySQL. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 21.06.2015, 23:29:51 |
|
||
|
Проблема с процедурой
|
|||
|---|---|---|---|
|
#18+
ошибка же указана Код: sql 1. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.06.2015, 08:21:47 |
|
||
|
Проблема с процедурой
|
|||
|---|---|---|---|
|
#18+
Gallemarfor selectdeclare cursor забыли? Gallemardoа это что? Вы на каком вообще языке писать пытаетесь? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.06.2015, 08:27:39 |
|
||
|
|

start [/forum/topic.php?fid=47&gotonew=1&tid=1833027]: |
0ms |
get settings: |
7ms |
get forum list: |
10ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
146ms |
get topic data: |
6ms |
get first new msg: |
4ms |
get forum data: |
2ms |
get page messages: |
35ms |
get tp. blocked users: |
1ms |
| others: | 256ms |
| total: | 471ms |

| 0 / 0 |
