I am disabling past dates in Date Picker in Apex v4.1 by entering in Setting as Minimum Date +0d
But when I am trying to edit and save data next day that field is showing error. Can somebody please help.
I can't view images, but - the way you described it - I'd suggest you to remove +0d in Date Picker item and create your own validation whose type is PL/SQL Function returning error text; it will check whether item value is equal or larger than TRUNC(SYSDATE), e.g.
if :P1_DATE_ITEM < trunc(sysdate) then
return ('Error - date has to be larger or equal to today''s date');
end if;
Then set validation's server side condition to e.g. ITEM IS NULL, while the "item" is table's primary key item (or - if you're working with the ROWID - use it).
Doing so, you'd tell Apex to perform control only for newly created rows (because their primary key column value isn't set yet, nor it has a ROWID as row isn't saved into the database). "Old" rows have it and validation won't fire.
Related
The need to identify the updated rows in Oracle when date_modified column has null values and then update with date value in data_modified. Filled data_modified column is useful in next steps in our scenario.
The source system is not updating/inserting date_modified value even when the creation/update is happened.
Input data:
Expected:
I have an option to fill current date when null else leave as it is in date_modified col.
but the difficulty here is, my approach will always fill current date even if the rows updated or not.
SELECT NVL(TO_CHAR(MOD_DATE,'DD-MON-YYYY'),to_char(sysdate,'DD-MON-YYYY')) FROM ORA.TABLE
Please suggest.
It's not an adjustment of your query, but the way you describe the problem seems like a good place to use a trigger:
CREATE OR REPLACE TRIGGER <your_table>_MOD_TIME
BEFORE INSERT OR UPDATE ON <your_table>
FOR EACH ROW
BEGIN
IF :new.mod_date IS NULL THEN
:new.mod_date := SYSDATE;
END IF;
END;
you could also add a separate column to store the action I or U for insert/update and this will give you better insight over what happened since this is good debug information and I don't think the overhead will be worth it.
I'm pretty new to APEX and programming as a whole, so bear with me. I have a table I created using dynamic PL/SQL and have a TO and FROM datepicker to set the range of rows to select. It is functioning great so far but I'm having a problem with the defaults for both datepickers. I've set the FROM datepicker to default to one year in the past and the TO datepicker is set to the current date. I've set them both using a SQL expression in the default field. Whenever you change the date and refresh, the table selects the correct rows. BUT if you want to remove the dates in both pickers so that you can see every row in the table, the null values are being reset to the default values after refreshing the page. I feel like there's probably a very simple way to fix this, but I'm at a loss. Any help with this would be greatly appreciated!
An item gets its value from session state; if it doesn't exist, then from source; if it doesn't exist (and the item is still NULL), then default value is used.
Therefore, what you did is just the opposite of what you want - if everything else is NULL, default value is used.
What to do? Don't set default value for the item - use it directly in report's WHERE clause. Something like this:
select whatever
from your_table
where some_conditions
and date_column between nvl(:P1_DATE_FROM, add_months(trunc(sysdate), -12))
and nvl(:P1_DATE_TO , trunc(sysdate))
So:
if P1_DATE_FROM and/or P1_DATE_TO are set, these values will be used
if they are NULL, they will be set to previous year and today
Of course, you'd remove both item's default values.
I was wondering how does ORACLE APEX identify if a certain page item value should go as number or varchar2 when used in stored procedure call.
my_pkg.proc1(P1 =>:P2_ITEM1);
Here, how does APEX engine identify if the parameter P1 for proc1 is expecting a number or varchar2 or date.
To extend:
I have a grid. With query as below
Select * from table(my_pkg.pipe_func(:P2_PARAM1,:P2_PARAM2));
When user clicks a button I need to get the current session state value of these bind substitutions and I want to store above select query in a table as
Select * from table(my_pkg.pipe_func('ParamVal',256));
How can this be achieved?
It's the Oracle database that does this grunt work, in the same way it's done it for years. You can see this in the v$sqlarea.
And you should explicity convert these bind variables, as they will be inheretly treated as a varchar - same as they're stored.
where id = to_number(:p1_id)
And from an APEX perspective, if the user changes a value on screen, and you invoke a dynamic action to refresh a region using those items - you should list them in the 'Page items to submit' attribute, just under the region SQL. This will ensure the database session state is updated with what's in the browser, before conducting the refresh.
I am trying to append data from one table to another in Access 2013. The destination table, [ActionItems], has no records yet.
The source table, [Students], has the necessary columns: [AutoID] (Autonumber), [Action Status] (Short text), [Action Status Last Updated] (Date/time), [Action Status Description] (Short text).
I have set the destination table to match the data types and fields (though the field names are slightly different, I have joined them appropriately in the append query). The [AutoID] field in the destination table is set to Number, Long Integer, as I've read suggested elsewhere.
If I view the append query in datasheet view, I see 731 records, just as I should. But when I try to run the query, I get the following error:
"Microsoft Access can't append all the records... set 0 field(s) to
Null due to a type conversion failure... 0... key violations... 0...
lock violations, and 731 record(s) due to validation rule
violations."
There are NO validation rules in the destination table! Both text fields allow for zero length, and the [AutoID] field has no default value. I don't understand what I could be missing.
Here is my SQL (I realize my column names are rather wordy):
INSERT INTO [ActionItems] ( AutoID, [Action Status], [Action Status Last Updated], [Action Status Description] )
SELECT [Students].[AutoID (Do not use)], [Students].Status, [Students].[Status Last Updated], [Students].[Status Description]
FROM [Students];
If it helps, here is a link to a stripped-down version of the database: https://drive.google.com/file/d/0BysgnYaEVPnJemNnOUc3ZmFsWXM/view?usp=sharing
I have removed all other tables and any identifiable information. The only other major difference is that the primary key in the [Students] table was changed from a composite key ([First Name], [Last Name], and [Email]) to a single primary key ([AutoID (Do not use)]). I made no changes at all to the [ActionItems] table. Even with these changes, the error still occurs exactly as previously described.
The destination table, ActionItems, includes a field named Action Status Last Updated By. That field's Required property is set to Yes, and its Default Value property is blank. That means any time you add a new row to that table, you must supply a value for Action Status Last Updated By.
Notice your INSERT statement does not supply anything for Action Status Last Updated By. Therefore that INSERT does not add any rows.
In my copy of your database, I changed the field's Required property to No. After that change, executing your INSERT query added 731 rows to ActionItems ... one for every row in Students.
If you prefer a different solution, you could leave Required set to True and either put something in the field's Default Value property or alter the INSERT to supply a value for that field.
I have a LOV with two columns one is code and the other is description. I know that text items have a property which says validate from list however my code field and description field are display items. We do not want to force the user to click on a button to show the LOV. In the pre-form trigger i am setting a default value in the code field.
I would like to get/resolve the code to its description from the list without having to do a select from the database. Does anyone know of a way to get this done?
I have had also this very same problem. There might not be a solution to retrieve the label column from record group in the runtime.
But you could do this:
Store the record group query somewhere (package header or DB column).
Populate your record group with query in the runtime.
Create DB function which takes query and key value as parameters. The function would then return description of the key value (use dynamic SQL, execute immediate / dbms_sql).
Use the function in the POST-QUERY trigger:
:block.item_description := your_new_function(l_query, :block.item_value);