![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
the common technique is inserting into invoice table first, getting the identity ID value for master record, and saving lines with this INVOICEID in a loop. |
|
now i want to design a sqlserver stored procedure with an xml parameter, and returning identity ID value in invoice table. |
|
my xml should look like that; ROOT INVOICE DOCNUMBER>A001</DOCNUMBER DATE>04.09.2012</DATE LINES LINE PRODUCTID>1</PRODUCTID AMOUNT>10</AMOUNT PRICE>5.25</AMOUNT /LINE LINE PRODUCTID>1</PRODUCTID AMOUNT>10</AMOUNT PRICE>5.25</AMOUNT /LINE /LINES /INVOICE /ROOT with one shot, i want to save this schema into database. |
#3
| |||
| |||
|
|
By the way, I get an uneasy feeling when I see your table definition of invoicedetails and the sample data. What does it mean that two identical rows are inserted? Shouldn't (invoiceid, productid) be the primary key? |
#4
| |||
| |||
|
|
actually ive already done something like that before ive written that post. (using OPENXML) |
|
1) .... where/on xxx.DOCUMENTNO=yyy.DOCUMENTNO disturbs me /i dont know why/ 2) my actual purpose here is; what if our xml contains more than one invoice data? |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
dont get that "disturbing" on ur solution. i mean ive also used xxx.DOCUMENTNO=yyy.DOCUMENTNO with my code of OPENXML. and my code looks disturbing. document number may not be a unique value (some documents may even have a null document number) thats why its disturbing me. actually, this join works for only "inserted" table, so no problem. but that still makes me disturbing. |
|
/by the way, im not good at english, perhaps im chosing the wrong word for "disturbing"/ |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
we use sqlserver2005 (and 2008 somewhere) now. but may upgrade all db servers to 2008R2 actually im not locked to xml type for this job. what would your advice be here? in terms of ease of implementation or working performance etc. |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |