在存储过程的MySql参数中传递数据集 [英] Pass a DataSet in MySql Parameter in Stored Procedure
本文介绍了在存储过程的MySql参数中传递数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
请帮帮我.
我需要在MySQL中传递数据集.
在MSSQL中这是可行的,因为我已经尝试过了.
我在MSSQL中是这样的:
在我的C#代码中:
Hi All,
Please help me.
I need to pass a DataSet in MySQL.
It is feasible in MSSQL since I already tried it.
I do it like this in MSSQL:
In my c# code:
DataSet ds = new DataSet("Uploads");
ds.Tables.Add(new DataTable("exclution"));
SqlCommand oCommand = new SqlCommand("spUpdateDatabase", oConnection);
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.Parameters.AddWithValue("@LocalDatabase", ds.GetXml());
我的存储过程将是这样的:
And my stored procedure would be like this:
DECLARE @index int
BEGIN TRANSACTION
EXEC sp_xml_preparedocument @index OUTPUT, @LocalDatabase
INSERT INTO exclution
SELECT @BranchCode
, ExclutionID
, InsuredID
, InsuredRelationship
, ExclutionDiagnoses
FROM OPENXML(@index, 'Uploads/exclution')
WITH ( ExclutionID int 'ExclutionID'
, InsuredID int 'InsuredID'
, InsuredRelationship varchar(45) 'InsuredRelationship'
, ExclutionDiagnoses varchar(100)'ExclutionDiagnoses')
EXEC sp_xml_removedocument @index
IF (@@ERROR <> 0)
BEGIN
ROLLBACK TRANSACTION
SELECT 1
END
ELSE
BEGIN
COMMIT TRANSACTION
SELECT 0
END
但是我找不到在MySQL中执行此操作的方法.
任何帮助将不胜感激.
在此先谢谢您.
But I cant find a way to do it in MySQL.
Any help would be greatly appreciated.
Thanks in advance.
推荐答案
MySQL文档可能是一个很好的起点
MySQL XML函数 [
The MySQL Documentation might be a good place to start
MySQL XML functions[^]
这篇关于在存储过程的MySql参数中传递数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文