How to Dynamically create real APEX input items (not just html input) - oracle

Does anyone know how to dynamically create real Apex items, such as a text input field or a date picker?
We know to do something like so:
select
APEX_ITEM.TEXT (
p_idx => 1,
p_value => NULL,
p_attributes => 'placeholder="placeholder" class="myItem"'
) item from dual
What we want is actual items with Apex properties/attributes, similar to when you insert items manually in the builder. Among those for example Template, Label, Value required, Security attributes etc.
Thanks in advance!

Related

How to create and use a multi-select list in APEX ORACLE?

I have a table called Employees with Employee_id and Employee_Name columns. Now i want to create a page with Checkbox in-front of every Employee Name, select the ones that are needed, store them into a temporary table and use them for further operations. The problem i am facing is to how to create that multi select list and store the select values in thee table. Is there an Item for multi select? If not, how should i do it?
There's the Shuttle item. On the left side, you'd display list of all employees. Item buttons allow you to move all (or only some of them) to the right side of the item. Once you submit the page, list of employee IDs is stored into a table column in a form of colon-separated values, for example
6547:8879:5587:9987
This is a simple way of doing that. However, once you have to actually do something with those values, you have to split them to rows. Not a problem, though. Here's a query:
SQL> with emps (shuttle_item) as
2 (select '6547:8879:5587:9987' from dual)
3 select regexp_substr(shuttle_item, '[^:]+', 1, level) one_item
4 from emps
5 connect by level <= regexp_count(shuttle_item, ':') + 1;
ONE_ITEM
---------------------------------------------------------------------
6547
8879
5587
9987
SQL>
Or, you could create a tabular form which also displays all employees and has checkboxes at the beginning of every line. You'd then create a process which - in a loop - stores selected values into a temporary table you mentioned. For example:
-- F01 = row selector. If you check 1st and 3rd row, f01.count = 2 (2 rows checked)
-- f01(1) = 1 (row #1), f01(2) = 3 (row #3)
-- F02 = EMP_ID. f02(1) = EMP_ID that belongs to employee in 1st row,
-- f02(3) = EMP_ID that belongs to emplyee in 3rd row
declare
l_id number;
begin
for j in 1 .. apex_application.g_f01.count
loop
l_id := apex_application.g_f02(apex_application.g_f01(j));
insert into temp_table (emp_id) values (l_id);
end loop;
end;
There is an option for creating multi select list in oracle apex 5.1.
Create a pageItem of type: 'select list'.
Make the 'Allow multi
selection' to 'Yes'.
Write the SQL query for your select list under
the 'List of Values' attribute.
Then the select list will be
displayed based on our query.
Query format is:
select [displayValue],
[returnValue]
from ...
where ...
order by ...
Now once you select multiple value from select list(using ctrl+click), these are stored as ':' separated values in the select list page item.
I've created a video some times ago that covers your problem. It's a step by step tutorial how to create checkboxes and process them.
Video is available here:
https://www.youtube.com/watch?v=T-LXRMWQbPk
Regards
If the list is too big, I recommend to use the Popup LOV item with the Multiple Values switch activated instead the Select list or the Shuttle, because it has an internal search field for the objects list, doing way easier for the user to find the target values. Also, just as the Select List or Shuttle item, you can set a Separator character for the selected fields.

Oracle forms sort records

What I wanted is to sort records in a multi-record block before saving like this:
I already tried to change the order by of this item in here:
But it has no effect(I think).
I also want to know if I can automatically sort records in
WHEN-NEW-RECORD-INSTANCE in block level so that after entering the last record, it will be sorted.
We need to have a multi-record block ( block1 ) with Query Data Source Name property set to a table name which has a varchar2 type column namely str1,
and a Text Item (str1) with Database Item Property is "Yes" ( i.e. default ),
and lastly have a button with the following code inside of WHEN-BUTTON-PRESSED trigger of it :
declare
v_blk varchar2(25) := 'block1';
begin
commit_form;
go_block(v_blk);
execute_query;
end;
Provided we set ORDER BY Clause property set to ascii(str1) as in the picture below, we'll be able to get the desired output when the button pressed after letters are entered in the order of 'h','e','l','l','o'.

Transfer values between pages in Oracle APEX

I am working on Oracle APEX 5 and wanted to transfer values added into List manager (in page 2) to display them on Page 3 as read-only. How can we do that?
What type of item to choose to display values in page 3? and how to get these values from list manager?
please help.Thanks in advance.
The List Manager item type can hold multiple values, which are delimited by a colon e.g. '7782:7902:7788:7698'. If you pass this item value to a hidden item in the target page then you can call apex_string.split to convert it to an array of values, which you can then process as you wish. For example, if the values are EMPNOs and you want to display all the names in a display only item you can write code like:
declare
empno_array wwv_flow_t_varchar2;
begin
empno_array := apex_string.split (:P3_HIDDEN_ITEM, ':');
select listagg (ename, ', ') within group (order by ename)
into :P3_DISPLAY_ITEM
from emp
where empno in (select column_value
from table(empno_array));
end;

Oracle Apex 5.1: About creating an empty input form like the input form when creating table

I want to create a form using oracle apex 5.1 like the image below. But I do not know how to create it. Could anyone direct me achieve this?
You can use APEX_ITEM.TEXT in your query:
select empno,
APEX_ITEM.TEXT(25,ename) ename,
job, mgr, hiredate from emp;
You have to click on column (ename) in Columns section of your report and set Escape special character to No.
If you use Interactive report you can put HTML Expression for every column like:
<input type="text" value="#JOB#">
To show data from column in input just set value to be #NAME_OF_COLUMN#.
For empty input just add column in query:APEX_ITEM.TEXT(25,'') text_input or if you prefer second aproach add empty column and set HTML expression.
select empno, ename,'' as text, job, mgr, hiredate from emp;
Here is APEX_ITEM.TEXT function from Oracle Apex doc.
APEX_ITEM.TEXT(
p_idx IN NUMBER,
p_value IN VARCHAR2 DEFAULT NULL,
p_size IN NUMBER DEFAULT NULL,
p_maxlength IN NUMBER DEFAULT NULL,
p_attributes IN VARCHAR2 DEFAULT NULL,
p_item_id IN VARCHAR2 DEFAULT NULL,
p_item_label IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;
Items can be created in an HTML Region to create a form. You will then need to create Processes to perform the action(s) required when submitting the form.
The documentation explains it step by step : https://docs.oracle.com/cloud/latest/db121/HTMDB/app_forms004.htm#HTMDB30063
Use the new Integrated Grid feature that replaced the "old" tabular form:
See documentation: https://docs.oracle.com/database/apex-5.1/HTMDB/about-making-grids-editable.htm#HTMDB-GUID-0A317D17-5B12-4F4A-B5C8-68807DB5A4C1

filter tablix without datasource values in ssrs

I have SSRS report and I need to filter a static table that I created inside the report based on parameter. There is no data source to this table and I'm entering the data manually.
The tablix contain 3 columns.
How can I filter the columns based on parameter?
I tried in the expression =#param1 for example but it doesn't work.
For now I only manage to filter if the expression is on data source fields.
Do you literally have a table with a number of values in it written directly into the report? If so I don't think you will be able to perform any filtering on it as effectively all you've done it write data into textboxes that are displayed.
I would imagine your best option would be to instead create a new dataset and populate this with your static data, e.g.
SELECT 'A' AS Letter, 'English' AS Language
UNION
SELECT 'B' AS Letter, 'French' AS Language
UNION
SELECT 'A' AS Letter, 'German' AS Language
To give you a table as follows
Letter | Language
-------+----------
A | English
B | French
A | German
That you could then filter on Letter = A
So essentially you have a Tablix that has 3 columns pre-populated with information you have manually entered into the text boxes themselves? Since you've already entered that data, I don't believe there is a way to filter that at run time. That data is hard coded in essence. The Filter ability in SSRS is used as a WHERE clause so it restricts what is brought forth into the report from the query.
I would create a data source connection to a dummy database, create a DataSet, and create a query that fills a temporary table will all the information that you've manually entered. Once you create the temporary table and inserted values into it, you can then perform a SELECT with a parameter. Your Tablix will only be populated with information that matches the parameter. Something to the effect of this:
CREATE TABLE #TempTable (
ID INT
,Name VARCHAR(MAX)
,Email VARCHAR(MAX)
)
INSERT INTO #TempTable (
ID
,Name
,Email
)
VALUES (
1
,'Bob'
,'bob#email.com'
)
,(
2
,'Frank'
,'frank#email.com'
)
,(
3
,'Jim'
,'jim#email.com'
)
SELECT
*
FROM
#TempTable
WHERE
ID = #ID
DROP TABLE #TempTable

Resources