Oracle forms hybrid validation - oracle

This is my first post ever and haven't come across any other questions related to this. I am attempting to try and create a hybrid validation type and add it to an existing oracle form. We have a super/subset type of thing going on. When one chooses something from a dropdown, there are 5 options. If 4 of those options are chosen, the data is pulled from one validation table dataset, table A. If the other option is chosen, it comes from a different table's dataset, table B. These (along with others items) are saved in Table C. Table C has a FK constraint regarding these validations. I have added another column to table C to attempt to bypass the FK constraint, but the field still tries to save in the FK column. I can't seem to figure out if I need to add a database trigger, an item level trigger, or a form level trigger to reroute the data to correct columns in the database. Thanks in advance for any help!

If your items are select lists, you would use an item level trigger (when-validate-item) on the superset list item to populate/repopulate the list for the subset item.
Alternatively, you could use a popup LOV on the subset item which has a query which is filtered by the value of the superset item.

Related

How to use Oracle APEX dynamic action to populate a 'form on a table' field on the basis of other fields and underlying sequence?

I am implementing a 'form on a table' that will allow the end-user to create records in the database. I would like to generate the primary key for the underlying table based on the selections the user makes as well as the underlying sequence.
The basic formula for the primary key should be a concatenation of the 'disposal site code' + 'year of study' + str(sequence). The sequence is should start at and increment by 1 so that the first project created in the database end with -1 and the nth with -n.
For example if the user selects the 'Disposal Site' as 'Seldom', the field 'Disposal Site Code' should be dynamically populated by 'CA-AT-D130' (a 1:1 code alphanumerical code for each site) and after selecting the year, for example 2022, the project number would dynamically be populated as CA-AT-D130-2022-01 (assuming first entry in the table). After creating the new record CA-AT-D130-2022-01 would become the 'project number'.
Can anyone recommend the idiomatic way to do this in APEX? I have a feeling what I am needlessly complicated something that should be relatively straightforward.
There are 2 ways of doing this that are a lot simpler than what you are trying. There is no reason at all to use a dynamic action, this can just be done using apex page processing.
option 1: in the database: Create an trigger on the table that sets the primary key column based on the other column values & sequence
option 2: in apex: Create an after submit computation on the page item to compute the value based on the other page item values & the sequence.
option 3: what I would do instead:
In my personal opinion this isn't a good option for a primary key. The primary key should just be a unique row identifier with no business value. Just use an identity column for that and no additional work is needed in db or apex.
Sounds like you want to capture business information in the key. Well... make that a "pseudo-primary key" and store that information in a column with a unique index in your database. Or, use a virtual column in your table that calculates this value from the primary key column and the other columns you need.

Any way to intercept an error message and make more user friendly?

I have looked for an answer here among other places but havent quite been able to find what I need to know.
I have 3 tables, Order_Details, Products_Ordered and Product_Details. The first two are being used in a master detail form to show the order and the items ordered together. The Products_Ordered table has a composite primary key made from two foreign keys, the first being the primary key from the Order_Details table, and the second being the primary key from the Product_Details table. Together they ensure that a type of product can only be added to an order once. If someone wants to order more than one product then the quantity field in the record can be altered to reflect this. All that seems fine so far.
My issue is that when adding products to the order in the master detail form i have used a drop down list of values to select the product to add to the order. the display value for this is the product name and the return value for it is the primary key for the product from the Product_Details table.
I like this because its easier for the user to simply select the product and add a quantity of it to the table. And it works fine for both insert and update operations apart from one situation.
If the user selects the same product in to rows then submits the table the database then tries to add the product to the order twice, throwing a "ORA-00001: unique constraint violated." error. Obviously this is because of the product ID being used in the primary key of the table.
I don't want to allow the user to add two records to the table like that, rather id like to force them to alter the quantity field accordingly. The error message that comes up isn't very user friendly so my question is how can I detect this error and display a more user friendly one instead telling them to alter the quantity field instead?
*If this isn't possible then is there a way that I can hide any already selected products from the dropdown list of values in the following table rows? I haven't looked into this too much because surely it would get complicated when the user tries to add more rows than products available in the dropdown and there are no more products values to show?
I am quite new to this so please be nice. Any help is greatly appreciated :D
Here is a link where all is nicely described:
https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/07_errs.htm
Section
Predefined PL/SQL Exceptions
in combination with:
Defining Your Own PL/SQL Exceptions
and
Defining Your Own Error Messages: Procedure RAISE_APPLICATION_ERROR
Hope it helps...

Oracle Forms: have a specific column on some rows not store a value in the database?

Requirements
Here are the simplified requirements. The end goal is to be able to display data about an item, or print labels using the saved data. The solution is being created in Oracle Forms Builder
Attribute Definition form
Designed to define attributes.
Attribute configuration details are stored in an attribute
definition table
Attributes can be either a manually entered
values, or SQL driven
SQL Example: Case Weight (uses the Item's
Case UOM conversion rate multiplied by the item's unit weight)
Manual Example: Color of item
When SQL driven, a select statement is saved in the attribute configuration
Tokens like :INVENTORY_ITEM_ID are used in the SQL, and will be replaced with
values by the form when the SQL is evaluate.
Item Attribute Assignment form
Designed to link attributes to an item
Form includes a list of attributes assigned to an item
Records that link the attribute to the item are saved in the
database
Records store the attribute ID, Item ID and the attribute
value (if applicable)
List should be in a single block.
The form
allows additional assignments of attributes (which defined in first
form)
Items can have SQL and Manual type attributes assigned to
them.
Form allows "manual" values to be updated at any time by the
user
Form derives SQL values, displays them in the "value" field,
but the value field should be disabled so the user can't edit it.
Upon querying an item or assigning a new attribute
SQL values should be derived/evaluated
Manual entered values should be pulled
from the tables "value" column
Problem
We don’t want the form to save the SQL derived values to the table.
Is there a way to have a specific column on some rows not store a value in the database? These would be the rows that contain the SQL derived values, which are displayed in the disabled value cell, and derived when an item is queried, or an attributes is assigned.
It is possible, but you really should implement table handlers for your Forms, rather than relying on Oracle Forms to do your DML for you.
By "implement table handlers", I mean, set the block's "DML Data Target Type" property to "Use Transactional Triggers".
Then, code the ON-INSERT, ON-UPDATE, etc triggers for your block to call PL/SQL (passing in the appropriate values to insert, update, etc from your block).
In your PL/SQL, you can insert each column exactly where and how you want it, or don't insert a column at all, which is what you're after here.
If you are using the Oracle e-Business Suite, this is documented in the Oracle Applications Developer's Guide, chapter 10 ("Using PL/SQL in Oracle E-Business Suite: Coding Item, Event, and Table Handlers").

What table holds the category selections for the time_card table in ServiceNow

I'm using the ODBC connector to query time card data from the time_card table in ServiceNow, and there are two columns I'm wondering about: category and dv_category - those two fields are pulled from somewhere, and I do not know where. Is there are table that holds these values, or are they static on the UI and passed through?
The 'category' field is just a string(40) with a Choice List local to the field. So, it's not a reference field, just a drop down. The Choice List can be modified
I'm not finding the 'dv_category' field on the time_card table and I'm on Helsinki Patch 3. Can you clarify?
Editing to add the actual answer to the question : 'I believe the table you're looking for is called 'sys_choice''

TableAdapter to return ONLY selected columns? (VS2008)

(VS2008) I'm trying to configure a TableAdapter in a Typed DataSet to return only a certain subset of columns from the main schema of the table on which it is based, but it always returns the entire schema (all columns) with blank values in the columns I have omitted.
The TableAdpater has the default Fill and GetData() methods that come from the wizard, which contain every column in the table, which is fine. I then added a new parameterized query method called GetActiveJobsByCustNo(CustNo), and I only included a few columns in the SQL query that I actually want to be in this table view.
But, again, it returns all the columns in the master table schema, with empty values for the columns I omitted.
The reason I am wanting this, is so I can just get a few columns back to use that table view with AutoGenerateColumns in an ASP.NET GridView. With it giving me back EVERY column i nthe schema, my presentation GridView contains way more columns that I want to show th user. And, I want to avoid have to declare the columns in the GridView.
When you add a new query to a given TableAdapter, it is going to assume the schema in which it is attached to, which is why you are getting blank values for the columns you don't want.
Since you mentioned having already created the procedure, what you need to do is use the Server Explorer to connect to the database and simply drag that stored procedure over into your XSD work area. What this will do is create a separate QueryAdapter that will have just the columns you specified (still strongly typed) and you can bind/interact with your GridView using that QueryAdapter instead.
Is the strongly typed dataset used in another query that returns all the rows from the table?
What you could do is create a dataview using the strongly typed dataset and expose a data table for your DataGridView.
I'm not sure what your requirements are totally, but this example should help you:
DataView dv = new DataView(ds.<Your_Table>);
// This will create a new data table with the same name,
// But with only two columns from the original table.
// This could then be bound to your data grid.
DataTable dt = dv.ToTable(false,
ds.<Your_Table>.<Your_Column1Column>.ColumnName,
ds.<Your_Table>.<Your_Column1Column>.ColumnName);
Just delete the columns you don't want at run-time before you bind to your Gridview. The underlying class is still just a DataTable after all.

Resources