MySQL Forums
Forum List  »  Newbie

Getting error while inserting xml formatted data into mysql
Posted by: ANurag Prajesh
Date: May 20, 2015 06:59AM

Hi,

I am getting below error while executing stored procedure for inserting xml file into mysql database.

I am using HeidiSQL 9.2.

Error Details : error 1136 column count doesn't match value count at row 1



Stored Procedure is:

CREATE DEFINER=`root`@`%` PROCEDURE `InsertBulkData`(IN `p_xml` TEXT, IN `xPathRow` VARCHAR(255))
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
declare v_row_index int unsigned default 0;
declare v_row_count int unsigned;
declare v_xpath_row varchar(255);

-- calculate the number of row elements.

set v_row_count := extractValue(p_xml,'count(/Employees/Employee)');

-- loop through all the row elements

while v_row_index < v_row_count do
set v_row_index := v_row_index + 1;
set v_xpath_row := concat(
xPathRow
, '['
, v_row_index
, ']'
);
insert into test values (
extractValue(p_xml,concat(v_xpath_row,'/Name[1]/text()'))
, extractValue(p_xml,concat(v_xpath_row,'/Company[2]/text()'))
);
end while;
END



XMl File is:

<?xml version="1.0"?>
<Employees>
<Employee>
<Name>Anurag</Name>
<Company>Omnie</Company>
</Employee>
</Employees>

Any Help...

Options: ReplyQuote


Subject
Written By
Posted
Getting error while inserting xml formatted data into mysql
May 20, 2015 06:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.