473,796 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:sche mas-microsoft-com:xml-data"
xmlns:dt="urn:s chemas-microsoft-com:xml:datatyp es"
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="a c_export_and_pa th">
<element type="FILENAME" sql:field="path " />
<element type="idvir" sql:field="nume ro_virement" />
<element type="code" sql:field="code _affilie" />
<element type="mnt" sql:field="mont ant_remise" />
</ElementType>

</Schema>

Vbs file:
Set objBL = CreateObject("S QLXMLBulkLoad.S QLXMLBulkLoad")
objBL.Connectio nString = "provider=SQLOL EDB.1;data
source=*****;da tabase=*****;ui d=*****;pwd=*** **"
objBL.ErrorLogF ile = "C:\Temp\error. xml"
objBL.SchemaGen = True
objBL.CheckCons traints = True
objBL.KeepIdent ity = False
objBL.BulkLoad = true
objBL.Execute "C:\Temp\921914 2_MAPPING.xsd", "C:\Temp\921914 2.xml"
Set objBL = Nothing
Trigger source code :

CREATE TRIGGER [dbo].[trg_ac_export_a nd_path] ON
dbo.ac_export_a nd_path
FOR INSERT
AS

DECLARE @id AS varchar(50)

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

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

END

May 9 '07 #1
4 4694
M6C (ro********@gma il.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("S QLXMLBulkLoad.S QLXMLBulkLoad")
objBL.Connectio nString = "provider=SQLOL EDB.1;data
source=*****;da tabase=*****;ui d=*****;pwd=*** **"
objBL.ErrorLogF ile = "C:\Temp\error. xml"
objBL.SchemaGen = True
objBL.CheckCons traints = True
objBL.KeepIdent ity = False
objBL.BulkLoad = true
objBL.Execute "C:\Temp\921914 2_MAPPING.xsd", "C:\Temp\921914 2.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****@sommarsk og.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...@sommars kog.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...@sommarsk og.se

Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/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:sche mas-microsoft-com:xml-data"
xmlns:dt="urn:s chemas-microsoft-com:xml:datatyp es"
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="a c_export_and_pa th">
<element type="FILENAME" sql:field="path " />
<element type="idvir"
sql:field="appe nd("A",numero_v irement)" />
<element type="code" sql:field="code _affilie" />
<element type="mnt" sql:field="mont ant_remise" />
</ElementType>
</Schema>

May 11 '07 #3
M6C (ro********@gma il.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****@sommarsk og.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...@sommars kog.sewrote:
M6C (roca.da...@gma il.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 aFireTriggerspr operty. This is forSQLXML4.0. I don't have much experience ofSQLXML, butFireTriggers is 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
8808
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 row in the table is deleted. I have been trying to use this command in a trigger (<filename> is the name and path of the file): xp_cmdshell "delete <filename>" If some one could please help I would appreciate it very much. I would love a...
1
5916
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 table within SQL Server. This import needs to run continuously, as more text files will be saved in the folder by a separate system and they need to be updated into the SQL Server table. I have a DTS which can import all text files from the...
9
11236
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 only one column: txtOutput I want to use the DB front end (MS Access) to send the text string to the SQL backend, then have the SQL Server create a file to a path, such as F:/myfiledate.txt that holds the text in txtOutput, then the trigger...
1
4168
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 works well within my applications. But it failed (or the trigger never fired)when we used the DTS Import wizard to insert new data into the table from an excel file. How can I overcome this situation? Any help is greatly appreciated.
1
2703
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 oracle sqlldr there are bad files). I've tried also with db2 load that works fine but there isn's insert_update. So I thought a before insert trigger but this with this kind of trigger I cannot insert data in another table. Any suggestions? ...
0
1507
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 as I want to save these data in my VSS for future after export. ====================================== My prev Post:
5
2594
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 every record each time that a record is either created for the first time or imported for the first time? I would be importing into a temp table and then running an update query to copy the data to the customer table. Another confusing issue is...
1
1874
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 materialized query table. ....when I try to IMPORT INSERT into my non-updateable view. The view has an INSTEAD OF trigger defined on it, and inserts with standard SQL
0
9933
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 upgrades against these two db's. The "refresh" needs to be completed at least once a day, sometimes 4-5 times a day. I need the quickest way of doing this task. I have extremely limited knowledge on scripting. What I need is something that I can just...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.