Updating tables based on Dates
In my application I use some tables with a date field.
table: employee
period date (e.g. 01-01-2004, 01-02-204, 01-03-2004)
target money
result money
table: project
date date (e.g. 15-01-2004, 20-01-2004, 03-02-2004)
revenue money
If I book a new project the table employee should be updated with result = result + revenue. If there is a new project on 15-01-2004 the record in employee where period = 01-01-2004 should be updated.
Can someone help me with a sample code for this problem?
Assuming you have a block in the form call PROJ with fields DATE, REVENUE and EMP_NO. Also that a record exists for the employee and period date.
Create PRE-INSERT and PRE-UPDATE triggers on the block PROJ containing
begin
update employee
set result=result+:PROJ.REVENUE
where period_date=trunc(:PROJ.DATE,'Mon')
and emp_no=:PROJ.EMP_NO;
end
Similar Messages
-
How to fill setup table based on date???
Hi Experts,
I need to do repair full request for 2lis_11_vaitm datasource, I want to load from 1st Apr 2008 to 31st March 2009, but in OLI7BW t-code i am unable to find date field in selection screen.
1) How can I fill setup table based on date?
2) In RSA7 containing records even though is it possible to fill setup table ?
Helpful answer will be appreciated with points,
Thanks in advance,
Venakt.Venkata,
1) How can I fill setup table based on date?
--> If date not possible then try to setup with available options/characteristics.
--> While pulling into BW, extract data selectively. Give date selection at infopcakge.
2) In RSA7 containing records even though is it possible to fill setup table ?
--> Yes, you can do it.
Srini -
Error updating tables based on schema
Hello,
I'm trying to update a table based on the next schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="HILO" xdb:SQLType="HILO_TYPE" xdb:defaultTable="HILO_TABLE">
<xs:complexType>
<xs:sequence>
<xs:element name="MENSAJE" maxOccurs="unbounded" xdb:SQLType="MENSAJE_TYPE" xdb:maintainOrder="false">
<xs:complexType>
<xs:sequence>
<xs:element name="FECHA" type="xs:date" xdb:SQLType="DATE"/>
<xs:element name="TITULO" xdb:SQLType="VARCHAR2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CUERPO" type="xs:string" xdb:SQLType="VARCHAR2"/>
<xs:element name="DNI_CREADO_POR" xdb:SQLType="VARCHAR2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="9"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ASIGNATURA" xdb:SQLType="VARCHAR2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="APROBADO" xdb:SQLType="VARCHAR2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="APROBADO"/>
<xs:enumeration value="RECHAZADO"/>
<xs:enumeration value="PENDIENTE"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="NUMERO" type="xs:int" use="required" xdb:SQLType="INTEGER"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="CONTADOR" type="xs:int" use="required" xdb:SQLType="INTEGER"/>
</xs:complexType>
</xs:element>
</xs:schema>
And the update that i'm trying to do is the next one:
UPDATE hilo_table p
SET value(p) =
updatexml(value(p),'/HILO/MENSAJE/CUERPO/text()', 'Edit' )
where existsnode(VALUE(p), 'HILO[@CONTADOR="1"]') = 1;
ERROR en línea 1:
ORA-01732: operación de manipulación de datos no válida en esta vista
I have updated another tables based on schema and it works fine, any idea?OK this is your decision. However If you are building a production system that is important to your orgnanization as the product manager I strongly recommend that you either upgrade to a least 9.2.0.3.0 or discontinue using XML DB technology completely
There are probably somewhere in the order of 500 serious XML DB related bugs fixed between 9.2.0.1.0 and 9.2.0.7.0, all of which have been regarded as serious enough to impossible for a customer to develop or deploy a production system. None of these will EVER be fixed or available as patches for 9.2.0.1.0.
The way in which we store the data on the disc is different in 9.2.0.3.0, and while in theory we migrate the on disc format when you upgrade in practice I know that is has never been tested with any significant amount of data present.
Also you really want to take the support situation into account. Image this, it's 3:00am in the morning and your production system fails due one of the bugs that have been fixed in a later release of the product. You cannot find a workaround and you call oracle support for help. They WILL say, sorry there is nothing we can do until you upgrade to 9.2.0.3.0. Now you have to upgrade in hurry and then re-test everything you have done before you can even start working on a fix.
From a business perspective staying on 9.2.0.1.0 and continuing to use the XML DB technology makes no sense. I hope I have made this clear. If you want I will be more than happy to discuss this issue with your development managers. -
Update table based on ID reference comparing each column and value
Hi,
Through UI user can update any information and click save. In backend i will be receiving only ID as reference . Based on the ID value i should update multiple tables wherever i have the reference tables. Here i will not get the values or column name updated.
I just get a ID to find which row is updated.
I should do a comparision now.
I have a history table where i get the row before updation. and i get a row after updation from current data i.e. from ssdb_Railroad[This will be updated by java after updation we will get the ID inorder to update remaining tables]. Now i need to compare
both the table column values and know which column is updated and after getting the value i should update reference tables.
Below is the structure for comparision table , History table and Main table.
Create table Comparision_History (
ID int IDENTITY(1,1) PRIMARY KEY,
InsertUser_UpdateUser varchar(50),
Old_ColVal varchar(100),
New_ColVal varchar(100),
TableName varchar(100),
[Action] varchar(50),
InsertDate_UpdateDate Datetime NOT NULL DEFAULT getdate()
CREATE TABLE SSDB_Railroad_History (
ID int IDENTITY PRIMARY KEY,
SCAC varchar(4) ,
Name varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
varchar(50),
NOTES varchar(1000),
[Action] varchar(50),
InsertDate_UpdateDate Datetime NOT NULL DEFAULT getdate(),
InsertUser_UpdateUser varchar(50),
CREATE TABLE SSDB_Railroad (
ID int IDENTITY(1,1)PRIMARY KEY,
SCAC varchar(4) UNIQUE,
Name varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
varchar(50),
InsertDate Datetime NOT NULL DEFAULT getdate(),
UpdateDate Datetime,
InsertUser varchar(50),
UpdateUser varchar(50)
Here SSDB_Railroad table and History table needs to be compared and get a updated value and it should be inserted in a comparision table. as well as it should be updated in reference tables.
Please help me with the code.
Thanks in Advance
DeepaHi Deepa_Deepu,
According to your description, personally, the merge function can meet your requirements. Usually, we can synchronize two tables by updating or inserting rows in a target table based on differences found in the source tables. Just as your description, when
the value of ID and InsertDate_UpdateDate in the source table matches a value, update them in the target table. When the values does not match, the source row is inserted into the target table.
For more information, see: using MERGE to perform UPDATE and INSERT operations on a target table by using a derived source table.
http://msdn.microsoft.com/zh-cn/library/bb510625.aspx
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
Need to fetch value from a table based on data range
Hello there,
I was hoping that the community could give me a hand with this little puzzle I got.
I am currently creating a Time Dimension for a data wharehouse, and I have the requirement to populate a column named SEASON (e.g: Summer, Winter, Spring, Autumn) for each date row. So for the 20/Dec/2013, the Season column must say Winter.
Here is now my Time Dimension table looks like, without the Season information (which I yet have to load):
DimTime Table
TIMEID
FULLDATE
YEAR
SEASON
MONTH
MONTHDAY
WEEK
WEEKDAY
274
02-MAR-10
2010
3
2
9
2
275
03-MAR-10
2010
3
3
9
3
276
04-MAR-10
2010
3
4
9
4
277
05-MAR-10
2010
3
5
9
5
278
06-MAR-10
2010
3
6
9
6
279
07-MAR-10
2010
3
7
9
7
This entire table is being populated using Oracle functions to manipulate a date field from another table, named PDATE:
My ETL Code
INSERT INTO DimTime(timeid, fulldate, year, month, monthday, week, weekday)
SELECT tim_seq.NEXTVAL, pdate, year, month, monthday, week, weekday
FROM (SELECT DISTINCT pdate, EXTRACT(year from pdate) year, EXTRACT(month from pdate) month,
EXTRACT(day FROM pdate) monthday, to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
TO_CHAR(pdate, 'D') weekday
FROM Performance PER
ORDER BY pdate);
NOTE: Code considers the table DimTime to be truncated every time it loads (i.e.: I don't need to consider additional loads).
As you can see, Season wasn't populated. Since the solstices and equinoxes vary for each year, I can't just say that Summer start at a given date (e.g: 21 of June) because one year it could be the 19/Jun, another the 22/Jun, etc. So in order to solve this problem, I have a table named Season which defines the START and END dates for the seasons:
Season Table
SEASON#
SEASONNAME
YEAR
DATEFROM
DATETO
1
Spring
2010
01-MAR-10
30-MAY-10
2
Summer
2010
31-MAY-10
29-AUG-10
3
Autumn
2010
30-AUG-10
28-NOV-10
4
Winter
2010
29-NOV-10
27-FEB-11
5
Spring
2011
28-FEB-11
29-MAY-11
6
Summer
2011
30-MAY-11
28-AUG-11
7
Autumn
2011
29-AUG-11
27-NOV-11
8
Winter
2011
28-NOV-11
26-FEB-12
9
Winter
2009
30-NOV-09
28-FEB-10
This is the bit I don't know how to do. How can I make sure that I populate the correct Season in my DimTime table based on the season specified in the Season table?
Thanks in advance for your help!
Regards,
P.Just join to table Season:
INSERT
INTO DimTime(
timeid,
fulldate,
year,
month,
monthday,
week,
weekday,
seasonname
SELECT tim_seq.NEXTVAL,
pdate,
year,
month,
monthday,
week,
weekday
FROM (
SELECT DISTINCT pdate,
EXTRACT(year from pdate) year,
EXTRACT(month from pdate) month,
EXTRACT(day FROM pdate) monthday,
to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
TO_CHAR(pdate,'D') weekday,
seasonname
FROM Performance PER,
season
WHERE pdate between datefrom and dateto
SY. -
To select from database table based on date range
hi
i have a selection screen in which date range is being given
say eg 23/06/07 to 23/12/08
based on this date i want to select data from a ztable
eg i want to select a field amount from table
and three is a field date range on the table
for this particular field i want to select all records for amount field and factual field falling wiithing this date range and sum it
eg
based on date range as in selcetion screen
select amount( field1) factual ( field2) from ztable into it_ztable where date = ?....
please give me code for it and how to sum all values as i will get from the ztable into internal table the two values as fetched from the ztable
please suggest asap
regards
arorahi
i am using
sELECT field1 field2 FROM Ztable INto it_matu
where DATE GE sl_dat-low
AND DATE LE sl_dat-high.
i am getting data in internal table but
say i have twelve records now i want to sum it the both the columns into and use that sum final amount to display
let me know how to use sume in the intrranal tabl do i need to use control statement
how to use the sum for two columns and take into a serperate variable to display
regards
aRora -
Update table based on collection
Hello friends,
I have two tables:
1- PHOTOS (img_id number (5,0),Product_id number (5,0), Content Blob ....)
2- PRODUCTS (Product_id number (5,0), product_type .... )
each product has 1 to 6 images.
I need to watermark the uploaded images in the memory then update the original images for the watermarked images.
I used this code, but the problem is how to update the images in the photos table based on the product_id ???
DECLARE
type source_col is table of blob index by pls_integer ;
V_source source_col;
cursor c1 is select CONTENT from photos where Product_id = :P22_Product_id;
counter number :=1;
added_image BLOB;
prop ordsys.ord_str_list;
logging VARCHAR2(2000);
begin
--- Here we choose a pattern for watermarking from a table called WATERMARK_PHOTOS
select img INTO added_image FROM WATERMARK_PHOTOS WHERE N = 1;
for rec in c1 loop
V_source(counter) := rec.CONTENT;
ORDSYS.ORDImage.process(V_source(counter), 'fixedScale=900 500');
ORDSYS.ORDImage.applyWatermark(V_source(counter), added_image, V_source(counter), logging, prop);
--- The problem in the following statement: How to update the images
UPDATE photos SET CONTENT = V_source(counter) where Product_id = :P22_Product_id;
Counter := counter + 1 ;
end loop;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;Thanks Sybrand,
I am using Oracle 11g R2 Standard One edition.
the DDL of the photos table is
ID NUMBER 5 0
product_id NUMBER 5 0
FILENAME VARCHAR2 100
MIMTYPE VARCHAR2 250
FILESIZE VARCHAR2 20
CONTENT BLOB in my application I do not know the image id in advance, but i know the id of the product of which I want to edit the images. So:
in the following procedure :p22_product_id is the value of of the primary key of Products table.
I followed your tips, and it worked out. Can you please check and assure that it is OK :
DECLARE
type source_col is table of blob index by pls_integer ;
V_source source_col;
type id_col is table of number index by pls_integer ;
V_id id_col;
added_image BLOB;
prop ordsys.ord_str_list;
logging VARCHAR2(2000);
begin
select content bulk collect into V_source from photos where product_id = :p22_product_id order by id ;
select id bulk collect into V_id from photos where product_id = :p22_product_id order by id ;
SELECT img INTO added_image FROM timg WHERE N = 1;
for i in V_source.first .. V_source.last
loop
ORDSYS.ORDImage.process(V_source(i), 'fixedScale=900 500');
ORDSYS.ORDImage.applyWatermark(V_source(i), added_image, V_source(i), logging, prop);
UPDATE photos SET CONTENT = V_source(i) where id = V_id(i);
end loop;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;Best Regards,
Fateh -
Update table based on values from other table
Hi,
I am trying to update one table based on the values of another table. Since you can't use From in update statements, how do you execute this?
For example i have to tables, Table A and Table B. I want to update a column or columns in Table A based on another value in Table B:
So if the column in Table B was 1 then column in Table A would be Yes, if Table B was 2, then Table A would be Yes, if Table B was 3 then Table A would be N/A and so on...
Any help would be appreciated.
thanks,
scottSQL> select * from t1;
ID ST
1
2
3
SQL> select * from t2;
NO
1
2
3
4
SQL> update t1 set status=(select decode(no,1,'Y',2,'N','NA') from t2 where t1.id=t2.no);
3 rows updated.
SQL> select * from t1;
ID ST
1 Y
2 N
3 NA
Daljit Singh -
Hi,
I have to update Table by reading Xml data.
I have written a procedure which is given below.
PROCEDURE Sp_Set_File_Permission
p_i_v_xml_data IN VARCHAR2,
Cur_Out_Col_Nm OUT Typ_Icon_Out
IS
XmlDataset XMLTYPE;
BEGIN
/* This is my xml
<xmldata>
<newdataset>
<fileid>99</fileid>
<add>TRUE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
<newdataset>
<fileid>100</fileid>
<add>FALSE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
</xmldata>*/
xmldataset := Xmltype.Createxml(p_i_v_Xml_Data);
--error occured on this line while executing procedure
FOR i IN (SELECT
Dt.Extract('//newdataset/fileid/text()').Getstringval() AS Fileid,
Dt.Extract('//newdataset/add/text()').Getstringval() AS Add,
Dt.Extract('//newdataset/edit/text()').Getstringval() AS Edit,
Dt.Extract('//newdataset/del/text()').Getstringval() AS d,
Dt.Extract('//newdataset/ex/text()').Getstringval() AS e,
Dt.Extract('//newdataset/im/text()').Getstringval() AS I
FROM TABLE(Xmlsequence( xmldataset.Extract('//xmldata/newdataset'))) Dt)
LOOP
UPDATE t_object_master
SET add_view=i.Add
,edit_view=i.Edit,
delete_view=i.D,
export_view=i.E,
import_view=i.I
WHERE objct_id=i.Fileid;
COMMIT;
END LOOP;
END Sp_Set_File_Permission;
When I am trying to exceute this procedure with the above mentioned xml ,getting error ORA-00923 ,FROM keyword not found where expected.
Please help me out in this.
Thanks,Something like this (no commit inside loop, no row per row)
create table t_object_master as
with myxml as (
select xmltype(
'<xmldata>
<newdataset>
<fileid>99</fileid>
<add>TRUE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
<newdataset>
<fileid>100</fileid>
<add>FALSE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
</xmldata>') doc from dual
select
fileid
,add_view
from
myxml
,xmltable('//newdataset'
passing myxml.doc
columns
Fileid number path 'fileid'
,add_view varchar2(5) path 'add'
table created
select
from t_object_master
FILEID
ADD_VIEW
99
TRUE
100
FALSE
update t_object_master t
set add_view = (
with myxml as (
select xmltype(
'<xmldata>
<newdataset>
<fileid>99</fileid>
<add>FALSE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
<newdataset>
<fileid>100</fileid>
<add>TRUE</add>
<edit>TRUE</edit>
<del>FALSE</del>
<ex>FALSE</ex>
<im>TRUE</im>
</newdataset>
</xmldata>') doc from dual
, myextract as (
select
fileid
,add_view
from
myxml
,xmltable('//newdataset'
passing myxml.doc
columns
Fileid number path 'fileid'
,add_view varchar2(5) path 'add'
select
add_view
from myextract
where
fileid = t.fileid
select *
from t_object_master
FILEID
ADD_VIEW
99
FALSE
100
TRUE -
How to select data in setup tables based on date
hello gurus,
I have a question . I want to fill the setup tables but not complete historical data. I need to fill it based on some date selection.Can anyone help me the process. I went to oli9bw but i cannot see any option like date range for data selection...... i.e., I need to extract a subset of data from ecc to bw.
Thanks a lotHi Sandeep,
While filling Setup tables we won't have any selection(It loads all historical data), when you run the IP to load data to BW.follow the below 2 cases.
1)If you require further delta loads on this, run the full load based on your date selections.then create another IP for delta,run "init without data transfer" as option in Update tab of IP.
2)If you don't require any delta further, simply run Full load with date selections.
Hope this helps.
Regards,
Venkatesh. -
Updating Table using the data from a flat file
Hi,
I have a table called emp;
Name,
empno,
accountno,
amount.
This table is filled with values of name and empno.
The columns accountno and amount are empty.
I have a flat file created in some folder.
Contents of the flat file can be like this:
mani | 23 | 123 | 1000
spr | 22 | 342 | 2133
asjf | 54 | 432 | 2345
I need to access the file in the specified location, read all the records one after the other in the flat file and update the table "emp" with the values in the flat file.
Row after row all the records in the file should be updated to the table.
I found out some way to do this - its sqlloader - But it loads the data from a file to the table - i dont need that - i need to update the table.
Let me know how this can be solved ?????????
Thanks in advance.......Just to clarify Andrew's point, you can use external tables as the source table for an UPDATE statement. You cannot use them as a target for an UPDATE statement (i.e. you can't update the text file from an Oracle table).
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Update table based on a select with a where clause
I am trying to update a table only for records where i have a status of changed.
Using the following code the update changes all the records putting in blank data if it is outwith the where clause.
ideas?
-- Update changed records
UPDATE IP_SURVEY_ACTIVITY_REG_NO old
SET (
old.SLPN,
old.SURVEY_DATE,
old.SEQUENTIAL_REF_NUMBER,
old.TOTAL_NUM_OF_SAMPLES,
old.TOTAL_NUM_OF_ASSOC_SAMPLES,
old.AIR_TESTS,
old.REMARKS,
old.SURVEY_DETAILS,
old.FURTHER_SURVEY_DETAILS,
old.GENERAL_COMMENTS) =
(SELECT
new.SLPN,
new.SURVEY_DATE,
new.SEQUENTIAL_REF_NUMBER,
new.TOTAL_NUM_OF_SAMPLES,
new.TOTAL_NUM_OF_ASSOC_SAMPLES,
new.AIR_TESTS,
new.REMARKS,
new.SURVEY_DETAILS,
new.FURTHER_SURVEY_DETAILS,
new.GENERAL_COMMENTS
FROM IP_SURVEY_ACTIVITY_REG_NO_INT new
WHERE new.load_id = v_load_id
AND new.status = 'CHANGED'
AND new.sarn = old.sarn);
cheers bjornThe EXISTS claue just needs to be added to your original query as a predicate on the ip_survey_activity_reg_no table. somethign like:
UPDATE ip_survey_activity_reg_no old
SET (old.slpn, old.survey_date, old.sequential_ref_number,
old.total_num_of_samples, old.total_num_of_assoc_samples,
old.air_tests, old.remarks, old.survey_details,
old.further_survey_details, old.general_comments) =
(SELECT new.slpn, new.survey_date,
new.sequential_ref_number,
new.total_num_of_samples,
new.total_num_of_assoc_samples, new.air_tests,
new.remarks, new.survey_details,
new.further_survey_details,new.general_comments
FROM ip_survey_activity_reg_no_int new
WHERE new.load_id = v_load_id and
new.status = 'CHANGED' and
new.sarn = old.sarn)
WHERE EXISTS (SELECT 1 FROM ip_survey_activity_reg_no_int new
WHERE new.load_id = v_load_id and
new.status = 'CHANGED' and
new.sarn = old.sarn)An updateable join view is similar, except you just join the two tables. Assuming that sarn is the primary key of ip_survey_activity_reg_no_int, or is at least declared as unique in that table, then the update of the join would look something like:
UPDATE (SELECT old.slpn oslpn, old.survey_date osurvey_date,
old.sequential_ref_number osequential_ref_number,
old.total_num_of_samples ototal_num_of_samples,
old.total_num_of_assoc_samples ototal_num_of_assoc_samples,
old.air_tests oair_tests, old.remarks oremarks,
old.survey_details osurvey_details,
old.further_survey_details ofurther_survey_details,
old.general_comments ogeneral_comments,
new.slpn nslpn, new.survey_date nsurvey_date,
new.sequential_ref_number nsequential_ref_number,
new.total_num_of_samples ntotal_num_of_samples,
new.total_num_of_assoc_samples ntotal_num_of_assoc_samples,
new.air_tests nair_tests, new.remarks nremarks,
new.survey_details nsurvey_details,
new.further_survey_details nfurther_survey_details,
new.general_comments ngeneral_comments
FROM ip_survey_activity_reg_no old, ip_survey_activity_reg_no_int new
WHERE new.sarn = old.sarn and
new.status = 'CHANGED' and
new.load_id = v_load_id)
SET oslpn = nslpn,
osurvey_date = nsurvey_date,
osequential_ref_number = nsequential_ref_number,
ototal_num_of_samples = ntotal_num_of_samples,
ototal_num_of_assoc_samples = ntotal_num_of_assoc_samples,
oair_tests = nair_tests,
oremarks = nremarks,
osurvey_details = nsurvey_details,
ofurther_survey_details = nfurther_survey_details,
ogeneral_comments = ngeneral_commentsHTH
John
Message was edited by:
John Spencer
Honest, Eric wasn't there when I posted :-) -
ABAP Webdynpro - Populating second table based on data selected on first
Hi Experts,
I am new to ABAP Webdynpro. I have a requirement to show a search area, one table for header info, and second table for populating item level information.
I was successful building a search area and populating first table when the 'Search' button is pressed.
Now, I like to populate the second table with item details if a row on first table is selected. I tried to bind the OnSelect Event of first table to a method and try to get the results and bind to second table.. However, I am unsuccessful in this attempt.
Here are my questions/challenges.
1. When I select a row on first table, how can I extract the key information?
2. Is it sufficient to create a context attribute and populate it with FM and bind that with second table?
I appreciate your help in answering this question.
Thanks,
SGHi,
Regarding...
1. When I select a row on first table, how can I extract the key information?
When you select any row in table, a lead selection will be set in the node which bound to the table.
To read this selected record you need to use the following code. Here the name of context node is "FLAGS". And the structure ls_flags contains all the attributes defined in the node.
DATA lo_nd_flags TYPE REF TO if_wd_context_node.
DATA ls_flags TYPE wd_this->element_flags.
lo_nd_flags = wd_context->get_child_node( name = wd_this->wdctx_flags ).
CALL METHOD lo_nd_flags->get_static_attributes
IMPORTING
static_attributes = ls_flags.
Regarding....
2. Is it sufficient to create a context attribute and populate it with FM and bind that with second table?
Based on the data that you got in the first step, you can fill an internal table with data that needs to be displayed in 2nd table.
To bind the internal table you need to define the internal table of type context node. Use the following code to bind the internal table to context node which bound to 2nd table. Here name of the context node is "OVERVIEW".
DATA: lo_nd_overview TYPE REF TO if_wd_context_node,
lt_overview TYPE wd_this->elements_overview.
<<<< Fill lt_overview with data >>>>>
lo_nd_overview = wd_context->get_child_node( name = wd_this->wdctx_overview ).
CALL METHOD lo_nd_overview->bind_table
EXPORTING
new_items = lt_overview.
Alternatively you can use the Supply Function Method.
Vikrant Trivedi -
Loop through tables based on data dict values
Hi,
I working on an old v7.3.4 database that I'm not familiar with and I want to loop through the tables and count the occurrence of a field value based on table names i've retrieved from the data dictionary. None of the tables have relational keys defined.
In a cursor I can loop thru all_tab_columns and load variables with the table, column names, and the datatype, but then I want to use these values in a second nested cursor to loop through each table found by the first cursor.
When I do :
Select var_colname from var_tabname
i get
The following error has occurred:
ORA-06550: line 23, column 10:
PLS-00356: 'V_TABNAME' must name a table to which the user has access
ORA-06550: line 22, column 5:
PL/SQL: SQL Statement ignored
ORA-06550: line 22, column 12:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 27, column 7:
PL/SQL: SQL Statement ignored
so it would seem I can't use a variable to substitute the table name in the 'from' clause. Does anyone know of a way round this ?
Thanks in advanceHi,
You will have to use dynamic sql to create your second cursor.
DECLARE
v_sql_query VARCHAR2(400);
TYPE cur_typ IS REF CURSOR;
c1 cur_typ;
mYRec MyTable%rowtype;
BEGIN
v_sql_query := 'select * from MyTable';
OPEN c1 FOR v_sql_query;
LOOP
FETCH c1 INTO mYRec;
EXIT WHEN c1%NOTFOUND;
EXIT WHEN c1%NOTFOUND IS NULL;
/*processing here*/
END LOOP;
CLOSE c1;
END;
Regards -
Updating TABLEA based on values in TABLEB
Hi: I have the two following tables. I want to write a query which updates fields in TABLE1 based on certain values in TABLE2
1. Update SEVERITY in TABLE1 with SVRT_CD in TABLE2 for all TABLE1.INCIDENT = TABLE2.TKT_NBR
2. Update ESCALATION in TABLE1 with ESCL_LVL in TABLE2 for all TABLE1.INCIDENT = TABLE2.TKT_NBR
3. If the TABLE2.MNS_STATUS is 5 then set TABLE1.INCIDENTSTATUS='Acls' for all TABLE1.INCIDENT = TABLE2.TKT_NBR
4. If the TABLE2.MNS_STATUS is 4 then set TABLE1.INCIDENTSTATUS='Bctk' for all TABLE1.INCIDENT = TABLE2.TKT_NBR
remedy@MDS> descr TABLE1;
USERID NOT NULL VARCHAR2(32)
INCIDENT NOT NULL VARCHAR2(64)
INCIDENTSTATUS NULL VARCHAR2(16)
SEVERITY NULL NUMBER
ESCALATION NULL NUMBER
ONSTRAINT user_pk PRIMARY KEY (USERID,INCIDENT)
netcool@RMDSP02> describe TABLE2;
TKT_NBR NULL NUMBER(10,0)
ESCL_LVL NULL NUMBER(2,0)
SVRT_CD NULL VARCHAR2(1)
MNS_STATUS NULL NUMBER(1,0)
CONSTRAINT tkt_pk PRIMARY KEY (TKT_NBR)I think this will do what I want in #1 and #2. Can someone confirm?
UPDATE TABLE1
SET (SEVERITY, ESCALATION) = (SELECT SVRT_CD,ESCL_LVL from TABLE2 where to_number(TABLE1.INCIDENT) = TABLE2.TKT_NBR)Not sure how do I do the #3 and #4.
Thanks
RaviFor point 3 and 4 use decode. and dont forget to use EXISTS in your update.
UPDATE table1
SET (severity,
escalation,
incidentstatus) = (SELECT svrt_cd,
escl_lvl,
DECODE(mns_status,5,'Acls',4,'Bctk')
FROM table2
WHERE TO_NUMBER(table1.incident) = TABLE2.TKT_NBR)
WHERE EXISTS (SELECT NULL
FROM table2
WHERE TO_NUMBER(table1.incident) = TABLE2.TKT_NBR) Thanks,
Karthick.
Maybe you are looking for
-
How do I revert back to my original LR
I ran a trial version of Adobe CC and now I can't get back to my original LR 5 version. It will open, but when I go to developer module it says I have to update/purchase the creative cloud version. How can I simply use my original boxed version?
-
Hi Gurus When viewing an Employees details in the Account Details of the WEB UI. In the heade section there is an area call Worked, in this section is a Label "Type" with a Drop Down. What is this field used for and when do I configure the drop down
-
How to create Mail Folders?
Question Does anyone know how to create mail folders for oganizing the inbox? I can't figure it out, but likely, the answer will be "you can't". I'm not using an IMAP mail host, I have a pop account with Yahoo!Mail. Any help is appreciated... Thanks.
-
VIDEO STORAGE AND PLAYER ????
I have a question for you Video Gurus out there. I am collecting a lot of old TV Shows from the internet and storing them on my Mac, and I want a storage device that I can store and play them on when connected to my TV. I can put episodes on a thumb
-
Photoshop CS5 Crashes when saving...please help!
Someone please help...this is driving me crazy. Photoshop randomly crashes when I try to save...specifically I see it happen when I do ctrl+S and it only seems to happen on my first save. If my first save is successful all other saves for that docume