Running query with GUID(GENERATE-UUID)

Posted by Admin on 20-Dec-2007 00:27

Hey,
I'm trying to create a simple query to insert new rows to a table, which contain GUID (stored as string) in the first column.
In SQL it look like this:

INSERT INTO TARGET_TABLE (REC_ID, COL1, COL2)
SELECT NEWID(), COL_A, COL_B FROM SOURCE_TABLE

I want try to create an equivalent query to progress data base.
I assume that I need to use the function GUID(GENERATE-UUID) instead of NEWID(). But I did not succeeded.

Any suggestions?

Regards,
Moshe.

All Replies

Posted by Admin on 20-Dec-2007 03:12

AFAIK, the client need to generate the GUID and pass the value to the INSERT statement rather than using a NEWID() function.

Posted by Admin on 20-Dec-2007 04:27

I don't want to create a huge sql statement.
I won't to run one simple SQL. the statement NEWID does not work on progress sql.

Posted by Admin on 23-Dec-2007 01:05

Someone?

Posted by Admin on 23-Dec-2007 01:55

I don't really understand what you want and what you won't do.

But, please check the SQL92 reference available at http://www.psdn.com/library/servlet/KbServlet/download/1915-102-5692/dmsrf-05-23-07.pdffor the list of available statements/functions. NEWID is available on MS-SQL server, but not for the OpenEdge database.

You might try to add a trigger. Look at the CREATE TRIGGER statement.

Mike

Posted by Admin on 26-Dec-2007 11:39

GENERATE-UUID is a 4GL function, you can't use that in SQL! The 4GL is a programming language which has it's own database access API. In parallel there is SQL-support with another feature set. You probably have to define a SQL-column as byte-array and when you define the SQL-statement you have to generate the GUID-value elsewhere and pass it as a byte array. The SQL-engine has no GUID-generator.

Be carefull: some databases might have performance issues when using real GUID's, because of the distribution of the GUID-values. That's why some databases provide a special GUID-function, which better fits indexing requirements...

This thread is closed