Is it possible to create multiple data source objects under the same database executing a single xmla script? - ssas

I want to create multiple data source objects under the same database executing the single XMLA script only once.I have tried the below script but it did not work.If I define only a single node, the script executes successfully.But when I add the another same node it gives error. I am newer to this.Please guide.
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ParentObject>
<DatabaseID>Test Database</DatabaseID>
</ParentObject>
<ObjectDefinition>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource1</ID>
<Name>Test Datasource1</Name>
<Description>A test datasource1.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
<DataSource xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RelationalDataSource">
<ID>Test Datasource2</ID>
<Name>Test Datasource2</Name>
<Description>A test datasource2.</Description>
<ConnectionString>Provider=SQLNCLI11.1;Data Source=servername;User ID=user;Password=pass;Initial Catalog=SqlDb</ConnectionString>
<ImpersonationInfo>
<ImpersonationMode>ImpersonateServiceAccount</ImpersonationMode>
</ImpersonationInfo>
<Timeout>PT0S</Timeout>
</DataSource>
</ObjectDefinition>
</Create>

Is there a batch element wrapper you can use?

Related

How to pass property value dynamically to sql tag in liquibase changelog

I'm currently assigning a predefined property value to some tag's attributes, but I want to use it as well inside xml tags. Below is an example based on Liquibase documentation:
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"
>
<property name="schema.name" value="DBPECG"/>
<changeSet id="20201005103200-1" author="felipe.rudolfe" objectQuotingStrategy="QUOTE_ALL_OBJECTS">
<createTable schemaName="${schema.name}" tableName="TB_IES" >
.
.
.
</createTable>
</changeSet>
</databaseChangeLog>
And here is what I want to do. I want to use schema.name in a way such as this, inside sql tag:
<changeSet id="20201005103200-3" author="felipe.rudolfe" objectQuotingStrategy="LEGACY">
<sql>
ALTER TABLE ${schema.name}.TB_IES ADD CONSTRAINT...
</sql>
</changeSet>
Is there a way to do this?
Liquibase allows dynamic substitution of properties in changelog files. We can configure multiple properties inside a file and then use them wherever required. In your case, we can just configure property "schemaName" with some value and then use it in changelog file using ${schemaName} syntax.
Liquibase assigns or prioritizes value for configured property in below order:
As an attribute passed to your liquibase runner.
As a JVM sytem property
As an environment variable
As a CLI attribute if you are running liquibase through command line
In liquibase.properties file
In the parameters block (property element of the DATABASECHANGELOG
table)
You can do it as below example code snippet:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="author" id="some-unique-id" context="some-context">
**Your SQL query/ transactional logic goes here**
<sql>
ALTER TABLE ${schemaName}.TB_IES ADD CONSTRAINT...
</sql>
</changeSet>
</databaseChangeLog>
In liquibase.properties file, I will configure this property as follows:
schemaName=DBPECG
Note: above example is using 1 property (schemaName). You can use only even more than that.
If you need help with creating "liquibase.properties" file, visit this link
Cheers!

Alter cube dimension by using XMLA

By using XMLA how to access WriteEnabled dimension property and modify it?
Here is a sample I'm using for that
<Alter ObjectExpansion="ExpandFull" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<Object>
<DatabaseID>DB</DatabaseID>
<DimensionID>My dimension</DimensionID>
</Object>
<ObjectDefinition>
<Dimension xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100">
<WriteEnabled>false</WriteEnabled>
<ID>My dimension</ID>
<Name>Dimension name</Name>
<Attributes>
<Attribute>
<Name>Attribute name/Name>
</Attribute>
</Attributes>
</Dimension>
</ObjectDefinition>
</Alter>
Running this script I'm getting following error: Errors in the metadata manager. The 'My dimension' dimension has either zero or multiple key attributes.
What is missing in a script above?
Seems the key columns node and Name columns nodes for your attribute have missing:
Here is an example for a dim attributes node, hope it helps:
You can create a cube manually, and then check the alter script by right click the cube name for a reference also.

infinspan for SQL server

I need a template infinispan for sql server.
Or a tutorial that explains each and every tag, a sample that points h2 database, or tutorial that explains each and every tag a sample that points h2 database.
<?xml version="1.0" encoding="UTF-8"?>
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0">
<namedCache name="persisted_repository">
<persistence passivation="false">
<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
fetchPersistentState="false"
ignoreModifications="false"
purgeOnStartup="false">
<connectionPool
connectionUrl="jdbc:h2:file:target/content/db;DB_CLOSE_DELAY=-1"
driverClass="org.h2.Driver"
username="sa"/>
<stringKeyedTable
prefix="ISPN_STRING_TABLE"
createOnStart="true"
dropOnExit="false">
<idColumn name="ID_COLUMN" type="VARCHAR(255)"/>
<dataColumn name="DATA_COLUMN" type="BINARY"/>
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT"/>
</stringKeyedTable>
</stringKeyedJdbcStore>
</persistence>
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.DummyTransa`c`tionManagerLookup"
transactionMode="TRANSACTIONAL"
lockingMode="OPTIMISTIC" />
</namedCache>
</infinispan>
If you want to connect to MySQL, the only thing you have to change is the connectionPool:
<connectionPool
connectionUrl="jdbc:mysql://mysql.example.com:3306/my_db"
driverClass="com.mysql.jdbc.Driver"
username="db_user"
password="db_pwd" />

Unitils dataset and modified dates

Any ideas how this can be done with Unitils dbunit?
Date relative to current in the DBUnit dataset
The problem is that the [create_date]-placeholder is not recognized in #Dataset.
A simple solution might be to just use placeholders in your xml dataset, eg.
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<user userName="jdoe" name="doe" firstname="john" lastLogin="{YESTERDAY}" />
<user userName="jdoe" name="doe" firstname="jane" lastLogin="{A_WEEK_AGO}" />
</dataset>
and do some post-processing(replace the placeholders with the calculated values) before you run your tests. When you are using Maven, you could then first execute the post-processing, (fill in the values in the xml-template-dataset, copy the filled-in-xml-dataset to the correct folder), before any tests are executed.

How do I update my SQL database using XML?

I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<Patients>
<Patient EMail="LeBron#James.com">
<FirstName>LeBron</FirstName>
<LastName>James</LastName>
</Patient>
<Patient EMail="Kobe#Bryant.com">
<FirstName>Kobe</FirstName>
<LastName>Bryant</LastName>
</Patient>
<Patient EMail="Allen#Iverson.com">
<FirstName>Allen</FirstName>
<LastName>Iverson</LastName>
</Patient>
</Patients>
I want to store it in a SQL database which I have done successfully/
I then added some more data to the same XML File:
<?xml version="1.0" encoding="utf-8"?>
<Patients>
<Patient EMail="LeBron#James.com">
<FirstName>LeBron</FirstName>
<LastName>James</LastName>
</Patient>
<Patient EMail="Kobe#Bryant.com">
<FirstName>Kobe</FirstName>
<LastName>Bryant</LastName>
</Patient>
<Patient EMail="Allen#Iverson.com">
<FirstName>Allen</FirstName>
<LastName>Iverson</LastName>
</Patient>
<!-- New data starts here -->
<Patient EMail="trtr#Iverson.com">
<FirstName>tr</FirstName>
<LastName>rson</LastName>
</Patient>
<Patient EMail="wewn#Iverson.com">
<FirstName>Awerwren</FirstName>
<LastName>Iveww</LastName>
</Patient>
</Patients>
But it does not update in SQL database at runtime.....
What am I doing wrong?
Based on what you've posted, I'm guessing that perhaps there's a primary or unique key on the Patient table's FirstName and LastName columns, and the second time you try to insert data into the database this constraint is causing the inserts to fail.
Just a guess. Post more information and perhaps we can narrow it down a bit for you.
Share and enjoy.
Delete the previous database. Create a new database with the new XML.