Form WHERE clause - oracle

I have an APEX form I'm developing for "user settings". I have a table with a sequence as a primary key and the users ID in another column...in addition to a few columns where each users saved settings are stored (things like "N" for do not receive notices).
I haven't used Oracle APEX in a while so excuse this likely newbie question...The insert works fine, but I'm having trouble with making the form only show the current users values. In my Form Region the source is set to my Table, and I have a WHERE clause like this:
USER_ID = 813309
But that's not working (813309 is my id and I'm just hard-coding it for now). The form always comes up with a "New" record.

For a form to load a specific record you can set the primary key page item to the value you need. You can do so in the url using the link builder from another page or you can set a computation on the item. That is what I would try in your case: add a computation to your item P_USER_ID of type "Static Value" with value 813309. Make sure the computation happens before the "Fetch Row" - the value obviously needs to be set before the process runs.

In such cases, I prefer creating a Report + Form combination (using the Wizard, of course): it creates an interactive report (so that you can review data in a table), and a form which is used to add new records or update/delete existing ones.
Doing so, when you pick a user in interactive report and click the icon at the beginning of a row, Apex redirects you to the form page, passing primary key column value to the form which then fetches appropriate data from the table.
Not that it won't work the way you're trying to do it, it's just simpler if you let Apex do everything for you.
So: did you create an automatic row fetch pre-rendering process? If not, do so because - without it - Apex doesn't know what to fetch. Also, if you hardcoded user_id, it won't do much good. Consider storing username into the table so that you could reference it via :APP_USER Apex variable.

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.

Unable to retrieve report data using Dynamic Action in Oracle APEX

I have two tables: Application (PK: Application_ID) and App_support_domain (column: team_name, FK: Application_ID referencing Application table)
I am trying to display the data present in the Application table based on the selection of team names.
I have created a LOV popup (P2_NEW) to select the team name.
After selecting the team name I want to show the application data in the form of a report, so I have created a dynamic action that will show the body region which has the application data.
But the SQL query that I have written does not return any data. I think it is not taking the P3_NEW LOV value and displaying the application data.
Please let me know if you need more info/clarification.
Could you please take a look and help me out?
A "show" dynamic action will not resubmit the report. Add 2 actions to the dynamic action. One to refresh and an 2nd one to show. That will force the report to to refresh. Make sure you put P2_NEW in the "Page Items to submit" for the report.

Servicenow - Service Catalog Reference Field - Insert different column than the display value

Let me describe my problem:
I have a table for all my IT-Services. I reference to this table more than once, for different purposes. Most of the time I need to reference to the name of the service. That's why I keep the name as displayed value.
One Column of that table is a service_id (custom field) which is for example "Service_004". Now in a catalog request Item the User has to fill in the service_id in a reference field.
But since I have the name as displayed value, and I need it in other forms, I am unable to reference to the service_id.
Using the variable attributes field I managed to let the service be found using the autocomplete function. But in the reference field I still get the servicename. I know that I can change the display value in the dictionary, but this breaks other functions. So what I need is to change the display value just for one reference field.
Also I tried to create a new table called IT-Services2 with reference to my table IT-Services. Then I switched the display to true in the new table for my service_id, but this will even change it in the parent table.
Perhaps an onChange client script utilizing g_form.setLabelOf() ?
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf
Maybe I'm not fully understanding your question...
I ran into this issue before, what you can do is create select box variable and use an on load client script to populate the list with the service_id(s) from the table you are referencing.
I would write a script include to pull the data from the table and call it from the client script via GlideAjax.

"Record has already been inserted" on commit in Oracle Forms 6i

I'm not an Oracle forms guy, but I'm stuck maintaining an old Oracle Forms 6i app that our company has, so I apologize if I sound like I don't really understand forms, because I don't.
We have a pre-existing form that I've had to make some change to. It has a master/detail type setup. There are a series of "rows" for the details. When I enter master info and the first detail record, I can save just fine. When I add a second row of info to the details section, it gets to the KEY-COMMIT trigger, but when it actually hits the "commit;" line, it gives me the error "Record has already been inserted."
But there is only the one record associated with the master details in the table. When I clear that message it asks, "Do you want to save the changes you have made?" If I click "Yes", it just gives me the "Record has already been inserted" message in the status bar and nothing happens. If I try to exit the form, it again asks if I want to save the changes, but "yes" does nothing but keep me on the form. Clicking "No" removes the second detail record.
I'm confused. I'm clearly missing something.
Your detail data block has the Enforce Primary Key property set to Yes. It means that rows inserted/updated/deleted by this block are not queried by rowid, but by primary key.
It does not matter, how is primary key set in database, but how is set in forms. Check all items in your detail block and find those with Primary Key (Item) property. Then check, if there is a duplicate record in database.
I prefer using rowid and uncheck Enforce Primary Key property. If your block works directly with database table (not view), it works fine

Oracle Forms: Problem with master/detail commit

greetings,I'm facing a problem in Oracle Forms 10g. I created a simple master-detail form where i want to save data only from the detail data block (the master will function more as a browser).
The only solution found till now is to edit the properties of text items in the master block and prevent them from inserting/updating. This comes in conflict with the list of values (LOV) appearing when the user tries to input the app_id, or from a search button (i know that the way is not significant). Is there a way that i can pass values to the primary block and function only as a query?
Any help could save me from lots of trouble!
We can set various properties at the block level using the Block Properties palette. In your case you need to toggle off Delete Allowed, Insert Allowed and Update Allowed. Obviously you will want Query Allowed toggled on.

Resources