开发者

Sql insert as a "insert block" method

开发者 https://www.devze.com 2023-03-24 01:49 出处:网络
I need to insert data from Oracle to MySQL.开发者_Go百科 Like this. (For example query with two records (In real 500))

I need to insert data from Oracle to MySQL.

开发者_Go百科

Like this. (For example query with two records (In real 500))

INSERT INTO test_table
            (bill_balance, 
             prime_uid, 
             customer_id, 
             account_name, 
             phone, 
             street, 
             bill_dt, 
             account_no) 
VALUES      ('111', 
             '123456', 
             '1234-56789', 
             'My name is', 
             '20373359', 
             'Street name', 
             '1970-01-01 02:00:00', 
             '123456'), 
            ('2', 
             '123', 
             '123-123', 
             'TEST', 
             '', 
             'test 123', 
             '1970-01-01 02:00:00', 
             '123456789') 

I had this error:MySQL server has gone away.

In php I have made those settings:

error_reporting(E_ALL);

ini_set("memory_limit", "512M"); 
ini_set("max_execution_time", 0);
set_time_limit(0);

ini_set('display_errors','1');
ini_set('interactive_timeout', 3600);
ini_set('wait_timeout', 3600);
ini_set('mysql.connect_timeout', 60);
ini_set('mysql.allow_persistent', true);

it works, with simple "insert", It's not working with block insert method.


You probably exceeded the allowed packet size.
Compare the result of strlen($yourQuery)(+ some feasible margin) to the result of
SHOW VARIABLES LIKE 'max_allowed_packet'

see also: http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_allowed_packet

0

精彩评论

暂无评论...
验证码 换一张
取 消