Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Using a function in a primary key field
Using a function in a primary key field [message #4973] Wed, 02 September 2015 01:50 Go to next message
rafs is currently offline  rafs
Messages: 69
Registered: May 2015
Member
I also ran into a situation where I have a compound UNIQUE key (some_timestamp, some_type_id), and both fields are NOT NULL.
I wanted some_timestamp to get the value now()::timestamp(0) with time zone.
(This truncates the miliseconds from the timestamp which I don't want because I want only one record of this type per second.
But it seems the framework will test the UNIQUENESS and fail since now() is not a real value yet.

[Updated on: Wed, 02 September 2015 01:52]

Report message to a moderator

Re: Using a function in a primary key field [message #4985 is a reply to message #4973] Wed, 02 September 2015 12:12 Go to previous message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
That is correct. If you set the value of a field to a function as in "now()" then the value from that function will not be known until the query is executed. You cannot use functions for unique keys as RADICORE will test for uniqueness before the query is executed.

You should remove "now()" from the default value in the Data Dictionary and set the "Auto Insert" property instead. This will allow the framework to obtain the correct value before the test for uniqueness is performed.


Previous Topic: Cancel a Generate PHP screen
Next Topic: Open a new window from RADICORE
Goto Forum:
  


Current Time: Fri Nov 22 22:24:00 EST 2024

Total time taken to generate the page: 0.00960 seconds