I have a select list based on other select list. It works fine on the create screen but gives 'Invalid number' error in update screen.
SQL query:
select description, account_id
from t_account
where chart_id = :P15_chart_name
Please help me out!
You are trying to convert a string into a number, and that failed.
As Select List item has 2 values: 1st being display and the 2nd return value, it is the 2nd value that causes problems - account_id in your case.
For example, it contains value A while column that is supposed to accept this value is declared as NUMBER. Oracle can't convert A into a number and raises an error.
What to do?
make sure that Select List item LoV query returns only numbers, or
modify column's datatype to varchar2
If that's not it, then :P15_CHART_NAME item and chart_id table column differ in datatypes; a simple option is to fix page item's datatype.
Related
From a query I want to replace the null values of the "cod_account" field, the condition to fill this field is that it must take the previous value only if it satisfies that the previous records of other fields (cod_agen, cod_sub, no_prod) are equal.
Currently it is like this:
enter image description here
what is desired is
enter image description here
thanks for your advice. i solve it
use with to separate queries.
select
case when cod_account is null and class ='Primary'
then null
when cod_account is null and class='Secundary'
then (select cod_account from principals P--principals is table create in a "with"
where fa.cod_agen=P.cod_agen
and fa.cod_sub=P.cod_sub
and fa.no_prod=P.no_prod
and p.class='secundary'
)
...
from signs fa
I am trying to make a cost value populate in an interactive grid column based on the value selected in an Item column.
My setup is:
An "Item" table which contains a list of Items, and the "Cost" assigned to the item.
A "Quote" table which contains general info about the quote, i.e. company name, date created, signed, signed date etc.
A "Quote_Items" table which assigns an Item to a quote by Quote_ID, and Item_ID. I added a Cost column to the Quote Items table to be able to see it in the interactive grid, and update it.
For the Quote Items I created an Interactive grid to add Items to the quote.
I set the Item_ID column in my interactive grid to a popup LOV which populates the Item_ID based on the selected item.
To populate the "Quote_Item.Cost" I added a dynamic action to the Item_ID column to:
Event:Change
selection Type: Column(s)
Region: ..Item List
Column(s): Item_ID
Action: Set Value
Set Type: SQL Statement
SQL Statement: SELECT I.COST
FROM WIP_ITEMS I
WHERE I.ITEM_ID = ITEM_ID
Items to Submit: COST
The result is, when I select an Item from the dropdown, all values in the "Items.Cost" table are displayed in comma separated values in the field:
Quote Item populating all item costs in one field
It seems like the "WHERE I.ITEM_ID = ITEM_ID" part of the SQL query is not working correctly? How can I get it to show only the Value associated with the Item_ID?
Syntax to reference a column in the SQL query > :COLUMN_NAME
So your SQL query should looks like this:
SELECT i.cost
FROM wip_items i
WHERE i.item_id = :ITEM_ID
And you need to modify the "Items to Submit" parameter too, because it must always be the value which your reference in the where condition, so in your case it should be:
Items to Submit: ITEM_ID
I want to display the item from different table, I am using POST-QUERY trigger
:
SELECT Stock_code
INTO :exchange.stockcode
FROM Exchange_Stock
WHERE Exchange_code = :exchange.Exchange_code;
it come up with FRM-40735 and ORA-01422
but it display some of the record (not all),
I have no idea what is wrong
Most probably the POST-QUERY trigger fires just after the fields of table-based block with multiple records are populated. Obviously Exchange_code values are not unique throughout the table data, whereas a SELECT .. INTO .. FROM ... clause only can bring one row record.
So, you can try to filter out the results so as to get single rows for each parameter fields combinations such as :exchange.Exchange_code & :exchange.code_order instead of only :exchange.Exchange_code field within the WHERE condition :
SELECT Stock_code
INTO :exchange.stockcode
FROM Exchange_Stock
WHERE Exchange_code = :exchange.Exchange_code
AND code_order = :exchange.code_order;
where important thing is to get single row from the query matching for each record in the data block. You can still add more condition to the query if this condition is not provided yet.
I have written a PL/SQL procedure as:
CREATE OR REPLACE PROCEDURE checkProdQuantity (productid IN number, orderqty IN number)
IS
qty number;
qty_diff number;
BEGIN
SELECT quantity INTO qty from Products where ProductID=productid;
IF orderqty>qty THEN
dbms_output.put_line('Ordered quatity is greater than available quantity');
ELSE
qty_diff:=qty-orderqty;
UPDATE Products set quantity=qty_diff where ProductID=productid;
END IF;
END;
/
But when I try to execute this procedure with valid parameters, it shows an error: exact fetch returns more than the requested number of rows.
I have checked my table, and for the parameters I am supplying it should return only one row. I think for some reason, the value of productid IN parameter is not being read in the select query. Even if I provide some random values for productid parameter, it still gives the same error. I am unable to figure out where the problem is.
I don't think the compiler is distinguishing between the parameter productid and the column name ProductID.
Try renaming your parameter to a_productId, or something different from the column name.
Its happning because, when you write
SELECT quantity INTO qty from Products where ProductID=productid;
Oracle scope resolution interprets productid as the column_name and not as your input variable.
Change the name of the input variable to something other than the column name and it should work.
Hope it helps
Vishad
I have an Apex page with a select list item populated from a SQL query that should default to the product of the item passed through from another page, however it always selects the first item in the list.
We need to set it so it selects the current category however I can't see where this setting is. The version of APEX is 3.2.
Firstly, I suspect (correct me if I'm wrong) that your item is selecting the first item because the item is defined with Display Null Value set to No; internally, however, the item is probably NULL, but the list item cannot show it so it just shows the first list value. But I probably wouldn't change this setting.
To set the default value for a Select List item, set Default Value Type to PL/SQL Function Body, then enter your SQL query (that returns a single value) in the Default attribute for the item, with suitable PL/SQL around it, e.g.:
DECLARE
v_value VARCHAR2(<your data max length>);
BEGIN
SELECT <yourcolumn>
INTO v_value
FROM <yourquery>;
RETURN v_value;
END;