Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] WebFOCUS, Create Random GUID

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] WebFOCUS, Create Random GUID
 Login/Join
 
Master
posted
Is there a way within WebFOCUS to create a random GUID? I know I can go ask SQL to give it to me, I know I can even call external services to give me one, but I'm attempting to do this within WebFOCUS. I've tried the following without luck.

SQL
SELECT NEWID()


We have Services that we call and they use these guids to trans a transaction. So every time we call them, we need a new GUID. Calling to SQL or another service every time to get a GUID would cause a performance issue with thousands on at a time.

This message has been edited. Last edited by: GavinL,



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
I'm not a 100% sure, but I don't think there is an easy solution. I wrote a FUSE routine function to generate a UUID, but you need to write it, then compile with the openssl libraries, then deploy it etc. You could also write a JAVA plugin to generate a UUID, but you will have the same issues.

You might want to look into use your SQL option to generate a table with a set number of GUIDs, then read them - or include them - in your process 1 at a time until you have exhausted the table. Then re-gen the table and start all over again.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
I do this in our Oracle environment:

SET SQLENGINE=SQLORA
ENGINE SQLORA SET DEFAULT_CONNECTION connection-name;
-RUN

SQL
SELECT SYS_GUID() AS ROW_ID FROM DUAL;
TABLE ON TABLE HOLD AS H001 FORMAT ALPHA
END
-RUN

-READFILE H001

?FF H001

-TYPE ROW_ID: &ROW_ID


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
quote:
SET SQLENGINE=SQLORA
ENGINE SQLORA SET DEFAULT_CONNECTION connection-name;
-RUN

SQL
SELECT SYS_GUID() AS ROW_ID FROM DUAL;
TABLE ON TABLE HOLD AS H001 FORMAT ALPHA
END
-RUN

-READFILE H001

?FF H001

-TYPE ROW_ID: &ROW_ID


Yea, I would think that is a bit much since I could have thousands of people and I need a new guid for each transaction. Was hoping there was something internal that I was just missing.

Thanks guys, I guess the most inefficient way is the only way.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
What could be more efficient? I don't get it.

SET SQLENGINE=SQLORA
ENGINE SQLORA SET DEFAULT_CONNECTION connection-name;
SQL
SELECT SYS_GUID() AS ROW_ID FROM DUAL;
TABLE ON TABLE HOLD AS H001 FORMAT ALPHA
END
-RUN
-READFILE H001

Eight lines of code that probably take 100ms to run...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
This works too...

-DEFAULTH &GUID = _FOC_NULL;

-IF &GUID EQ _FOC_NULL GOTO CREATEGUID;
-TYPE GUID = &GUID
-GOTO THEEND

-CREATEGUID
-HTMLFORM BEGIN
<script>
function S4() {
	return (((1+Math.random())*0x10000)|0).toString(16).substring(1); 
}
function CreateGUID() {
	//then to call it, plus stitch in '4' in the third group
	return (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase();
}
{
	location.href = location.href + '&|GUID=' + CreateGUID();
}
</script>
-HTMLFORM END

-THEEND

This message has been edited. Last edited by: GavinL,



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
quote:
Originally posted by Francis Mariani:
What could be more efficient? I don't get it.


Internal Method to WebFOCUS..



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
Every DBMS could be different, hence a DBMS call.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
This might help. I am not responsible for the code, I downloaded an example and just compiled the DLL into the "user" directory:

uuid.c
#include <stdio.h>
#include <stdint.h>
#include <openssl/rand.h>

void uuid(char *buffer)
{
	union
	{
		struct
		{
			uint32_t time_low;
			uint16_t time_mid;
			uint16_t time_hi_and_version;
			uint8_t  clk_seq_hi_res;
			uint8_t  clk_seq_low;
			uint8_t  node[6];
		};
		uint8_t __rnd[16];
	} uuid;

	int rc = RAND_bytes(uuid.__rnd, sizeof(uuid));
     
	uuid.clk_seq_hi_res = (uint8_t) ((uuid.clk_seq_hi_res & 0x3F) | 0x80);
	uuid.time_hi_and_version = (uint16_t) ((uuid.time_hi_and_version & 0x0FFF) | 0x4000);

	snprintf(buffer, 38, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
			uuid.time_low, uuid.time_mid, uuid.time_hi_and_version,
			uuid.clk_seq_hi_res, uuid.clk_seq_low,
			uuid.node[0], uuid.node[1], uuid.node[2],
			uuid.node[3], uuid.node[4], uuid.node[5]);

}
  


Usage:
-SET &UUID = UUID('A36');
-TYPE UUID IS &UUID
>> UUID IS 0f68060e-e8cb-4ad4-99e0-d4a811d3078f

-* or in a report/data flow ...
TABLE FILE CAR
PRINT 
     COMPUTE A_UUID/A36 WITH COUNTRY = UUID('A36'); AS UUID
-*     COMPUTE A_MD5/A32 = STR2MD5(COUNTRY,10,'A32'); AS 'MD5 HASH'
BY COUNTRY 
ON TABLE SET ASNAMES ON
END  

>> Output
COUNTRY     UUID
----------  ------------------------------------
ENGLAND     b0aeec49-dc31-481e-bd38-7d5f312a7216 
FRANCE      b1a0b91a-55c0-4d0e-8a5a-66160e61daa8 
ITALY       c254d2e4-b221-49b9-8c08-611d479e1776 
JAPAN       f35641ff-61c3-4a39-84c7-51fac4e4cfe1 
W GERMANY   3ebd8a30-fe6f-4810-80c0-9408116d8c4b 


Hope this helps


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] WebFOCUS, Create Random GUID

Copyright © 1996-2020 Information Builders