XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Cynthia van BovenSubject: Xquery with SQL NEWID function
Author: Cynthia van Boven
Date: 26 Apr 2009 01:23 PM
Originally Posted: 26 Apr 2009 01:20 PM
Hi Stylussees,

I am converting data from one sql database to xml and then import it in another database. Now I would like to add an SQL NEWID to each generated record. Now I read something in the forum on a ddtek-sql:NEWID() function, but it is not recognized in Stylus Studio 2009.

Can I generate a NEWID and do you have an example?

Thanks,

Cynthia

Postnext
Ivan PedruzziSubject: Xquery with SQL NEWID function
Author: Ivan Pedruzzi
Date: 28 Apr 2009 11:00 AM
See the following example

declare function ddtek-sql:NEWID() as xs:string external;

ddtek:sql-insert("subscribers",
"ID" , ddtek-sql:NEWID(),
"name" , "ivan",
"surname" , "Pedruzzi")


The subscribers table is defined as

CREATE TABLE [dbo].[subscribers](
[ID] [uniqueidentifier] NOT NULL,
[name] [nchar](50) NOT NULL,
[surname] [nchar](50) NOT NULL,
CONSTRAINT [PK_subscribers] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Cynthia van BovenSubject: Xquery with SQL NEWID function
Author: Cynthia van Boven
Date: 03 May 2009 01:09 PM
Hi Ivan,

Is it also possible to add a newid to the xml file by means of an xquery? This way I can import the file via the import function of the application, so my file will also be functionally validated.

Thanks!


Cynthia

Posttop
Ivan PedruzziSubject: Xquery with SQL NEWID function
Author: Ivan Pedruzzi
Date: 05 May 2009 12:03 PM

NEWID is a SQL Server built-in function therefore it can only be used in the context of SQL data source.

If you like to generate a GUID you can use the following technique.

The query below uses java.util.UUID, note that you need to have Java 1.5 or greater; you can check the Java version in the Stylus Studio about box.

declare namespace uuid = "ddtekjava:java.util.UUID";
declare function uuid:randomUUID() as ddtek:javaObject external;
declare function uuid:toString($uuid as ddtek:javaObject) as xs:string external;

<root>
{uuid:toString(uuid:randomUUID())}
</root>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.