Making a search bar manually WITHOUT interactive report. (Oracle APEX) - oracle

I am trying to make an application completely manually without using any interactive reports or generated PL/SQL. Everything is working at the moment but I am stumped when it comes to the search bar and I can't find anything online to help me.
I have a classic report called 'Browse Job Vacancies' and a 'Search' button; I also have the 'C1_JOB_TITLE_ITEM' search bar and a page process called 'Search'.
In the process I have this code:
SELECT
JOB_CODE,
JOB_TITLE,
JOB_DESCRIPTION,
SITE_NAME,
EMAIL_ADDRESS,
TELEPHONE_NUMBER,
SALARY,
START_OF_PLACEMENT,
APPLICATION_METHOD,
APPLICATION_CLOSING_DATE
FROM JOB
WHERE upper(job_title) = upper(:C1_JOB_TITLE_ITEM);
I am getting this error:
ORA-06550: line 1, column 64: PLS-00428: an INTO clause is expected in this SELECT statement
So I created this code:
DECLARE temp_row char;
BEGIN
SELECT
JOB_CODE,
JOB_TITLE,
JOB_DESCRIPTION,
SITE_NAME,
EMAIL_ADDRESS,
TELEPHONE_NUMBER,
SALARY,
START_OF_PLACEMENT,
APPLICATION_METHOD,
APPLICATION_CLOSING_DATE
INTO temp_row
FROM JOB
WHERE job_title = :C1_JOB_TITLE_ITEM;
END;
Here I am getting this error:
ORA-06550: line 13, column 16: PL/SQL: ORA-00947: not enough values
I am completely stumped on what to do at this point so any help at all is greatly appreciated. Sorry if I'm not being detailed enough this is my first time writing in Stack Overflow.

(Editing because someone didn't think this was an answer.)
You say you have a page process. You don't need any sort of process for this. You should have a Region with the following properties (assuming 18.x):
Type = Classic Report
Source > Location = Local Database
Source > Type = SQL Query
Source > SQL Query > your query from your first block above
Apex will run the query and create a report based on it. Processes are for PL/SQL blocks that do something like populating data or manipulating the database in some way.
When you enter a keyword in your item and click your button (the button action should be Submit Page), Apex will populate C1_JOB_TITLE_ITEM in session state with the user's value, then use that in the bind variable when it re-generates the page.

1) Create a classic report with that SQL as the source code.
2) Set C1_JOB_TITLE_ITEM in Page Items To Submit attribute, just under region source.
3) Create the page item C1_JOB_TITLE_ITEM, as your search field.
4) Create a Dynamic Action on Change of that item, and refresh your classic report region. The timing of this refresh is up to you. Step 2 ensures the value you've typed in the browser is sent to the database for the purpose of re-running that query.
Do you have a function based index on upper(job_title)? Otherwise you may experience performance issues.

Related

Oracle Apex Apex_application.G_fNN processing not pulling all the values

I'm very much new to oracle apex and have been constantly failing on creating tabular form for inserting data into my table. My scenario is as follows.
i have two tables
1. tasks(task_id, task_Name)
2. Efforts (Eff_id,Task_id,Hours_spent,NOtes).
I want to create a tabular form to insert data into Efforts table with the tasks that I've in Tasks table. I created the tabular form with the query below.
SELECT APEX_ITEM.CHECKBOX(1,TASK_ID) "TASK_ID",
TASK_NAME,
APEX_ITEM.TEXT(2,'')"HOURS_SPENT",
APEX_ITEM.TEXT(3,'')"NOTES"
FROM TASKS;
but when I create the "after Submit" process to read the values of this report and tried to insert into my table effortS with the following code, something strange is happening. When i select the checkbox of row-1,2 and 3 then only row 1 is getting inserted into my efforts table but for the rest, only task id values are getting inserted not the whole row. I was missing "hours_spent and NOtes". in my efforts table for rows-2 and 3..here is my plsql block
BEGIN
FOR i in APEX_APPLICATION.G_F01.COUNT LOOP
INSERT INTO EFFORTS(EFF_ID,TASK_ID,HOURS_SPENT,NOTES)
VALUES (SEQ_EFFORTS.NEXTVAL,APEX_APPLICATION.G_F01(i),APEX_APPLICATION.G_F02(i),APEX_APPLICATION.G_F03(i))
END LOOP;
commit;
END;
Can Someone help me! if there's another way of doing my requirement, then I'm more than happy to do it..
Welcome to the APEX community.
This is a classic problem, due to the nature of HTML
Get the values of the selected rows with checked checkbox
Note, the usage of tabular forms is also waning in favour of Interactive Grids.

Select row value from column in interactive report

Version: Oracle 18.2
I have an interactive report in my application. When I click the 'delete' icon, I want to delete information about the user I selected. Is there a way to get the value from the 'Facility Manager' column so I can use that value in a select statement to perform the delete statement.
I've tried to do it by using the ROW_ID variable (:selected_rowid) but this didn't work.
+ Interactive Report Image
+ Set Value statement
The column value is referenced by hashes, e.g. #STUDENT_ID#.
Have a look at what Jackie McIlroy wrote, "Delete a Row of a Report with a Dynamic Action" (https://jackiemcilroy.blogspot.com/2018/03/delete-row-of-report-with-dynamic-action.html) . She describes the process in details, with a lot of screenshots.
If I were you, I'd do one of the following:
use an interactive report with a form (and navigate to the form in order to delete a row)
if it has to be a tabular layout, I'd try
the old tabular form
the new interactive grid
I don't think I'd remove rows from the interactive report (but OK, that's just me, and my ideas usually aren't too smart).

PL/SQL: ORA 01422 fetch returns more than requested number of rows

I am developing an order transaction where a user can order a product. Once they clicked the 'add to cart' button, it will be able to save on the database in how many times they want with the same order id. Order id is like a transaction id.
My problem is that whenever I want to display the items that customer ordered, it displays an error or ORA 01422. How can I resolve this error?
Here is my code
DECLARE
order_item_id NUMBER;
BEGIN
order_item_id := :MOTOR_PRODUCTS_ORDER.M_ORDERID;
SELECT MOTOR_ID,
MOTOR_QTY_PURCHASED,
UNITPRICE
INTO :MOTOR_ORDER_ITEMS.MOTOR_ID,
:MOTOR_ORDER_ITEMS.MOTOR_QTY_PURCHASED,
:MOTOR_ORDER_ITEMS.UNITPRICE
FROM MOTOR_ORDERS
WHERE motor_order_id = order_item_id;
END;
As krokodilo says, this error is caused because your query returns multiple rows. Depending on what you want to do, you have a couple of options.
If you want multiple values then either use a loop and process them one row at a time (if you are going to be performing a dml operation use bulk collect). If you only want a single row then narrow your result set down with an extra where clause, or use MAX to ensure you only get one value back.
If there is more than one row which will be returned from a query you'll need to use a cursor. One way to do this is with a cursor FOR loop:
DECLARE
order_item_id NUMBER;
BEGIN
order_item_id := :MOTOR_PRODUCTS_ORDER.M_ORDERID;
FOR aRow IN (SELECT MOTOR_ID, MOTOR_QTY_PURCHASED, UNITPRICE
FROM MOTOR_ORDERS
WHERE motor_order_id = order_item_id)
LOOP
-- Do something here with the values in 'aRow'. For example, you
-- might print them out:
DBMS_OUTPUT.PUT_LINE('MOTOR_ID=' || aRow.MOTOR_ID ||
' MOTOR_QTY_PURCHASED=' || aRow.MOTOR_QTY_PURCHASED ||
' UNITPRICE=' || aRow.UNITPRICE);
END LOOP;
END;
Best of luck.
This looks like a Forms question; is it? If so, my suggestion is to let Forms do that job for you.
According to what you posted, there are two blocks:
MOTOR_PRODUCTS_ORDER (a master block, form type)
MOTOR_ORDER_ITEMS (a detail block, tabular type)
I guess that there is a master-detail relationship between them. If there's none, I'd suggest you to create it. Although you can make it work without such a relationship, it'll be much more difficult. If you are unsure of how to do it, start from scratch:
delete MOTOR_ORDER_ITEMS block (detail)
create it once again, this time by following the Data Block Wizard
Set MOTOR_PRODUCTS_ORDER to be its master block
Relationship is on ORDER_ID column/item
Let's presume that by this point everything is set up. Retrieving items that belong to that ORDER_ID is now very simple:
navigate to master block
enter query mode
enter value into an item that represents ORDER_ID
execute query
End of story. Forms triggers & procedures (which were created by the Wizard) will do its job and retrieve both master and detail records.
No need for additional coding; if you're skilled developer, you can create such a form in a matter of minutes. Won't be beautiful, but will be effective & reliable.
There's really no use in doing it manually, although it is possible. Your code works if there's a single item for that ORDER_ID. For two or more items, as you already know, it'll fail with TOO-MANY-ROWS error.
Basically, if you insist, you should use a loop:
you'd enter ORDER_ID into the master block
as you need to move through the detail block, i.e. use NEXT_RECORD, which is a restricted procedure, you can't use number of triggers (open Forms Online Help System and read about them) so a "Show items" button (with its WHEN-BUTTON-PRESSED trigger) might be just fine
a cursor FOR loop would be your choice
for every row it fetches, you'd populate block items and
navigate to next record (otherwise, you'd keep overwriting existing values in the 1st tabular block row)
As I said: possible, but not recommended.

How to count the no of lines in a particular cell in a table column through PL/SQL

Oracle >> How to count the no of lines entered in a cell in table, because i want to restrict maximum line for a customer. friends kindly give some suggestions to execute this command with SQL and PL/SQL..
Create a validation on that page that runs when query exists.
Add this query changing P1_item with the name of your page item:
SELECT 1 from dual where length(:P1_item) - length(REPLACE(:P1_item, chr(10), ''))>10
Using this when you submit the page if there are more than 10 new lines in your page item the validation will popup an error.

Oracle APEX; changing values after update/insert

I am developping a web application in Oracle Application Express (Apex) technology.
I have a page where I can add a new record to a table called 'tz_tab'. That table has a column 'pos' which is one letter (single char) - 'Y' or 'N'. Now, i'd like to do something like this:
When post processing (== updating/inserting 'tz_tab') form on the page - check if 'pos' value is 'Y'
If so - update the rest of records in 'tz_tab' values to 'N'
I tried creating triggers on 'tz_table' but with no success.
Summing up, I need to have only one record with 'pos' value == 'T' in 'tz_tab'.
Is there any method to do this by APEX or should it be done with oracle triggers?
Thanks!
It sounds like you can achieve this by creating a PL/SQL process in your APEX page that will fire after submit. You should be able to check page items and perform an UPDATE statement as required.
You don't say how you're doing your processing in Apex, but you can create a page process that fires after your insert/update step with something like.
UPDATE tz_table SET pos = 'N' WHERE id != :ID_OF_THE_ITEM_JUST_UPDATED

Resources