PL/SQL Dynamic action [Set Value] not recognizing apex item value - oracle

I have a problem setting the value of an apex item (P13_3) using a pl/sql defined dynamic action. At the moment the dynamic action is triggered using a button. For example if "530000000019" is entered into the item (P13_3), after the clicking the button it should return a value (Product Code) and set the item with that value.
This is the pl/sql code that runs when the button is clicked:
DECLARE
p_code products.prod_code%TYPE;
p_id products.prod_id%TYPE;
BEGIN
p_id := :P13_2;
SELECT prod_code INTO p_code FROM products WHERE prod_id = p_id;
RETURN p_code;
END;
This is the error that appears:
Ajax call returned server error ORA-01403: no data found for Set Value.
This means that no data was returned when the SELECT INTO clause ran. I then altered the code and ran this code to see if there were any faults in the code:
DECLARE
p_code products.prod_code%TYPE;
p_id products.prod_id%TYPE;
BEGIN
p_id := 530000000019;
SELECT prod_code INTO p_code FROM products WHERE prod_id = p_id;
RETURN p_code;
END;
This code returned a value and the set value dynamic action was successful. This therefore means, that in apex was not picking up the value in the P13_3 item.
I have a apex process that has similar syntax that calls the P13_3 apex item and it runs successfully. Here is the code of the apex process:
DECLARE
b_code products.prod_id%TYPE := :P13_3;
p_quant products.prod_qnty%TYPE := :P13_2;
BEGIN
UPDATE products
SET prod_qnty = prod_qnty - p_quant
WHERE prod_id = b_code;
END;
If I am not mistaken, I would say that this proves that the problem lies with dynamic action and not the pl/sql code. I am currently using apex 5.1 (The 16 Dec release). Please Help. Thank you in advance :)

I have tried similar work ,I have created two text boxes one for input & another for output & I am getting expected result .Please check following screen shots of result & dynamic action settings
And dynamic action settings is as follows :
Edit view of True action is as follows :
Hope this will help you.

Related

interactive report with dynamic sql statement

I'm trying to generate an Interactive-Report in Apex with a SQL-Statement which lies in a page item (:P10_SQL), for example: select 1 from dual.
declare
l_sql VARCHAR2(4000 CHAR);
Begin
select V('P10_SQL') into l_sql from dual;
return l_sql;
End;
The Report has the type PL/SQL Function Body returning SQL Query.
Apex shows an error
ORA-20999: WWV_FLOW_EXEC.NULL_QUERY_RETURNED_BY_FUNCTION
Somebody gets an idea?
Apex acts kind of crazy as it doesn't always want to accept code I write (which is perfectly valid), saying that function doesn't return anything. Oh well.
Therefore, my function that returns SQL query was written in stages. The following bullets represents attempts I made; all of them are OK. The final version - the one that runs right now is as simple as return :P77_SQL; (I'm on page 77)
return 'select dummy from dual'
declare
l_str varchar2(4000);
begin
l_str := case when :P77_SQL is null then 'select dummy from dual'
else :P77_SQL
end;
return l_str;
end;
return :P77_SQL;
However: you can't use interactive report, has to be a classic report because not all tables you'll have as a source will have the same column names (unless you use aliases and match number and datatypes, which is rather complicated).
But, if you use a classic report, then turn "Use generic column names" on and set desired number of generic columns (I set it to 10; you'll know what to do in your case).
My P77_SQL text item submits the page when I press ENTER, which causes the report to refresh.
A few examples:

Wrong number or types of arguments error oracle forms

I created procedure under Program Units Oracle Forms
Code:
PROCEDURE VALIDATION_TEST
(p_mid we_group_hof_k.mstatusid%TYPE,
p_status we_group_hof_k.cardstatus%TYPE
) is
begin
insert into test
select mstatusid, cardstatus
from we_group_hof_k
where p_mid = 1
and p_status = 'A';
end;
This procedure complies successfully. I put this line on When-Button-Pressed Trigger "TEST" Button
VALIDATION_TEST;
When I try to compile "TEST" Button then I am getting following error:
wrong number or types of arguments in call to 'VALIDATION_TEST'
I am using oracle forms 11g.
How to solve this problem?
You have defined your procedure with two parameters. Your call of that procedure passes zero parameters. So you solve this by passing two parameters when you call the procedure.
Or maybe by removing the parameters from the procedure's signature. Because quite frankly your code doesn't make a lot of sense. The WHERE clause tests the parameters against hardcoded values. So either you select all the records in we_group_hof_k - if the passed arguments are 1 and 'A' - otherwise none.
Perhaps this is what you need?
PROCEDURE VALIDATION_TEST
(p_mid we_group_hof_k.mstatusid%TYPE,
p_status we_group_hof_k.cardstatus%TYPE
) is
begin
insert into test
select mstatusid, cardstatus
from we_group_hof_k
where mstatusid = p_mid
and cardstatus = p_status;
end;
Then you would call your procedure like this:
VALIDATION_TEST(1, 'A');
Although, as this procedure is called from Oracle Forms probably you need to pass in items from a Forms block. But only you know that for sure.

How to display clob column data on page item APEX?

I'm trying to display the clob column on Page Item. but, it shows the below error message:
I've done the following:
Created page item with display only.
Add plsql returned function into the page item with the below code:
DECLARE
L_CLOB CLOB;
begin
select p_data INTO l_clob from testdel;
:P2_NEW := L_CLOB;
END;
But, it shows as error message.
I would like to return more than 4000 characters. But, no success.
Error computing item source value for page item P2_NEW.
ORA-06502: PL/SQL: numeric or value error
I think you are doing something wrong, please try using below instructions.
Data length stored in table : >4000
first Create item as display only
Item Source
Item Output
Please let me know if any issue there .
Thanks.

Oracle : Execute Query with LOV selected value

I need to run a query with a value that is selected from a LOV.
I've got the next setup :
a block named "MENIU"
a table named "MENIU" with a column "ID_MENIU".
a LOV named "LOV_MENIURI"
a parameter named P_IDMENIU
a button on the form named "Alegeti Meniul"
In order to run a query with the value selected from the LOV I've tried this :
LOV return item "ID_MENIU" is set to PARAMETER.P_IDMENIU
in the pre-query of block MENIU I've assigned the PARAMETER.P_IDMENIU value to MENIU.ID_MENIU
Button "Alegeti Meniul" has the next "when-button-pressed" trigger code :
declare
success boolean;
begin
Enter_Query;
success := show_lov('LOV_MENIURI');
Execute_Query;
end;
My problem is that when pressing the button for the first time nothing happens, if I press the button a second time LOV window appears and the query is executed twice.
A GIF with the outcome:
You don't need that enter_query call.
begin
if show_lov('LOV_MENIURI') then
execute_query;
end if;
end;
When calling the execute_query built-in you'll fire the pre-query trigger, setting the where clause using the value returned by the LOV.

PLSQL Procedure get user input at runtime

Im doing a college assignment that requires me to create a PLSQL procedure that where the user can add a new customer order containing a number of items and the quantity for each item. I came up with the following that would ask the user to input a number of items to be added to the order and would then use a loop to ask for specific details such as product no and quantity. Im having problems with the user input at runtime though... When compiling the code it asks for the product code and quantity and wont ask again at runtime instead it saves the values given earlier at compile...
CREATE OR REPLACE
PROCEDURE Add_Order (Item_amount IN NUMBER, CustNo IN NUMBER) AS
ItemNo NUMBER;
var_Quantity NUMBER;
var_PONo NUMBER;
BEGIN
IF Item_amount BETWEEN 2 AND 9 THEN
SELECT seq_PONo.NEXTVAL INTO var_PONo from dual;
INSERT INTO PurchaseOrder_tab
SELECT var_PONo, REF(C),
SYSDATE,
ItemList_tab()
FROM Customer_tab C
WHERE C.CustNo = CustNo;
FOR i IN 1..Item_amount LOOP
DBMS_OUTPUT.PUT_LINE('INSIDE LOOP');
ItemNo := &Enter_ProdCode;
var_Quantity := &Quantity_Amount;
INSERT INTO TABLE (
SELECT P.ItemList
FROM PurchaseOrder_tab P
WHERE P.PONo = var_PONo
)
SELECT seq_ItemNo.nextval, REF(Pr), var_Quantity
FROM Products_tab Pr
WHERE Pr.ProductCode = ItemNo ;
DBMS_OUTPUT.PUT_LINE('Added '||var_Quantity ||' items of '||ItemNo||' to order No: '||var_PONo);
END LOOP;
ELSE
DBMS_OUTPUT.PUT_LINE('Amount of items entered onto an order must be between 2 - 9. Please try again with correct amount.');
END IF;
EXCEPTION
WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Operation failed '||'SQLCODE: '||SQLCODE);
DBMS_OUTPUT.PUT_LINE('SQL Error Message '||SQLERRM);
ROLLBACK;
END;
/
Short answer: you can't. PL/SQL is executed inside the database engine, and the database engine has no access to the terminal window (or database tool) you are using to start the procedure.
The code in your quesion seems to partially work, because it asks for input once, but what really happens is that: the tool (SQL*Plus, SQL Developer or whatever) parses over the PL/SQL block and sees the &-Signs, so it asks what to replace them with. Once the input is given, the PL/SQL-Block - including the entered values - is given to the database for execution.
Since you can't do that in PL/SQL, better create a front-end program first that collects the values, then sends them to the database.
Try to play around with :
BEGIN
DBMS_OUTPUT.GET_LINE(:buffer, :status);
END;
Instead of using & refferences
To Get data input from the USer,
SET SERVEROUTPUT ON;
ACCEPT Enter_ProdCode VARCHAR2 PROMPT "Please enter Product code : ";
ItemNo := &Enter_ProdCode;

Resources