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?
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.
Subject: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;