2
나는이 방법이 있습니다오류 1064 MySQL의 저장 프로 시저에는
CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_billing_details`()
BEGIN
DECLARE offsetcount INTEGER DEFAULT 0;
DECLARE totalcount INTEGER DEFAULT 0;
set totalcount = (select count(*) from new.billing);
loopall: LOOP
BEGIN
DECLARE v_finished INTEGER DEFAULT 0;
DECLARE c_subsid varchar(100) DEFAULT "";
DECLARE c_duedate varchar(100) DEFAULT "";
DECLARE c_descriptions varchar(100) DEFAULT "";
DECLARE c_debitamt varchar(100) DEFAULT "";
DECLARE c_transdate varchar(100) DEFAULT "";
DECLARE c_cursor CURSOR FOR
SELECT subsid, descriptions, debitamt, transdate FROM new.billing limit 200 offset offsetcount;
-- declare NOT FOUND handler
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET v_finished = 1;
OPEN c_cursor;
loopbilling: LOOP
FETCH c_cursor INTO c_subsid, c_descriptions, c_debitamt, c_transdate;
IF v_finished = 1 THEN
LEAVE loopbilling;
END IF;
insert into sakura.customer_bill_items (type ,name, description, amount, created_at) values (if(c_descriptions = "balance", 4, if(c_descriptions = "subscription", 1 , if((c_descriptions like "%modem%" or c_descriptions like "%amplifier%" or c_descriptions like "%power supply%"), 2 , 3))) ,c_descriptions, c_descriptions, c_debitamt, c_transdate);
insert into sakura.customer_monthly_bill_items (customer_id, bill_item_id, start_billing_date) values ((select a.id from sakura.customer a where a.subscriber_id = c_subsid), last_insert_id(), c_transdate);
insert into sakura.customer_billing_details (bill_item_id, subscription_plan_id, bill_item_amount) values (last_insert_id(), (select subscription_plan_id from sakura.customer_subscriptions where customer_id = (select id from sakura.customer where subscriber_id = (select subsid from new.subscriber where subsid = c_subsid))), c_debitamt);
insert into sakura.customer_billing_header (customer_id) select a.id from sakura.customer a where a.subscriber_id = c_subsid;
update sakura.customer_billing_details set header_id = last_insert_id() where id = last_insert_id();
END LOOP loopbilling;
CLOSE c_cursor;
END;
set offsetcount = offsetcount + 200;
IF offsetcount >= totalcount THEN
LEAVE loopall;
END IF;
end LOOP loopall;
END
을하고 내 컴퓨터에서 제대로 작동하지만 서버에서 실행하려고 할 때, 그것은으로 반환
ERROR 1064 : SQL 구문에 오류가 있습니다. 정확한 구문에 대해서는 매뉴얼을 확인하십시오. 찾지 못했음을 선언하는 계속 진행자 v_finished = 1; OP 'on line 31
저는 Workbench 5.5.54를 사용 중이며 서버는 5.1.66을 실행 중입니다. 나는 몇 시간 동안 대답을 찾고 있었지만 나는 운이 없다. 누군가가 도움이되기를 바랍니다. 감사!
배치가 필요하므로 시간 초과가 발생하는 너무 많은 레코드를 실행 중이므로이 오프셋이 필요합니다. –
변수가있는 오프셋은 10이 아닌 실제 숫자 또는 변수가 아닌 숫자로 변경하는 대신 작동하지 않습니다. –
하지만 내 모든 데이터를 반복 할 수 있도록 증가해야합니다. 내 PC에서 실행할 수는 있지만 서버에서는 실행할 수 없습니다. 내 PC가 최고급이 아니므로 서버를 사용해야합니다. –