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)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] 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.