Home › Discussions › Questions & Answers › Dynamic Default Parameter Values using SQL
Dynamic Default Parameter Values using SQL
Customer · · Questions & Answers · 9 replies
I have a report requiring a period parameter. I want the default value to automatically populate with the current system date, but formatted specifically in the GL period format (e.g., MON-RR). How do I define this dynamic default value?
9 replies
To set a dynamic default value based on SQL, you define the parameter’s Default Value starting with the keyword `select` . For your requirement, you can use the SQL `select to_char(sysdate, ‘MON-RR’) from dual` . Blitz Report executes this SQL statement at runtime to derive the default value, which is particularly useful for defaulting dates, user IDs, or other session-dependent information .
I noticed some documentation suggesting that basic functions like `TO_CHAR` can be used without the `FROM dual` clause. Is this possible, and if so, which functions support this simplification?
Yes, to simplify report development, several functions can be used in default value definitions without needing to select from `dual` . These functions include standard mathematical and string manipulation functions such as `abs`, `add_months`, `coalesce`, `decode`, `length`, `lower`, `nvl`, `to_char`, `to_date`, and `upper`, among others listed in the source documentation . This provides a cleaner syntax when calculating simple default values.
If I want to default an email address for a report author based on the current user’s record, how would that SQL look?
To dynamically default the author’s email based on the current user, the SQL would typically join `FND_USER` with `PER_ALL_PEOPLE_F` using `FND_GLOBAL.USER_ID`. A complex example provided includes checking both the user’s direct email address and their person record email, using `coalesce` to return the first non-null result: `select coalesce(fu.email_address, (select papf.email_address from per_all_people_f papf where fu.employee_id=papf.person_id and sysdate between papf.effective_start_date and papf.effective_end_date)) email from fnd_user fu where fu.user_id=fnd_global.user_id` , .
If a required date parameter is of type ‘Date’, will the system convert the entered value to the server time for SQL execution?
If the parameter type is set to Date, the entered parameter value is used as a bind variable for SQL execution without any timezone conversion, effectively binding to midnight of the date entered . However, if the parameter type is set to DateTime and you have timezone conversions enabled, the entered parameter value *will* be converted to server time before being used as a bind variable for SQL execution .
Is there a mechanism to reorder parameters easily if I realize I need to insert a new one in the middle of a sequence?
Yes, Blitz Report provides a utility specifically for this purpose under Tools > Resequence parameters . This function automatically assigns new sequence numbers to your parameters, ensuring there is spare room between sequence numbers again, which allows you to easily insert new parameters into the required display order without manual sequence number adjustment conflicts .
- You must be logged in to reply to this post.
Sign in with LinkedIn or Google to take part.