how to use biml offline schema - schema

I have defined a table in BIML that does not exists.
I then create the table using ExecuteSQL, and want to load that table.
However BIML will fail as it tries to query the non existent table.
I have already provided the column mapping so it doesnt need to query the table anymore.
This thread Create table before the dataflow in BIML mentions the offline schema, but there is not much content on how to use it.

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Metadata>
<OfflineSchema Name="OfflineSchema1">
<Items>
<Item Name="[Schema].[Table]" ConnectionName="ConnName">
<ExternalTableSource Table="[Schema].[Table]" />
</Item>
</OfflineSchema>
</Metadata>
</Biml>

Related

MS SQL Server loading XML Source with multiple elements in database table

I'm relatively new to SQL Server, so please bear with me!
I have a XML file with multiple elements that I am trying to load into a database table, see below:
<ReportStatus>
<Change>
<Signatory>XXX</Signatory>
<Status>XXX</Status>
<StatusTime>XXX</StatusTime>
</Change>
<Message>
<CreationTime>XXX</CreationTime>
<ID>XXX</ID>
<Version>0.0.1</Version>
</Message>
<Request>
<References>
<Reference>
<RefId>Reference</RefId>
<RefValue>XXX</RefValue>
</Reference>
</References>
<RequestNr>XXX</RequestNr>
<Service>
<Name>XXX</Name>
<Type>XXX</Type>
</Service>
</Request>
The flow will only let me load one element at one time, I have tried loading the data into the table as such:
However, this loads the data into the table in 2 separate records:
Is there a way to consolidate these 2 elements before placing them into the table so the entire record is loaded as a single record?
Thanks in advance!
EDIT
Here's the table with the matching fields:

Edit XML data and import to SQL table

I have an XML feed from a wholesaler that is updated periodically to show the stock quantities of the items they wholesale. I need some help in collecting that XML file data twice a day and importing it into the SQL table on my website. Here is an example of the XML file:
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE stockreport SYSTEM
'http://www.wholesalewebsite/feeds/status.dtd'>
<stockreport>
<timestamp>14/07/2014 18:55:26</timestamp>
<version>2.0</version>
<products>
<product type="main">
<code>M0507</code>
<name>Example Product</name>
<stock>4</stock>
<status>In Stock</status>
</product>
</products>
</stockreport>
I need to use this feed to update the quantities of the items in my store. My SQL table is called prods_stock and in the table the code (M0507) is called customid and stock is called quantity, so I need to alter the XML fields to match my existing table fields and then update the quantities using the customid(code) as an anchor point. I can ignore name and status.
How would I go about doing this?
Thanks in advance
Thanks for the suggestions, as I am not very good with coding etc... I have decided to just manually insert an sql query daily to update the database. An example of the code I will use is:
UPDATE products_stock SET customid = 'n12',quantity = 10 WHERE 1=1 AND customid= 'n12';
UPDATE products_stock SET customid = 'n50',quantity = 10 WHERE 1=1 AND customid= 'n50';
I will be using a csv feed file from the wholesaler and getting the info from there. Is there an easier/quicker way to drag the info from the csv file and update the table, rather than manually type the code for each line?
Thanks
You may have a look at XSLT. That allows you to parse any XML file and transform it's contents into any form you like. Using that you could transform the XML into SQL queries and run them agains the database.
You could then write a small shell script that loads the XML file, runs the XST-rules and hands the result on to the database.
You cannot archive that without any programming knowledge, but XSLT ist quite simple for such simple use cases. First I would work through a basic XSLT tutorial to become familar with the basics and then try it out with our problem.
Happy learning.. :)

Inserting Data from XML nodes into Database via SSIS

I want to insert the below XML Data retrieved from web service task into my Database,
<?xml version="1.0" encoding="utf-16"?>
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name xmlns="http://Iycon.com/WebService">Rahul</Name>
<BirthDate xmlns="http://Iycon.com/WebService">1988-09-23T00:00:00</BirthDate>
</Data>,
I am making use of foreach loop container to loop through different nodes but unable to get the result, this data I am inserting into database via Execute SQL Task, I have tried lot but unable to find solution,Thank You,
You can try the following to get the data into SQL Server.
Add Webservice Task
This retrieves the complete node set from the web service.
Update a variable(object) with the web service response data.
Add Data Flow Control
Add XML Source Control
Use XML from variable and generate the XSD
Add OLE Destination Control
Map your columns to match the XML nodes exposed from the XML Source.

Can Datanucleus SchemaTool create additional columns not bound to a PC but mapped in JDO ORM?

I have a User class (#PC) currently having only one property: 'email', now I want the user-table (where User class is stored) to have additional columns, which are not managed by JDO but are subject of authentication happening outside of PM. When I auto-create the table by Datanucleus and then ALTER the table adding my columns everything works as expected.
Of course I would be happy to use SchemaTool for generation/update of the schema, yet dont want to have manual ALTER table procedure on that user table. Naively I've tried to put the two extra columns into ORM file (omitting targets):
<package name="bo">
<class name="User" table="tb_user">
<column name="USER_SECURITY" jdbc-type="VARCHAR" length="64"/>
<column name="SEC_SALT" jdbc-type="VARCHAR" length="10"/>
</class>
</package>
but SchemaTool did not generate the extra columns, altough ORM file was loaded according to logs.
BTW: no way I want to have those columns mapped and managed during JDO lifecycle.
so, is it possible to get Schematool to generate extra columns on tables or do I have to sort them out into another table not managed by Datanucleus?
thanks
JDO spec defines such as that as seen in this link, and I have no problem with our tests using such unmapped columns in SchemaTool
http://www.datanucleus.org/products/accessplatform_3_3/jdo/orm/schema_mapping.html#unmapped

Converting a "DBML" file to a "SQL database file"

I have the DBML file of a database and would like to generate an SQL database file from this file.
Thanks
There's a method on the Data Context called CreateDatabase() that you could use.
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.createdatabase.aspx
I know of no available utilities that do that, and it's a bit much to do for a SO answer.
But, for the most part, it's not that big a deal. The DBML file is written in XML; it should be easy to read via Linq-to-xml. Then just split out the SQL commands for the values in the xml into a script file. Then run the script. (It also could be done with a XSLT transformation)
<Table Name="dbo.Person" Member="Persons">
becomes
CREATE TABLE Persons (
and
<Column Name="PersonID" Type="System.Int32" DbType="Int NOT NULL IDENTITY"
IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false">
</Column>
<Column Name="AddressID" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false"></Column>
becomes:
PersonID Int NOT NULL,
AddressID int NOT NULL,
and so on.
You can use the CLI tool.
dbml2sql schema.dbml -o schema.sql
https://www.dbml.org/cli/#convert-a-dbml-file-to-sql