Exception handling using Oracle Forms Builder - oracle

I am making my first Oracle form in Oracle Forms Builder with the help of web material i.e. tutorials etc. I have written the following code in the WHEN-BUTTON-PRESSED trigger:
INSERT INTO PATIENT VALUES
(:CNIC_NO, :P_NAME, :CITY, :ADDRESS, :GENDER, :BLOOD_GROUP, :DISEASE, :WARD_NO);
COMMIT;
The problem here is that an unhandled exception is raised by the trigger with the following error numbers:
ORA-12899 (Reason is the Null value is inserted in non-Null column)
ORA-1400 (Reason is that the data length is too large than the allowed length)
I need to popup an informative message box for these and a default one for the others.

First of all I would avoid this errors by builtin Oracle forms validation. Set Required property to True on property panel for all items, which are based on not null database columns. Oracle forms then forces user to enter a value.
Next set Datatype and Maximum length properties to set basic data validations.
This should be enough in your case. If your still want to catch an exception, use code like this:
begin
INSERT ...
exception
when others then
message(DBMSERRTEXT);
end;
Anyway - it is not good idea to insert data using when button pressed triggers. It is not transaction safe. Use standard forms block. Oracle forms does all the data validations and manipulations for you.

You have either to guarantee there is a suitable value will be inserted in the specified column that doesn't accept null value the you have to use NVL function inside the insert statement. Well, it's quite a good idea to have a technique too.
handle Oracle Forms errors and informative messages
You have also to construct your table columns size larger enough to store the inserted as the address for example must be larger than 100 varchar2.

You can use The Default Oracle Forms Menu Tool Bar will handle the form's CRUD Operations for you. Instead of writing the insert,update,etc.
But, you have to specify using it by yourself for every form module.

Related

Adf column filter: which format does ADF use to generate the where clause in the VO's query?

TLDR; is there a way to understand at runtime which format is ADF using for dates behind the scenes? In particular the format used to render dates in dynamically generated sql code?
In the Oracle ADF Application I'm working on there are several table filters (by that I mean the field over the column in which I can write text/number/dates to query the table).
Filtering this way, the framework modifies the query of the View Object, adding the appropriate where clause. On the page there's also a button "Select all" that allows me to select all the data that's rendered in the table (there is a selection checkbox).
In the specific case, the query from the VO is used to aim two different goals:
update the rendered data in the table
if I press the "select all" button a function in the backend database is called (callable statement calling the function), passing as a parameter the query.
The first task is successfully reached (as the table is visually updated), but we had an issue with the second one.
The backend function uses the query to select all the extracted data (as iterating in ADF with java would be too slow).
The problem is that the where clause isn't correctly generated for the backend database (which is also oracle).
Basically the generated WHERE clause (which was added to VO's query automatically by the framework) was
WHERE record_date = '2020-10-12'
which I had to change to
WHERE record_date = to_date('2020-10-12', 'YYYY-MM-DD')
in order to have it correctly executed by the Oracle Db.
So now it's working (yay), but my concern is: isn't it dangerous to assume the date format will be 'YYYY-MM-DD' on every application's instance?
I think this 'YYYY-MM-DD' is the format in which ADF is managing dates (as the value is written as '2020-10-12' in the query).
But is there a way to understand at runtime which format is ADF using for dates behind the scenes? Or does it always use 'YYYY-MM-DD', or am I completely off-road and the storage format is another and I should ask which format does it use to render dates? But dates on page are visually rendered in another way :/
Sorry for my lack of expertise and have a nice day!
Update
The value of the query field, which I'm getting by calling
this.getNamedWhereClauseParams().getAttribute('vc_temp_1');
is of class
oracle.jbo.domain.Date
and by printing it I obtain the date in format YYYY-MM-DD.
Would it be possible that the framework was simply using Date.toString?
This would raise another question: how can I be sure of the pattern used by Date.toString? The documentation isn't clear about it (and it says that it should be used only in development, so this is quite a remote scenario).
What you named 'Filter' is called 'Query by Example' or QBE in short. See the doc for more info.
You can change the query passed to the server using a bean method. Look at e.g. JDev 12.2.1.3: Multi select component table filter for a sample.
Using dates in ADF is always dependent on the current user's settings. If the user don'T use a specific locale the default is 'yyyy-mm-dd'. This can be changed at different points, starting by the entity objects, view objects a,d finally in the UI by using converters.
The best way to use dates depends on the use case.

Oracle Form 12c field showing hash instesad of number

I am working on Oracle forms 12c and facing an issue with few fields showing as hash(####) values instead of number field on data block when saving changes by clicking on SAVE (commit) button.
Also showing below error
(FRM-40735 KEY COMMIT Trigger raised unhandled exception ORA-01483)
it seems that it is due to change of field item from number to HASH (string)
For further information:-
-Fields are database items
-Trying to insert value in database fields by entering value on field.
-Size of fields are more than entered number value.
-on re-querying data block using (f7 & f8) data is showing correctly as number.
-Not able to recreate this issue on different database(working fine on other database)
is it something related to environment issue or minor bug while coding?
If the Returning_Dml_value property on datablock is set to Yes,it sometimes causes junk values to be populated and asks a requery on block. Try setting it to No instead.I faced a similar issue once and it got resolved by setting Returning_Dml_value property to No.
The following blog explains more about this property of Oracle forms:
http://cave-geek.blogspot.co.uk/

How to use the result offset and fetch clauses with Oracle Forms Builder

I am currently working with Oracle Forms and I have made a dynamic query which is being passed on to the Set_Block_Property() and then the query is Executed. The output is ordered by using the 'Order By' option in Property Palette of respective form.
My requirement is to limit the number of records and when clicking the next button, It has to show the next set of records. I have been using the 'maximum records fetched' property in the Form Palette; however, I came across the OFFSET and FETCH clauses in Oracle 12c R1 (12.1), which do this with ease.
Is it possible to use the same with Oracle Forms Developer? Any answers or references would be appreciated. Thank you in advance.
At block level you got an option Query Array Size
This is the number of records fetched from the database.

How to implement dynamic datasets in a SSRS report

I have the following scenario: a single .rdl file with a stored procedure as datasource. This stored procedure accepts two parameters: #ProcedureName nvarchar(max) and #Parameters xml. The functionality of the stored procedure is to call another stored procedure (most probably on a different database) with the given XML parameters. So, in essence, each of the stored procs that gets executed will return it's own dataset.
How would I go about creating a tablix/matrix that consumes the dataset without specifying the columns as the columns need to get generated at runtime?
Unfortunately, SSRS doesn't have "AutoGenerateColumns"-style functionality and resolves a number of things at design time. So the short answer is that you cannot.
The designer checks field references when saving, and will not save with a reference to a field that isn't in a dataset's field list. If a field ceases to exist after the report definition is generated, it will show up as a static blank value on the report. Expressions will do so as well, even if the field is in an unevaluated portion. So if field B is removed, this expression would still be affected:
=IIF(1=1,Fields!A.Value,Fields!B.Value)
Which means that you can't use conditional grouping expressions as a workaround, even if you had an exhaustive list of the columns that might be returned.

Issues on wrong date format in oracle forms

If I give wrong date in one block field it should not allowed to enter other block in oracle forms.
eg:- in date field I'm entering values like MUHUTHUTHU after that I'm moving cursor to next block. first time I'm getting an error mesage FRM-50026 (wrong date format) but the cursor moved to other block.
But I don't want to allow to another block. Thanks to help me out from this issue.
If you specify the format mask property of that item as a valid date format (MM/DD/RRRR for example), Forms should take care of it by itself.
If not, you need to check the date format in the WHEN-VALIDATE-ITEM trigger and if it's not a valid date then raise the FORM_TRIGGER_FAILURE exception:
RAISE FORM_TRIGGER_FAILURE;
That will keep the cursor in that field.
The default functionality if the entered data is not valid according to the format mask is that the focus stays in the item. It is though possible to accidently or not override the default functionality. You can e.g. use On-Error trigger to override the default error handling and of you forget to call RAISE FORM_TRIGGER_FAILURE after your custom error handling then the program flow will continue as no error have happen at all.

Resources