Master Detail Form - Update Statement for Column in the Detail Section
Hello,
I've posted a demo application to apex.oracle.com
Application# 49298
Application Name: Street_Inventory
Basically, on page 3 I have a Master Detail Form. In the Detail section, I want the value of On_hand to save to table ITEMS. Here's my code below.
SOURCE
select
"CONSUME_DETAIL"."CONSUME_DETAIL_ID",
"CONSUME_DETAIL"."CONSUME_HEADER_ID",
"CONSUME_DETAIL"."ITEM_ID",
"CONSUME_DETAIL"."CONSUMED_QUANTITY",
("ITEMS"."ON_HAND" - "CONSUME_DETAIL"."CONSUMED_QUANTITY") as "ON_HAND"
from "CONSUME_DETAIL",
"ITEMS"
where "CONSUME_HEADER_ID" = :P3_CONSUME_HEADER_ID
and "CONSUME_DETAIL"."ITEM_ID"="ITEMS"."ITEM_ID"
UPDATE INVENTORY PROCESS
UPDATE ITEMS
SET ON_HAND = :P3_ON_HAND - :P3_CONSUMED_QUANTITY
WHERE ITEM_ID = (select ITEM_ID
from CONSUME_DETAIL
where CONSUME_DETAIL_ID = :P3_CONSUME_DETAIL_ID);
My code isn't working. What am I doing wrong?
WReed,
The first thing I see "off the bat" is that you don't have items named P3_ON_HAND and P3_CONSUMED_QUANTITY which are referenced in your code. Although it's possible to do what you want with just SQL, I updated your code with a little PL/SQL to make it easier to understand...
As you'll see the problem now is that the design/db model is not quite right as your getting a too many rows error.
Regards,
Dan
http://danielmcghan.us
http://sourceforge.net/projects/tapigen
Similar Messages
-
Update statement for multiple records
i have table a and table b
common col in both the tables is emp_id
in table b i have district_id
which i want to update in table a.... column district_id for all the employees
how to write update statement for this
Edited by: user10873676 on Oct 17, 2011 8:00 AMBased on your current description, we have something like this...
SQL> create table a (emp_id number)
2 /
Table created.
SQL>
SQL> create table b (emp_id number, district_id number)
2 /
Table created.
SQL>
SQL> insert into a (emp_id)
2 select rownum from dual connect by rownum <= 10
3 /
10 rows created.
SQL>
SQL> insert into b (emp_id, district_id)
2 select rownum, 10-rownum from dual connect by rownum <= 10
3 /
10 rows created.
SQL>
SQL> update b
2 set district_id = 1
3 /
10 rows updated.
SQL>
SQL> select * from a;
EMP_ID
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> select * from b;
EMP_ID DISTRICT_ID
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
10 rows selected.Which I'm sure is NOT what you want as the update on table b has nothing to do with table a, and we have no idea what the district_id should be updated with. -
How can I make a detailed form widget into TWO columns?
how can I make a detailed form widget into TWO columns? I have a contact form with a lot of fields.
Hi Whatsmyjam9999,
You can place a blank composition widget then click tigger 1, click inside target 1 and from menu--> files--> place the image and adjust it's dimensions, you can repeat the same steps for trigger 2 and 3
Here is a video link http://ghai2.worldsecuresystems.com/jing/2013-07-22_1442.swf -
SQL*Loader-930: Error parsing insert statement for column
we upload data on daily basis in application throug apps user and these table are invloved
1. DEV_RA_INTERFACE_LINES_ALL(owner is a apps)
2.RA_INTERFACE_LINES_ALL(owner is a AR)
we do steps
1 delete record from DEV_RA_INTERFACE_LINES_ALL table
2 delete record from RA_INTERFACE_LINES_ALL table
3 load data using sql loader with apps user
4 insert in RA_INTERFACE_LINES_ALL table
we want to change user i mean these step do dataupload user not apps
we give the proper rights to dataupload like select,delete and insert rights on these table to dataupload user but when i going to load data throug sql loader we receive error
SQL*Loader-930: Error parsing insert statement for column APPS.DEV_RA_INTERFACE_
LINES_ALL.ORIG_SYSTEM_BILL_ADDRESS_ID.
ORA-00904: "F_ORIG_SYSTEM_BILL_ADDR_REF": invalid identifier
and if i insert data through apps then done.make sure that u have no speces left
between lines.
give the path of control file path correctly. -
Update statement for object table.
Hi,
I have created one type as
Create type test as object(
ins_by varchar2(30),
ins_on date,
upd_by varchar2( 30),
upd_on date);
and then created an object table as
create table imst(
i_code number(5),
i_desc varchar2(35),
i_op test);
now i am able to insert record in this table as
insert into imst values(1,'Hawkins cooker',test(user,sysdate,'',''));
Above works fine.
But I would also like to update the record with i_op.upd_by,i_op.upd_on with some other values.
Can any body help me specifying how to write a plain update statement for the same.
Regards.
SoumenCheck it out:
SQL> Create type myTest as object(
2 ins_by varchar2(30),
3 ins_on date,
4 upd_by varchar2( 30),
5 upd_on date);
6 /
Type created.
SQL> create table imst(
2 i_code number(5),
3 i_desc varchar2(35),
4 i_op myTest);
Table created.
SQL> insert into imst values(1,'Hawkins cooker', mytest(user,sysdate,'',''));
1 row created.
SQL> select * from imst;
I_CODE I_DESC
I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
1 Hawkins cooker
MYTEST('APC_LOAD', '12-JUL-04', NULL, NULL)
SQL> update imst i set i.i_op.upd_by = USER, i.i_op.upd_on = add_months(sysdate, 1);
1 row updated.
SQL> select * from imst;
I_CODE I_DESC
I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
1 Hawkins cooker
MYTEST('APC_LOAD', '12-JUL-04', 'APC_LOAD', '12-AUG-04')
SQL> Smoke me a kipper I'll be back before breakfast.
Cheers, APC -
Update stats for table in dbstatc
Hello all,
I am very new to administrating SAP on Oracle. My question is. There are some tables in dbstatc with ignore flag. I ran the below query to get that...
select COUNT(*) from sapsr3.dbstatc
where ACTIV = 'I';
Now from my understanding the I flag means...do not update stats for that table...
So i first ran below...which runs the full stats and it did not update or touched those table in dbstats with I flag
brconnect -c -u / -f stats -t all -f collect -p 8
so after researching i found we can update those stats with below .... even after running the below, stats still do not show up as update.... how can i update (forcefully if required) to update stats for a particular table....
brconnect -u / -c -f stats -t SAPSR3.table_name -f allsel -p 4
i query dba_tables at DB level to see if that specific table was analyzed or not. I am on 11.2 oracle version...and this is a BW SAP system....New User:
1) Which objects do you have the INACTIVE flag set for:
col dbobj format a20
select dbobj, activ from sapsr3.dbstatc where activ = 'I' order by 1;
2) Check that you have the correct DBSTATC settings per SAP Note 403704.
If you do not, then I would suggest you update the DBSTATC table following SAP Note 403704, but before you do take a copy of the dbstatc table:
sqlplus sapsr3/<pass.
create table dbstatc_old as select * from dbstatc;
3) To check to see if you have stats on a table:
select table_name, partitioned, last_analyzed, num_rows from dba_tables where table_name = 'TBTCO';
TABLE_NAME PAR LAST_ANALYZED NUM_ROWS
TBTCO NO 19-MAY-11 163030
If the LAST_ANALYZED shows up with NO values, then there are NO stats on the table.
HOWEVER, be careful for partitioned tables in BW because there are stats at the partition level as well:
select TABLE_NAME, PARTITION_NAME, LAST_ANALYZED, NUM_ROWS from dba_tab_partitions where table_name = '<table>';
4) To collect the statistics on a table
brconnect -c -u / -f stats -t <TABLE> -f allsel,collect -g 4 -p 16
5) If the stats are still not collected with the brconnect command, it may be because the stats are locked at the table level from SAP Note 1020260:
SELECT stattype_locked FROM dba_tab_statistics WHERE table_name = '<TABLE>';
If the value is ALL, then the stats may be locked at the table level and may require to unlock the stats before updating.
Good Luck,
Mike Kennedy -
Nsert/Update and Add Column at the same Table and at the "same" Time
Hello,
I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
Example:
At first the "insert/update" statement:
Insert into TestTable (Testid,Value) values (1,5105);
After that the "add" statement:
Alter table TestTable add TestColumn number;
- sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
"insert/update" statement:
Insert into TestTable (Testid,Value) values (2,1135);
After that the execute commit.
I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
Thanks for ideasWell I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
Cheers, APC -
I have iphone 4s and i updated it for iso 6 , the icon passbook its not working what shall i do, please note that i live in united arab emirates
Hae you tried to do a hard reset of your phone? This will not lose any data. Hold the sleep/wake button and the home button until the phone turns off ignoring any slide to power off messages. Then power the phone back on.
-
Hi Guys,
I have a With CTE table expression ,this cte gets the value from startdate and enddate
I need to insert this startdate and enddate into a table ,while inserting into table,i got the below error,
Derived table 'Datematrix' is not updatable because a column of the derived table is derived or constant.
below is the query i used,
declare @StartDate date='01/01/2013'
declare @EndDate date='12/31/2013'
;WITH Datematrix(AllocationDate)
As
SELECT @StartDate AS AllocationDate
UNION ALL
SELECT DATEADD(D,1,AllocationDate) AS AllocationDate
FROM Datematrix WHERE AllocationDate<@EndDate
Insert into Datematrix(AllocationDate)
select * from Datematrix
any guys update this solution.
Thanks
Bhupesh.R;WITH Datematrix(AllocationDate)
As
SELECT @StartDate AS AllocationDate
UNION ALL
SELECT DATEADD(D,1,AllocationDate) AS AllocationDate
FROM Datematrix WHERE AllocationDate<@EndDate
Insert into Datematrix(AllocationDate)
select * from Datematrix
Hello,
Your CTE bases only on fix value = @StartDate , not on a table/view; here do you want to insert data to? This don't work in any way.
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Convert a SQL Server Update Statement for Oracle
Hi,
i need to convert an update statement written for SQL Server to make it work on Oracle,
the update is the following:
UPDATE TABLE1
SET CDate = TBL2.CDate
FROM TABLE1 TBL1
JOIN TABLE2 TBL2 ON TBL2.Code = TBL1.TBL2Code
JOIN TABLE3 TBL3 ON TBL3.Id = TBL1.Id
WHERE TBL3.TypeCode = '07'
how can i make it compatible with oracle?
thanks!!Billy Verreynne wrote:
Karthick_Arp wrote:
Try this
<snipped>Dislike such an approach that requires multiple hits on the same tables. This is never scalable. A key performance issue is to do only one pass through a data set when possible and not do multiple passes.Yes i understand. But to do a update on a join the table must be a Key Preserved Table. And for a normal Update it is necessory to have an EXISTS clause so that we dont update the non-matching rows to NULL. -
How to tune the Update statement for 20 million rows
Hi,
I want to update 20 million rows of a table. I wrote the PL/SQL code like this:
DECLARE
v1
v2
cursor C1 is
select ....
BEGIN
Open C1;
loop
fetch C1 bulk collect into v1,v2 LIMIT 1000
exit when C1%NOTFOUND;
forall i in v1.first..v1.last
update /*+INDEX(tab indx)*/....
end loop;
commit;
close C1;
END;
The above code took 24 mins to update 100k records, so for around 20 million records it will take 4800 mins (80 hrs).
How can I tune the code further ? Will a simple Update statement, instead of PL/SQL make the update faster ?
Will adding few more hints help ?
Thanks for your suggestions.
Regards,
Yogini JoshiHello
You have implemented this update in the slowest possible way. Cursor FOR loops should be absolute last resort. If you post the SQL in your cursor there is a very good chance we can re-code it to be a single update statement with a subquery which will be the fastest possible way to run this. Please remember to use the {noformat}{noformat} tags before and after your code so the formatting is preserved.
David -
Need a simple UPDATE statement for updating areas of the polygons
Hi,
I need a simple UPDATE SQL statement for updating areas of the polygons in a table shema.table (geom) with sdo_area function.
DejanDejan,
Maybe I don't understand your question but I will offer this:
update SOME_TABLE t set t.areasqft = SDO_GEOM.SDO_AREA(GEOM, 0.005) where t.geom.GET_GTYPE() = 3
This assumes a "feet" based SRID.
r,
dennis
Edited by: user633187 on Dec 1, 2008 9:04 AM -
Update statement for modifying day of the month
Hi,
i hope there is an easy answer to a question i'm probably over thinking. i have a situation where i need to update all the days in a date field to a certain day of the month regardless of the month or year. Here is an example of a small number of dates in the table:
07/28/2004
04/21/2008
12/21/2011
08/21/2006
04/04/2008
04/16/2012
08/13/2011
03/01/2006
04/17/2012
So, for each of these dates the day (or DD) would need to be converted to the 15th (ie. 07/15/2004, 04/15/2008, 12/15/2011, etc). I've used to_char to pull out just the DD, but am unsure what the update statement would need to look like. Any assistance would be greatly appreciated. Thank you!If you don't care about the time component
UPDATE your_table
SET your_column = trunc(your_column,'MM') + 14Justin
Edited by: Justin Cave on Apr 26, 2012 9:47 PM
Off by 1. Should be +14 not +15 -
Regarding hr forms of time statement for displaying in the ESS
hi experts,
i m trying to activate the hr-form name 'sap_tim_99_0001' by going through the tc-hrforms,but it is giving this error plz help me to sort out this probkem,
Generated print program contains a syntax error
Message no. HRFORMS011
Diagnosis
Generated print program /1PYXXFO/SAP_TIM_99_0001_PRNT contains a syntax error in line 144 of include /1PYXXFO/SAP_TIM_99_0001_PRNT.Hi Rajat,
I am facing same problem could please explain in details how u have solve this problem
Thanks in advance -
How can I assgin a master feild value in combobox bind variable in the detail
Hi All,
I'm working on a MD-Form in portal.
I want to pass a master block value in the dynamic combobox where clause.
Combo box is in the detail Block. Can anyone please give a solution for this?
This a very urgent Requirement for me. I really appreciate.
Thanks
MuraliDoes this help?
Dreamweaver Dynamic Master List with link to Detail - YouTube
Maybe you are looking for
-
Satellite U400-183 - Need Recovery DVD and AHCI drivers
Hi there, I tried to reinstall Win Vista Home Premium to my Satellite U400-183. I used a Win OS DVD that came with my other Notebook from an other manufacture and the Key which came with my Toshiba notebook. Everything worked just fine but in certain
-
Itunes wont open, windows error message
i click itunes and i get the windows error message i DONT have norton i used msconfig and disabled everything except windows and it still will not open i tried to unistall and reinstall, same problem can someone link me to a clean uninstall with itun
-
Conversion of String to Bytes and Length Calculation
hi, How can I convert String to Bytes Bytes to String int to Bytes Bytes to int & int to String And I have to calculate the Length in Bytes of a String and int. Thanks
-
My IPod was stolen, how do I retrieve it?
My IPod was stolen, how do I go about finding it and getting it back?
-
How do I get into my iCloud mail on someone else's PC
I have to access a boarding pass soming to my email tomorrow and I will be away from my laptop at someone else's office all day - need to print it at their office, filled with PCs, and don't know how to get iCloud.com mail on the web. Can someone p