Oracle APEX Array - oracle

In my apex app, I have an array I want to store as an application item. When I try to do this like (APP_ITEM_ARRAY is an "application item"):
declare
TYPE array_t IS TABLE OF VARCHAR2(255);
lv_arr array_t;
begin
:APP_ITEM_ARRAY := lv_arr;
end;
I get an error (expression is wrong type). So for now I'm testing using an apex_collection, which seems usable on my pages. But I'm a little unsure, are these part of the users session?
How best to store (pl/sql) arrays in session state for Apex to use across pages?
In my use case, the array is actually a list of groups the logged in user is in...so I also need an easy way to determine whether the user is in a group, or not, ala some kind of "exists" or "member of" and then on my pages I'll use that...show hide Buttons, Nav Items, etc.

In apex, a page item is always a string under the hood, so it's not possible to a value of a complex datatype to it (and it explains the error too). It's possible to use collections too but that would be overkill for this kind of functionality.
To store multiple values in a single page item (for example for items of type checkbox - where you can select multiple values - or like in your case), a colon-delimited string is used. There is a pl/sql API APEX_STRING that has functions and procedures to convert an object of type apex_t_varchar2 (which is basically an array) to a string and back.
Example:
DECLARE
l_groups apex_t_varchar2;
BEGIN
l_groups := apex_t_varchar2('user','administrator','manager');
:P1_PAGE_ITEM := apex_string.join(l_string1);
END;
/
Side remark: what I just explained answers your question, but why would you store that information a page item ? Just leave it in the database and when you need to know if a user is in a group, just use a database function. Or better, use an authorization scheme to determine what functionality is available to a user based on the group he is in - that is what those are made for.

Related

Can :xdo_user_name be used in list of value in Oracle bi publisher? Or just works in data set

I am making a data mode. Involve a list of values to bind with parameter. Just want to ask if adding :xdo_user_name as the list of value sql parameter is possible?
I am hoping that user login, the menu will only show related data to him.
Many thanks.
Not sure if this can work or not.
You could create a List Of Values - Type SQL Query
select :xdo_user_name as USER_ID from dual
Now create new parameter of (parameter) type Menu and based on the above LOV. Next, in your datamodel you can use the newly created parameter any way you need.

Field goes null when button press oracle forms?

I am creating form for search data in oracle forms 10g
when user select LOV from non-database field and press search button then non-database field goes null. I want field not null when button press
A screenshot would help; it is unclear where's that non-database field placed. If it is a tabular layout forum, is it placed within all the other fields? Or is it somewhere in a control, non-database block?
Anyway: here's how I'd do that.
First of all, if possible, avoid inventing your own searching algorithm. Forms is very good at doing such things by itself. Shortly:
enter query mode
enter search criteria (select it from a list of values; why not?)
execute query
absolutely no additional programming is necessary (apart from the LoV)
If, for some reason, you have to do it "your way":
put the non-database LoV field into a separate control block
WHEN-BUTTON-PRESSED should
use SET_BLOCK_PROPERTY and set database block's DEFAULT_WHERE (or, maybe even better, ONETIME_WHERE) to a selected LoV value
navigate to a database block (GO_BLOCK)
EXECUTE_QUERY
alternatively, WHEN-BUTTON-PRESSED would only EXECUTE_QUERY, but you'd use PRE-QUERY trigger on the database block that sets the searching criteria, for example :database_block.name := :control_block.lov_field;
As of your question:
it seems that the LoV field is part of the database block, and it gets cleared once you execute query. See if you can re-fill it using POST-QUERY trigger
Or, if it is not, check what the WHEN-BUTTON-PRESSED trigger is doing - maybe it clears it
See of what I wrote helps. If not, please, edit the question (your initial message) and provide additional information which would help us help you.

Oracle Forms 6i Do You Want To Save Changes Message

I have a form that contains several data blocks, all the fields are bind to the database by setting their properties to the database column name. All the items on each block are displayed on one canvas.
The items on the form contain personal data, however information like the customers phone numbers and addresses are stored on separate tables on a one to many mapping and is linked by the customer number, it takes into consideration the customer can have many phone numbers and many addresses.
The biggest problem here is when the user user is in query mode and has entered information on each block when they try to leave a block they get a message asking them 'Do You Want To Save Changes'. This happens for each block. So this message comes up several times.
What i am trying to achieve is this message should be suppressed so the user is asked this only once. I know once the user answers yes i can do_commit on each block to make changes save. However i have no control over this message and i would like to know the best way to structure an application to avoid this.
Add to trigger where you execute_query or do commit something like this.
:SYSTEM.MESSAGE_LEVEL := '25';
COMMIT;
:SYSTEM.MESSAGE_LEVEL := '0';
This suppress system messages. You did not write what trigger do you use in leaving block.

List of values with multiple return items

List of values, with multiple columns and multiple return values in Apex. It's a question i've seen around the web quite a few times, but i'm struggling with it aswell.
Coming from Oracle Forms, and now migrating forms to Apex, this is a feature i'm missing quite well. It also still baffles me a bit how enormously basic the built-in popup-lov is.
For example, right now i'm making some smaller forms, each having about 4 or 5 multirecord columns, for not much else than having 2 values linked up. Column 1: some value, used in sap for example, column 2: the id of a record in the oracle database (another table than the base table for the block). On column 2 there is an lov, with validate from list, and displays 3 columns, but also returns 3 columns. So you can choose a record from the lov, and automatically, the id will be filled in, aswell as the 'name' and 'description' for said id. Column 1 and column 2 form the base table of the block.
Now, in Apex, i'd loose this functionality by default. So for now, i've mostly coded the onchange event in javascript, and get the values with an ajax callback process. In the popup i concatenate the 3 columns. This however looks stupid (in my most humble opinion) when you want to force the user to pick a value from the lov ('Not Enterable, Show Display Value and Store Return Value'): the item will contain the concatenated value used in the lov, not just the id i'd much rather show - plus, i'll already have my other 2 fields filled in by the ajax callback.
It rather stings a bit to have to deal with this. The users are used to working with these old (headstart generated) forms, with just 2 enterable columns, one of which has an lov. Now they need to start working with this 'new tech', and even though there is some adjustment required, this area does feels a bit archaic at times!
So, i've made it work through an Ajax callback on the onchange event. So, when the value is changed through the lov, extra fields are filled up. This goes together with an after header process, after the automated row fetch, so the values are fetched when the page is loaded (or a user navigates the rows).
I've also written a custom solution, which requires me to create a page with a classic report on it with a search box. I then use this page in an iframe, and pop it up through a modal. When the user selects a record, i return the required returnvalue and a list of displayvalues. This i do through a bunch of javascript, which i've packed in a JS file, and actually requires quite little extra work to do on the pages: include the file on both, make an item with some post element text calling an 'open' procedure, and calling a select-and-close procedure on my lov page. I'm quite considering creating a small item typep plug-in, so i can more easily configure my calling item. Just a couple of buts: i've not actually used this in some forms already, i've engineered this in a testing application after getting frustrated with the standard tool. It would also require the client to maintain this javascript code + remember the config of the 2 items, let alone me writing a small plugin. So i'm hesitant to implement this.
TLDR: if you've been using Apex for a while, and maybe done some forms: how do you actually work with the popups. And if you've known forms: how did you deal with this change?
I'm still struggling - throw me a bone ;)
I haven't used it myself yet but I believe SkillBuilders Super LOV plug-in probably does what you need.

Oracle Apex Apps. Sending data to two tables on submit

I have two tables, HELP_PROBLEMS and HELP_SOLUTIONS.
HELP_PROBLEMS has a number of different fields, including PROBLEM_ID, SOLUTION_ID, PROBLEM_DESC etc.
HELP_SOLUTIONS has just SOLUTION_ID and SOLUTION_DESC.
I'm trying to build form that when you view the edit form of a problem, you can add the solution in a form below it.
In my mind, when I hit the button Add Solution (submit), it creates the new row in HELP_SOLUTIONS, and adds the SOLUTION_ID to the current row in HELP_PROBLEMS. (and update a few other things but trying to keep this as basic as possible).
Is this at all possible? I thought the 'master form' might work but I couldn't seem to sort it out as planned.
Thanks,
C.
You can create a pl/sql block that inserts a value in two different tables.
create a page process and select pl/sql
then try something like
begin
--insert into help_problems
--insert into help_solutions
end;

Resources