473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How Import XML file in a table with trigger.

M6C
Hello,
I'm trying to import a Xml file in a table.
It's working find, but when the data are inserted, my trigger on this
table doesn't work ?

I put my code below.

Best regards

Thank's

David
Xml file :
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<RTAVIS>
<FILENAME>03-05-073.PDF</FILENAME>
<idvir>1030</idvir>
<code>9219142</code>
<mnt>4337,88 </mnt>
</RTAVIS>
Xsd file :
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >

<ElementType name="FILENAME" dt:type="string" />
<ElementType name="idvir" dt:type="string" />
<ElementType name="code" dt:type="string" />
<ElementType name="mnt" dt:type="string" />

<ElementType name="RTAVIS" sql:relation="ac_export_and_path">
<element type="FILENAME" sql:field="path" />
<element type="idvir" sql:field="numero_virement" />
<element type="code" sql:field="code_affilie" />
<element type="mnt" sql:field="montant_remise" />
</ElementType>

</Schema>

Vbs file:
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=*****;database=*****;uid=*****;pwd=*****"
objBL.ErrorLogFile = "C:\Temp\error.xml"
objBL.SchemaGen = True
objBL.CheckConstraints = True
objBL.KeepIdentity = False
objBL.BulkLoad = true
objBL.Execute "C:\Temp\9219142_MAPPING.xsd", "C:\Temp\9219142.xml"
Set objBL = Nothing
Trigger source code :

CREATE TRIGGER [dbo].[trg_ac_export_and_path] ON
dbo.ac_export_and_path
FOR INSERT
AS

DECLARE @id AS varchar(50)

SELECT @id = 'A'+convert(varchar, [id]) FROM inserted

INSERT INTO ac_path([id], [path]) SELECT @id, path FROM inserted

END

May 9 '07 #1
4 4674
M6C (ro********@gmail.com) writes:
I'm trying to import a Xml file in a table.
It's working find, but when the data are inserted, my trigger on this
table doesn't work ?
...
Vbs file:
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=*****;database=*****;uid=*****;pwd=*****"
objBL.ErrorLogFile = "C:\Temp\error.xml"
objBL.SchemaGen = True
objBL.CheckConstraints = True
objBL.KeepIdentity = False
objBL.BulkLoad = true
objBL.Execute "C:\Temp\9219142_MAPPING.xsd", "C:\Temp\9219142.xml"
Set objBL = Nothing
By default triggers don't fire when you bulk load. At least not regular
bulk load. I don't know if XML bulk load is any different. Regular
bulk load has an option to fire triggers. You may want to explorer
whether XML bulk load offers this too.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 10 '07 #2
M6C
On 11 mai, 00:23, Erland Sommarskog <esq...@sommarskog.sewrote:
By default triggers don't fire when you bulk load. At least not regular
bulk load. I don't know if XML bulk load is any different. Regular
bulk load has an option to fire triggers. You may want to explorer
whether XML bulk load offers this too.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
Thank you, but i don't find any information about an option to fire
triggers.
I will continue to looking for more informations about XML bulk load
options.

An other question, to circumvent my problem;
Can i make an operation in the Xsd file ?
I want to add an constant character to an column.
Can i modify the Xsd file to look like the following:

Best Regards

Thank's

David

<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >
<ElementType name="FILENAME" dt:type="string" />
<ElementType name="idvir" dt:type="string" />
<ElementType name="code" dt:type="string" />
<ElementType name="mnt" dt:type="string" />
<ElementType name="RTAVIS" sql:relation="ac_export_and_path">
<element type="FILENAME" sql:field="path" />
<element type="idvir"
sql:field="append("A",numero_virement)" />
<element type="code" sql:field="code_affilie" />
<element type="mnt" sql:field="montant_remise" />
</ElementType>
</Schema>

May 11 '07 #3
M6C (ro********@gmail.com) writes:
Thank you, but i don't find any information about an option to fire
triggers.
I will continue to looking for more informations about XML bulk load
options.
I looked in MSDN Library, and according to the topic "SQL Server XML Bulk
Load Object Model", there is indeed a FireTriggers property. This is for
SQLXML 4.0. I don't have much experience of SQLXML, but FireTriggers is not
listed under "What's New in SQL 4.0", so I guess it was there in 3.0 as
well.
An other question, to circumvent my problem;
Can i make an operation in the Xsd file ?
I want to add an constant character to an column.
Can i modify the Xsd file to look like the following:
That question definitely goes over my head! :-)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 13 '07 #4
M6C
On 13 mai, 18:25, Erland Sommarskog <esq...@sommarskog.sewrote:
M6C (roca.da...@gmail.com) writes:
Thank you, but i don't find any information about an option to fire
triggers.
I will continue to looking for more informations about XML bulk load
options.

I looked in MSDN Library, and according to the topic "SQL Server XML Bulk
Load Object Model", there is indeed aFireTriggersproperty. This is forSQLXML4.0. I don't have much experience ofSQLXML, butFireTriggersis not
listed under "What's New in SQL 4.0", so I guess it was there in 3.0 as
well.
In fact SQLXML 4.0 have a FileTriggers property. But i try this option
in SQLXML 3.0 and it's not available.
So i must upgrade my sql server to the 2005 version, to use it.
Thank you for your answers. Now i know the reason of this
comportement.

May 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan | last post by:
I have a table in my database on SQL Server which holds a file name that refers to a file that is stored on the server. I would like to create a trigger to delete this file from the server if the...
1
by: Chris | last post by:
Background: I am using a MS Access 2000 front end with SQL Server 8.0 back end. I have the requirement to import all text files (regardless of filename) from a given folder on the network into a...
9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
1
by: SR | last post by:
Hi to all Gurus, I am working with two tables, where in if a record is inserted in one table an insert trigger fires and inserts relevant information for that record in the second table. This...
1
by: Lino | last post by:
I'm a db2 newbie. I want to import text file in a db2 table with a primary key and some foreign key. Import utility works fine but I want bad data to be archived in a file or in an error table (in...
0
by: Kiran | last post by:
Hi, Does some one here know how to trigger export(bulk/non bulk) and use bulk import without having to manually edit the Xsd file before import. BTW I am assuming that XML is the correct choice...
5
by: MN | last post by:
Hello, I have a customer table and another table that I need to prepopulate with special customer IDs, unique and not sequential. Is there a way to configure Access to assign the customer ID to...
1
by: jrickard | last post by:
Hi, I'm getting an SQL3193N on DB2 v8 (fixpak 11)... SQL3193N The specified view or materialized query table cannot be updated. You cannot LOAD/IMPORT into this view or LOAD into this...
0
by: A3AN | last post by:
Hi. I receive a database backup on a daily basis. I then import this dump on another server which I use for software development. There is two db's being hosted on this server. We test software...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.