TUniStoredProc Error Returned With "UUID" command in Proc
Posted: Fri 25 Nov 2011 17:48
Hey guys,
I have encountered a very strange error with the "TUniStoredProc" component when linked to a stored procedure where the stored procedure contains code which generates a table with multiple records containing GUID values obtained by the MySQL "UUID" command.
The stored procedure will typically contain the following statement:
NOTE: The example's "Staff" table below contains multiple records, so multiple GUID values will be required to be generated for the destination table's resulting column on the fly.
Also, the "UUID" command forms part of a concatenated string to represent the default GUID format of Windows GUID's, which is pre-and post fixed with curly brackets and which contain uppercase characters.
As you can see, the above SQL statement will generate the table "Test" with all the records from the "Staff" table, but the "EmployeeID" is generated with GUID values on the fly, as returned by the concatenated "UUID" command.
When testing the above code within the stored procedure on the server itself, everything works as expected, with each record entry in our test table containing a unique GUID value as returned by the "UUID" command.
But when you try to execute this exact same stored procedure with the "TUniStoredProc" component from within Delphi, you get a primary key violation on the "EmployeeID" field ??
Simply by executing this command, the primary key violation is generated:
For some reason, when you try to execute this server-side stored procedure using this UniDAC stored procedure component, it is as if the "UUID" command is not generating the required unique GUID values for each added record entry as it would when you execute the exact same routine on the server itself.
The only thing I'm left with, is that for some reason when executing this stored procedure using the "TUniStoredProc" component, something else is happening with the "UUID" command within the statement that doesn't want to function correctly, compared to executing it directly on the server??
When you take the EXACT SAME query, and you stuff it into a normal "TUniQuery" component and execute the query with "Query1.Execute", success is achieved as well, but NOT using the stored procedure component linking to the stored procedure on the server.
Does anybody have any idea why this is happening?? Is this a "strange" bug on this component I uncovered, or do I need to set some property value on the component itself to get it to execute this command successfully??
I can't understand how this is affected by being called with the "TUniStoredProc" component. It's not like the component itself is executing the actual routine, but merely invoking it on the server itself??
Does anyone have an idea how do you get this to work by using the "TUniStoredProc" component, or did I uncover I bug in this component??
Thanks.
I have encountered a very strange error with the "TUniStoredProc" component when linked to a stored procedure where the stored procedure contains code which generates a table with multiple records containing GUID values obtained by the MySQL "UUID" command.
The stored procedure will typically contain the following statement:
NOTE: The example's "Staff" table below contains multiple records, so multiple GUID values will be required to be generated for the destination table's resulting column on the fly.
Also, the "UUID" command forms part of a concatenated string to represent the default GUID format of Windows GUID's, which is pre-and post fixed with curly brackets and which contain uppercase characters.
Code: Select all
INSERT INTO Test(EmployeeID, Name, Surname)
SELECT (SELECT CONCAT('{', UPPER(UUID())), '}'), Name, Surname
FROM Staff;When testing the above code within the stored procedure on the server itself, everything works as expected, with each record entry in our test table containing a unique GUID value as returned by the "UUID" command.
But when you try to execute this exact same stored procedure with the "TUniStoredProc" component from within Delphi, you get a primary key violation on the "EmployeeID" field ??
Simply by executing this command, the primary key violation is generated:
Code: Select all
UniStoredProc1.Execute;The only thing I'm left with, is that for some reason when executing this stored procedure using the "TUniStoredProc" component, something else is happening with the "UUID" command within the statement that doesn't want to function correctly, compared to executing it directly on the server??
When you take the EXACT SAME query, and you stuff it into a normal "TUniQuery" component and execute the query with "Query1.Execute", success is achieved as well, but NOT using the stored procedure component linking to the stored procedure on the server.
Does anybody have any idea why this is happening?? Is this a "strange" bug on this component I uncovered, or do I need to set some property value on the component itself to get it to execute this command successfully??
I can't understand how this is affected by being called with the "TUniStoredProc" component. It's not like the component itself is executing the actual routine, but merely invoking it on the server itself??
Does anyone have an idea how do you get this to work by using the "TUniStoredProc" component, or did I uncover I bug in this component??
Thanks.