Grabbing values from select list - oracle-apex

i have a select list displaying all the names from the table X
i want to add id of that corresponding name in to another table naming Y.
HOW TO GRAB VALUE FROM SELECT LIST AND STORE IT IN TO DATABASE TABLE???

A list of values doesn't depend on anything; you can write any query you want (which includes your table X), as long as it returns two values: display and return ones. For example:
select name display_value,
id return_value
from table_x
where <some condition, if there's any>
order by name
If you create a form page and make its source table Y, choose which one of the columns should contain an ID returned by the Select List item and put the above query into its LoV property.
Run the page;
choose a value from the Select List;
Submit
Should be OK.

You need to create an Apex process to perform your desired action, like store the value in your database.
Once your user selects a value from your LOV, usually you'll want to submit the page, which you would tell to run that process.
Alternately, you could create a Dynamic Action on the LOV that runs a PL/SQL process to do your database change.
You may have gotten an answer by now but I thought I'd take a swing at it. I'm trying to get my reputation over the next threshold. :-)

Related

Oracle APEX - setting a default value for a Popup LOV

I have a popup LOV on my page and it is populated via the shared component. What I want is when the underlying query pulls only one record, to have it pre-selected in the LOV by default. Is that possible?
Can it be done ? Most probably ;) I have not tested this but this is how it could be done:
Create a computation to set the page item to the value of the single row.
Add a condition to the the computation so it only fires if the query above returns a single row.
For the condition, one possibility is to use a type "rows returned" with a query like the one below:
WITH count_rows (cnt) AS
(
select count(*) from (<your shared component query>)
)
SELECT 1 FROM count_rows WHERE cnt = 1;
Now, if you want to make this really dynamic you could write some code against the view APEX_APPLICATION_LOVS to pull the query from the shared component and check if it only returns a single row. Note that in this case, whenever the shared component changes the code on your page might break.

Select List item default value

I have Select List item based on List of Values (Shared Components). As default value is null and there is problem, I have another Select List item based on SQL Query which one uses value of first Select List. Cascading List of Values not helping. How I can set first Select List value as first value by default? Clientside value is not null, but serverside is. Exactly I can change Source of first Select List item, but I don't want use the same query which one I use in List of Values from Shared Component. Page submit or item submit in Dynamic Actions is slow and user see that. Are there any other solutions?
P.S: For example first Select List displays Countries, second Select List displays cities. In my case when first Select List is null, second Select List displays all cities from all contries, I don't want this, I want to make first Select List without null value and second Select List with values (cities) by value from first Select List (country, not null).
In one of application page it works like I need, but I can't understand how, and I can't find the difference in code. In page where it works session page displays item value (Page Items, Session State), in another isn't.
If you set "Display NULL value" to "No", it will show the first value of the select list

QuickSight: How can I use ifelse() or any other alternative for multiple conditions according to input provided in the added parameter?

I get the option of ifelse() in the Functions list when I am trying to add a calculated field while editing the data, but do not get it from the 'Add' option where I get the option to Add title, Add description, Add calculated field, Add parameter. I get options like sumif, avgif, countif but there I can provide only one condition.
I want to create an ifelse(0) function with multiple conditions dependent on a parameter value which user selects from a dropdown.
If you want to add ifelse() function you have to add it at the Dataset section. it is not available in Data analysis section.
If you want to add multiple choice values in the parameter, then you have to add the list of items by
click on Add Parameter
in the "Create new parameter" dialogue box, select multiple values then write the list of items by each line in the below text area.
then click on the create.
Currently IfEsle() is not supported in analysis based on SPICE dataset. If you want to use IfElse() in analysis convert SPICE dataset to a Direct Query dataset.

How to set a value to an application item in oracle apex 5

I have several tabs. There is a date picker on each tab. I need that date to be the same on all tabs no matter what. So, if the user changes the date on Tab 1, then goes to tab 2, the date on tab 2 will have changed also. I have never created an application level item before and I thought that might be the most efficient way to accomplish what I need (by setting that item's value to the date the user selected). My problem is that I don't know how to set the value of the application item and also how to retrieve that value on another tab.
You didn't describe what exactly you're trying to do, but - if each tab represents its own table, why do you keep the same date value in all of them? Doesn't look like a normalized data model. Consider using a single date column (in one - master - table) and use (i.e. reference) it in others (i.e. details).
As of your question: How about creating a global page (i.e. page 0) and having a date picker item on it? You can display it on any other page you want. For example, if you set its value while on tab 1 and then move on to tab 3, you can again modify that value which will be visible on all other pages. Basically, you'd maintain just one item instead of as many as number of tabs involved. (BTW, doesn't that remind you of what I described in the first paragraph?).
Alternatively, create a date picker item on tab 1 page; on all other pages, create a "lookup" (display) item which would simply display what's been selected on tab 1. That's easy to do, just make its source to be an "Item", such as P1_DATE_ITEM.
In Shared Components > Application Items create new Item called G_DATE.
Then for every datepicker add Dynamic Action on Event Change.
In True action Set Value select Type PL/SQL Expression with code
:G_DATE := :P1_DATEPICKER1;
and Items to Submit :P1_DATEPICKER1
Next in every datepicker Source set Type PL/SQL Expression with code
:G_DATE
used Always (...)
Regards

Copy Records in Oracle Apex

I need to copy selected row values and store as a new record.
I am using Oracle Apex 4.2 and Tabular Form.
I need to use checkbox to select the rows and button copy. When i select multiple rows followed by click copy button to copy all the selected row values as new rows and save.
Can anyone Help
Copying Records Through an APEX Tabular Form Input
The idea of cloning existing records from a single table through an Oracle APEX Tabular Form works without much interference with the default design that you can set up through the APEX wizard for page region content.
Build a table with an independent primary key.
Suggested to include two auxiliary columns: COPY_REQUEST and COPIED_FROM for running copy operations. Specific form elements will map to these columns on the tabular form that will be set up.
Build an Oracle stored procedure that can read which records need to be copied. This procedure will be invoked each time the SUBMIT button is pressed.
(optional) Consider including a suppression of step (3) in the event that there is nothing to process (i.e., no records marked for copying).
The Working Table for Receiving Input: COPY_ME
TIP: You will have an easier time if you use the standard TABLE creation wizard. Designate CUSTOMER_ID as the PRIMARY_KEY and have APEX create its standard auto-incrementing functionality on top. (sequence plus trigger set up.)
Here's the sample data I used... though it doesn't matter. You can put in your own values and be able to verify what happened easily.
The Heavy Lifting: The Stored Procedure for Cloning Records in COPY_ME
This procedure works with 1 or more records at a time with a special identifier in the COPY_REQUEST table. After the task is done, the procedure cleans up and resets the request value again.
create or replace procedure proc_copy_me_request is
c_request_code CONSTANT char(1):= 'Y';
cursor copy_cursor is
SELECT cme.CUSTOMER_ID, cme.CUSTOMER_NAME, cme.CITY, cme.COUNTRY,
cme.COPY_REQUEST
FROM copy_me cme
WHERE cme.COPY_REQUEST = c_request_code
FOR UPDATE OF cme.COPY_REQUEST;
BEGIN
FOR i in copy_cursor LOOP
INSERT INTO copy_me (customer_name, city, country, copied_from)
VALUES (i.customer_name, i.city, i.country, i.customer_id);
UPDATE copy_me
SET copy_request = null
WHERE CURRENT OF copy_cursor;
END LOOP;
COMMIT;
END proc_copy_me_request;
There is also a column that can be hidden. It tracks where the record was originally copied from.
Note that the cursor is using the FOR UPDATE OF and WHERE CURRENT OF notation. This is important because the procedure is changing the records that are referenced by it.
APEX Page Setup Instructions
Set up a standard FORM type page and choose the TABULAR FORM style. Follow the set up instructions, taking care to map the correct primary key, and also to the PK sequence object created with the table in the previous steps above.
This is what your page set up will look like after these steps are completed:
EDIT The COPY_REQUEST Form Value:
Under the column attributes section, change the Display As option to "simple checkbox"
Under the list of values section, put a single value under the LOV Definition: Y (case sensitive in either way... just be consistent)
EDIT The COPIED_FROM Form Value:
Under the column attributes section, change the Display As option to "Display as Text(Saves State)". This is just to prevent users from stepping on this read-only field. You could also suppress it if it isn't important to know.
CREATE a New Process: Execute Copy Procedure
This is the bottom of the same configuration page, there are very few things to change or add:
Demonstration: Screenshot of COPY_ME Tabular Form Page in Action
The first screenshot below is before the page is tidied up and the checkbox control is put into place.
Plug in some test data and give it at try. The Page Process created in the step above conditionally invokes the stored procedure that processes all copy requests made at the same time when the SUBMIT form button is selected.
COMMENTS: If you spend enough time tinkering around with the built-in wizards in Oracle APEX, there are opportunities to learn new design patterns and process flows compatible within the tool. Adapting your approach can reduce the amount of additional work and frustration.