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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Sample XQuery extension using ... (2)
-> + Another EDI problem (7)
-> + Removing xmls:od and xmls:xsi ... (2)
-> + Configuring MarkLogic with Sty... (10)
-> + EDI to XML (7)
-> + Can't write to SQL-Server (4)
-> + XQuery and SQL-Server (2)
-> + Connection to MS SQL Server in... (2)
-> + copy/modify with Stylus Studio... (5)
-> - copy/modify with Stylus Studio... (1)
-> + [SQLServer JDBC Driver]Value c... (5)
-> + wild card chracter usage in XS... (2)
-> - Xquery with SQL NEWID function (4)
-> ->Xquery with SQL NEWID fun...
-> ->Xquery with SQL NEWID fun...
-> ->Xquery with SQL NEWID fun...
-> + Change Only One Line (5)
-> + Format DB xQuery results (3)
-> + Adding MsSQL Database to XQuer... (3)
-> + Need help with using XQuery in... (2)
-> + please help! simple XML transf... (2)
-> + xquery for invoice data (3)
-> + Xquery to cross reference two ... (3)
-- Previous [121-140] [141-160] [161-180] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
(Deleted User) Subject: Xquery with SQL NEWID function
Author: (Deleted User)
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
(Deleted User) Subject: Xquery with SQL NEWID function
Author: (Deleted User)
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

   
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.