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
arora
hi
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
Similar Messages
-
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. -
Selecting from Multiple Tables but requiring data to match from a 3rd table
Hello Everyone,
I'm having alot of trouble with this select
I have three tables:
prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data:
cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"and I need it to grab all data in those two tables when one column in the prod_poured table meets a certain condition
This is what I have so far:
select cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"
from conc_test inner join cyl_break on conc_test.pour_no = cyl_break.pour_no, prod_poured
where conc_test.pour_no = prod_poured.test_id and prod_poured.job_no = '9-12-821';It gives me the right results but wayyy too many of them so obviously I've got something wrong.
the results it gives are this:
Pour Number Cylinder ID Pour Date Mix # Ambient Temperature Concrete Temperature Air % Break Date Age (Days) Specified Strength Specimen Strength
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6The results I need it to give are this:
100322A 100322A3 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.6
100322A 100322A4 22-MAR-10 10 16 16 4.2 19-APR-10 28 35 50.4
100324A 100324A3 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 51.9
100324A 100324A4 24-MAR-10 10 9 15 5.8 21-APR-10 28 35 50.8
100324E 100324E3 24-MAR-10 10 10 15 6 21-APR-10 28 35 50.7
100324E 100324E4 24-MAR-10 10 10 15 6 21-APR-10 28 35 51.6
100326B 100326B3 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 48.3
100326B 100326B4 26-MAR-10 10 9 15 5.7 23-APR-10 28 35 49As you can see my query provides the right results, just way too many of them. I only need to have one result per cylinder id.
I can't seem to wrap my mind around this one and if somebody could put together a proper select based on what I need that would be extremely helpful. If you need any more data to provide help just ask and I'll paste it.
Thanks,
dtr
Edited by: dtr on Apr 26, 2010 11:12 AMdtr wrote:
Hi,
Here are the create table statements:
create table conc_test
(p_date date, job_no varchar, mix varchar, pour_no varchar, amb_t varchar, conc_t varchar, slump varchar, air varchar, density varchar, cyl_cast_time timestamp)
create table cyl_break
(job_no varchar, pour_no varchar, cyl_id varchar, pour_d varchar, break_d varchar, age varchar, spec_str varchar, str varchar, mix);
create table prod_poured
(prod_id varchar, pour_id varchar, test_id varchar);
Great!
Don't forget to post the INSERT statements, and the output from that data (if it is different from what you posted in your first message).
Basically I need to pull the data I showed above out of conc_test and cyl_break, but only data that has the proper job_number which is retrieved from the prod_poured table. The prod_poured test_id for everything that has the proper prod_poured job_no So an IN-subquery, like Sudhakar and I suggested, should work.
What was the problem when you tried them? Post the query you ran, even if you just copied and pasted it from this thread: there may have be an editing error.
prod_poured test_id is the same thing as conc_test pour_no and cyl_break pour_noExactly! But that doesn't answer the question: Is that value unique in all the tables? If not, in which tables can it be duplicated? -
Select from different tables based on value
Hi Forum,
I'm stuggling with a problem:
In a table, I have two columns, pref_type and pref_value. Column pref_type stores a number value that is linked to a preference type, whereas column pref_value stores the value of that preference.
Unfortunately, the data model is such that per preference type a different tables needs to be used, so for example, if
pref_type = 1, table to query is A, whereas if
pref_type = 2, table to query is B.
I now want to write a query that resolves the preferences, ie it should branch to the respective table based on pref_type and search for pref_value and deliver back a different column of that respective table.
My first approach was like that:
select decode (pref_value, 1, (select result from A where pref_value = ???),
2, (select result from B where pref_value = ???)
where the three ??? depict the problem I'm having, as Oracle doesn't allow me to have a harmonized subquery here.
How do I achieve this?
Thanks for any help,
J. SiebenI believe this is what you are trying to get at:
SELECT DECODE(m.pref_type, 1, (SELECT result FROM a
WHERE a.pref_value = m.pref_value),
2, (SELECT result FROM b
WHERE b.pref_value = m.pref_value)
FROM my_table mAlthough, if the tables are large, that might be pretty slow. Better than an outer join, but one of those correlated queries is going to be run for each row in my_table. You could lso try something like:
SELECT m.pref_type, r.result
FROM my_table m,
(SELECT 'A' tbl, pref_value, result
FROM a
UNION ALL
SELECT 'B', pref_value, result
FROM b) r
WHERE DECODE(m.pref_type, 1, 'A', 'B') = r.tbl and
m.pref_value = r.pref_valueHTH
John -
Select from 4 tables but include data from 3 even if 4th is null
Hello -
I'm quite new to oracle and apex, but enjoying learning - but sometimes I need a gentle nudge to know what I need to learn about.
I have a select statement that works - selecting specific columns from 3 tables:
SELECT
"TERRITORIES"."TER_NAME" "TER_NAME",
"TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
"COUNTRIES"."CNT_DESCRIPTION" "COUNTRY"
FROM
"TERRITORIES", "TERRITORY_TYPES","COUNTRIES"
WHERE
"TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
and
"COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
I want to add in a 4th table for, you guessed it, States.
However, many of the countries do not yet have states in the states table (and may never have any). Therefore, they do not appear in the results. I want them included in the query, so that I'll have the opportunity to add in the data via Apex.
Is there a phrase I can insert in the 1st query so that I'll get data for Territory Type, Territory and Country, even if the State table is null?
Or, do I need to insert records into the state table, such as: insert into states (state_ID, STATE_CNT_ID) values (state_seq.nextval,2). If so, do I just do that over and over, replacing the value? Or is this where I need to learn about bind variables? Or some other command?
Thank you-
Marion in NY
Edited by: mtpaper on Oct 24, 2009 12:54 PM
I FIGURED IT OUT! I DID IT! How do I mark myself as helpful???
insert INTO states
(state_ID, STATE_CNT_ID)
SELECT state_seq.nextval, cnt_id
FROM countries
WHERE not exists (select * from states where states.state_cnt_id = countries.cnt_id)
Edited by: mtpaper on Oct 24, 2009 1:10 PMYou certainly could insert data into the STATES table, but I generally wouldn't advise inserting rows into a STATES table for states that don't actually exist. It would seem to make far more sense to just do an outer join when you include the STATES table in your query
SELECT "TERRITORIES"."TER_NAME" "TER_NAME",
"TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
"COUNTRIES"."CNT_DESCRIPTION" "COUNTRY",
s.state_name
FROM TERRITORIES t ,
TERRITORY_TYPES tt,
COUNTRIES c,
states s
WHERE "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
and "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
and c.cnt_id = s.state_cnt_id(+)The {noformat}(+){noformat} operator indicates that you want to do an outer join. So if there is no row in the STATES table that matches the join condition, a NULL is returned.
From a purely stylistic standpoint, I would generally suggest using aliases (i.e. the T, TT, C, and S in the FROM clause) rather than having to constantly write out all the table names. And I wouldn't suggest putting double-quotes around everything-- that forces all your identifiers to be upper case and case sensitive.
Justin -
Hi Experts,
I have a database table having fields
entity account period category value filename
A 1 001 ABC 100 abc.xls
A 1 002 ABC 200 abc.xls
B 2 001 DEF 300 sef.xls
I now need to update a control table from the database table which will select all the distinct filenames , from the database table .
how to do this
Thanks
AnkitHi,
In the select query write:
select distinct ( filename) from dtab. -
Selection from database tables
Hi Experts,
In one program I'm selecting data from tables <b>VBAK, VBAP,VBRK,VBRP,LIKP,LIPS</b>. As the tables have huge data, it's taking forever to get the data into internal tables.
Could you please suggest me to better the performance.
Thnx much.hi dev,
do not use select .. endselect statement and include all the key fields in your select statement.
instead of select .. endselect statement use
select * from <table> into table itab where < conditions)
Regards,
Santosh
Message was edited by: Santosh Kumar P -
Best way to select from 2 tables, based on sum from detail table
I have a "customer order line detail" table from which I want to report
Order Number
Customer Number
Part Number
Line Value { which is Unit Qty * (Unit price - discount%) }
But only for orders which are above £1500.
And lines which are not "Cancelled"
I have access to an API which returns the total order value for the order.
I am currently using this in my criteria, eg:
select order_no, customer_no, part_no, round(unit_qty *(unit_price - unit_price *(discount/100)),2) Line_value
from customer_detail
where
status != 'Cancelled'
and
Customer_Order_API.Get_Total_Sale_Price__(order_no)>=1500
The API contains the following:
SELECT SUM(ROUND((qty * price_conv_factor * unit_price), rounding_) -
ROUND((qty * price_conv_factor * unit_price) -
((qty * price_conv_factor * unit_price) * ((1 - discount / 100) * (1 - order_discount / 100))), 2))
FROM customer_detail
WHERE order_no = order_no_
AND state != 'Cancelled'
AND line_item_no <= 0
(that uses a price conversion factor that I don't use, since it's always 1)
My query runs so slowly, because it is getting the order value for every line of the order, is it possible to improve?
ThanksThanks for the suggestion, it was close to what I needed.
I ended up with this:
select order_no, name, ref_id, c_salesman_sub_division, line_value, catalog_desc
from
(SELECT coj.customer_no, coj.order_no, ifsapp.customer_info_api.GET_NAME(customer_no) name, coj.ref_id,
coj.c_salesman_sub_division, ROUND((coj.buy_qty_due * coj.
price_conv_factor) * coj.sale_unit_price, 2) - ROUND((coj.buy_qty_due *
coj.price_conv_factor) * coj.sale_unit_price - ((coj.buy_qty_due * coj.
price_conv_factor) * coj.sale_unit_price) * ((1 - coj.discount / 100) *
(1 - coj.order_discount / 100)), 2) line_value, coj.catalog_desc,
SUM( ROUND((coj.buy_qty_due * coj.
price_conv_factor) * coj.sale_unit_price, 2) - ROUND((coj.buy_qty_due *
coj.price_conv_factor) * coj.sale_unit_price - ((coj.buy_qty_due * coj.
price_conv_factor) * coj.sale_unit_price) * ((1 - coj.discount / 100) *
(1 - coj.order_discount / 100)), 2)) OVER (PARTITION BY Coj.ORDER_NO) AS SUM_ORDER
FROM ifsapp.customer_order_join coj
WHERE coj.order_no = coj.order_no
AND TRUNC(coj.date_entered) = NVL(TO_DATE('25/01/2007', 'DD/MM/YYYY'),
TRUNC(SYSDATE))
AND coj.authorize_code = 'UKMEDM'
AND coj.line_item_no >= 0
AND coj.ref_id <> 'SAMP'
AND coj.state <> 'Cancelled'
where sum_order >=1500
ORDER BY ref_id, c_salesman_sub_division, customer_no, order_no
/[pre]
But I have realised the problem with this. Not sure if I made it clear, to myself even, but I need to include
order lines added on a particular day (that are not cancelled)
for orders which total >= £1500.
If one line of an order is added for £900 but the rest of the order is £2000 then that line should be shown.
My SQL only shows lines added for the day >= 1500. -
Deletion of Rec from Database table
Hi,
I need to delete records from database table based on a particular field as below.
DELETE FROM dbtable
WHERE specid = specid .
Can U please help me in the syntax of the code.
I promise to reward.
Thanks & regards.hi
try this
DELETE FROM ZICM_ORD_PRCTRC WHERE VBELN = WA_ZICM_ORD_PRCTRC-VBELN
AND
POSNR = WA_ZICM_ORD_PRCTRC-POSNR.
regards,
muralidhar. -
How to populate a table based on a row selection from another table.
Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
ganeshI understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
"EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
Hope this helps. -
Extract data from database tables and download in pdf and csv
extract data from database tables and download in pdf and csv
hi how can i re-write my old form procedure in adf java. the procedure used to extract data from diffirent table and dowload the data in pdf and csv.am not downloading image, i what to extract data from diffirent tables in my database and download that data in pdf and csv. i would like to write this in java adf.i just what direction am not asking anyone to do my work this is my learning curve
the form code is
function merge_header3 return varchar2 is
begin
return '~FACILITY DESCRIPTION~ACCOUNT NO~BRANCH CODE~BANK REF NO.~P/P/ AMOUNT~Postal Address 1~Postal Address 2~Box Postal Code~Dep. Date~Month~BANK NAME~BRANCH NAME~ACCOUNT TYPE~DESCRIPTION~OBJECTIVE DESCRIPTION';
end;
procedure download_file (i_pbat integer) is
dir varchar2(80);
file_name1 varchar2(80);
file_name2 varchar2(80);
appl_code varchar2(80);
fil1 client_text_io.file_type;
fil2 client_text_io.file_type;
dat varchar2(1000);
DATA VARCHAR2(1000);
bvspro varchar2(100);
ssch varchar2(100);
bvspro_total number(20,2);
ssch_total number(20,2);
grand_total number(20,2);
cnt integer;
cursor pbat is
select *
from sms_payment_batches
where id = i_pbat
cursor pay (pb_id integer) is
select *
from sms_payment_vw
where pbat_id = pb_id
order by subsidy ASC,programme,beneficiary_name
cursor cgref (low varchar2) is
select *
from cg_ref_codes
where rv_domain ='SMS'
and rv_low_value = low
success boolean;
begin
set_application_property(cursor_style,'busy');
appl_code := sms_global.ref_code('SMS','APP_CODE','SMS',0);
dir := sms_global.ref_code('SMS','PAY_DIR','c:\sms\batch_payments',0);
success := webutil_file.create_directory(dir);
if webutil_file.file_is_directory(dir) then
null;
-- message ('directory exists');
else
-- message ('create directory ');
success := webutil_file.create_directory(dir);
-- if success then message ('directory exists'); end if;
end if;
for c_pbat in pbat loop
file_name1 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'pay.txt';
file_name2 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'merge.txt';
--message('create files ');
-- fil1 := client_text_io.fopen (file_name1,'W');
-- fil2 := client_text_io.fopen (file_name2,'W');
fil1 := client_text_io.fopen (file_name1,'W','');
fil2 := client_text_io.fopen (file_name2,'W','');
dat := 'FROM ACCOUNT NUMBER'
||'~'||'FROM ACCOUNT DESCRIPTION'
||'~'||'MY STATEMENT DESCRIPTION'
||'~'||'BENEFICIARY ACCOUNT NUMBER'
||'~'||'BENEFICIARY SUB ACCOUNT NUMBER'
||'~'||'BENEFICIARY BRANCH CODE'
||'~'||'BENEFICIARY NAME'
||'~'||'BENEFICIARY STATEMENT DESCRIPTION'
||'~'||'AMOUNT';
-- client_text_io.put_line(fil1,dat);
bvspro:= null;
ssch := null;
cnt := 0;
dat := '~'||lpad('~',16,'~');
for c_pay in pay(c_pbat.id) loop
--message('cpay loop ' || cnt);
if bvspro is null then
dat := lpad('~',16,'~');
dat := utility.put_field(1,c_pay.programme,dat,'~');
client_text_io.put_line(fil2,dat);
dat := utility.put_field(1,c_pay.subsidy,dat,'~');
client_text_io.put_line(fil2,dat);
dat := merge_header3;
client_text_io.put_line(fil2,dat);
bvspro := c_pay.programme;
ssch := c_pay.subsidy;
grand_total := 0;
bvspro_total := 0;
ssch_total := 0;
end if;
if bvspro <> c_pay.programme then
dat := lpad('~',16,'~');
dat := utility.put_field(5,ssch_total,dat,'~');
dat := lpad('~',16,'~');
dat := utility.put_field(5,bvspro_total,dat,'~');
dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
client_text_io.put_line(fil2,dat);
dat := lpad('~',16,'~');
client_text_io.put_line(fil2,dat);
dat := utility.put_field(1,c_pay.programme,dat,'~');
client_text_io.put_line(fil2,dat);
bvspro := c_pay.programme;
dat := utility.put_field(1,c_pay.subsidy,dat,'~');
client_text_io.put_line(fil2,dat);
dat := merge_header3;
client_text_io.put_line(fil2,dat);
bvspro := c_pay.programme;
ssch := c_pay.subsidy;
bvspro_total := 0;
ssch_total := 0;
cnt :=0;
end if;
if ssch <> c_pay.subsidy then
dat := lpad('~',16,'~');
dat := utility.put_field(5,ssch_total,dat,'~');
dat := lpad('~',16,'~');
client_text_io.put_line(fil2,dat);
dat := utility.put_field(1,c_pay.subsidy,dat,'~');
client_text_io.put_line(fil2,dat);
dat := merge_header3;
client_text_io.put_line(fil2,dat);
ssch := c_pay.subsidy;
ssch_total := 0;
cnt :=0;
end if;
bvspro_total := bvspro_total + c_pay.amount;
ssch_total := ssch_total + c_pay.amount;
grand_total := grand_total + c_pay.amount;
cnt := cnt +1;
--message('bfore write file 2 ' );
client_text_io.put_line(fil2
,cnt
||'~'|| c_pay.beneficiary_name
||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER ||''
||'~'||c_pay.BRANCH_CODE ||''
||'~'|| c_pay.BENEFICIARY_STATEMENT_DESC
||'~'|| c_pay.AMOUNT
||'~'|| c_pay.address_line1
||'~'|| c_pay.address_line2
||'~'|| c_pay.postal_code
||'~'|| TO_CHAR(c_pay.deposit_date,'DD-Mon-YYYY')
||'~'|| c_pay.month
||'~'|| c_pay.bank
||'~'|| c_pay.bank_branch
||'~'|| c_pay.account_type
||'~'|| c_pay.subsidy
||'~'|| c_pay.programme)
DATA := c_pay.FROM_ACCOUNT_NUMBER
||'~'||c_pay.FROM_ACCOUNT_DESCR
||'~'||c_pay.MY_STATEMENT_DESCR
||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER
||'~'
||'~'||c_pay.BRANCH_CODE
||'~'||c_pay.BENEFICIARY_NAME
||'~'||c_pay.BENEFICIARY_STATEMENT_DESC
||'~'||c_pay.AMOUNT;
DATA := REPLACE(DATA, ',' , ' ' );
DATA := REPLACE(DATA, '~' , ',' );
--message (cnt ||' ' || data);
--message('bfore write file 1 ' );
client_text_io.put_line(fil1, data);
end loop;
--message ('end of write');
dat := lpad('~',16,'~');
dat := utility.put_field(6,ssch_total,dat,'~');
dat := lpad('~',16,'~');
dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
dat := utility.put_field(5,bvspro_total,dat,'~');
client_text_io.put_line(fil2,dat);
dat := lpad('~',16,'~');
client_text_io.put_line(fil2,dat);
dat := utility.put_field(1,'Grand Total:' ,dat,'~');
dat := utility.put_field(5,grand_total,dat,'~');
client_text_io.put_line(fil2,dat);
-- close file
for i in 1..50 loop
if substr(i,-1) = 0 then
message ('flush ' || i);
end if;
client_text_io.put_line(fil1, lpad(' ',2000));
client_text_io.put_line(fil2, lpad(' ',2000));
client_text_io.put_line(fil1, lpad(' ',2000));
client_text_io.put_line(fil2, lpad(' ',2000));
end loop;
client_text_io.fclose(fil1);
client_text_io.fclose(fil2);
end loop;
set_application_property(cursor_style,'default');
exception
when others then
message(sqlcode ||' ' ||sqlerrm);
end download_file; i try this but this code onlydownload image not data from database tables
public void downloadImage(FacesContext facesContext, OutputStream outputStream)
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
// get an ADF attributevalue from the ADF page definitions
AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("DocumentImage");
if (attr == null)
return;
// the value is a BlobDomain data type
BlobDomain blob = (BlobDomain) attr.getInputValue();
try
{ // copy the data from the BlobDomain to the output stream
IOUtils.copy(blob.getInputStream(), outputStream);
// cloase the blob to release the recources
blob.closeInputStream();
// flush the output stream
outputStream.flush();
catch (IOException e)
// handle errors
e.printStackTrace();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
FacesContext.getCurrentInstance().addMessage(null, msg);
}You should ask your forum in the ADF-forum.
-
Deletion of bookmarks from RSWR_DATA table based on 'Last access' date
We want to delete the 7.X bookmarks from RSWR_DATA table based on Last accessed date. The program RSWR_BOOKMARK_REORG does not provide the selection criteria to delete the bookmarks based on last accessed date.
Is there any alternative program that deletes bookmarks from RSWR_DATA table based on last accessed date?
Please advice.We want to delete the 7.X bookmarks from RSWR_DATA table based on Last accessed date. The program RSWR_BOOKMARK_REORG does not provide the selection criteria to delete the bookmarks based on last accessed date.
Is there any alternative program that deletes bookmarks from RSWR_DATA table based on last accessed date?
Please advice. -
Most recent date (UDATE) from CDHDR table based on CDPOS
Hi,
I am working on one object where i stuck with one issue. The requirement is I have to retrieve the most recent date from CDHDR table based on CHANGENR in CDPOS table. Where i am doing FOR ALL ENTRIES on CDPOS table to get the MAX( date )and i got the error, that aggregate functions are not allowed except COUNT( * ) with for all entries.
Any thread which can solve this issue would help aswel.
Please guide me how to achieve this. <removed>
Edited by: Thomas Zloch on Mar 13, 2010 9:10 PMHi Li,
Thats was really helpful information , infact my requirement is same as what you said. I even checked in the table entries there is only one changenumber.
You said we can take the first record, i even did the same. But for TABNAME I have to pass 3 table name 'LFA1', 'LFB1' and 'LFM1'. For FNAME 'LOEVM', 'SPERR'. I have written the code as below.
SELECT objectclas
objectid
changenr
FROM cdpos
INTO TABLE i_cdpos_a1
FOR ALL ENTRIES IN i_lfabm1
WHERE objectclas = c_kred "KRED
AND objectid EQ i_lfabm1-objectid "Lifnr
AND ( tabname EQ c_lfa1 OR tabname EQ c_lfb1 OR tabname EQ c_lfm1 ) "LFA1, LFB1 and LFM1
AND ( fname EQ c_loevm OR fname OR fname EQ c_sperr ) "LOEVM, SPERR
AND value_new EQ c_x.
IF sy-subrc EQ c_0.
IF i_cdpos_a1[] IS NOT INITIAL.
Select UDATE from CDHDR based on CHANGENR in CDPOS.
SELECT objectclas
objectid
changenr
udate
FROM cdhdr
INTO TABLE i_cdhdr_a1
FOR ALL ENTRIES IN i_cdpos_a1
WHERE objectclas = c_kred "KRED
AND objectid EQ i_lfabm1-objectid "Lifnr
AND changenr EQ i_cdpos_a1-changenr. "(this is coming from CDPOS above selection)
Here i got UDATE which have all the dates from 3 tables. I have to display in the output the field value (X) of LOEVM and UDATE for LFA1, SPERR value and UDATE for LFA1.Same way for other two tables, I have to display the UDATE and its field value (X). Where UDATE should be most recent date respectively.
How can I populate the Recent date (UDATE) from one interal table for indvidual field values and table names. -
Dear all experts,
I am able to populate all fields data from database table, using dynamic table creation.
eg,
SELECT * FROM (w_tabname) INTO TABLE <t_itab>.
where w_tabname is the table name given by the user, and t_itab is field symbol.
but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
<b>I can</b> take those fields from file into any internal table,
but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
i have tried with field symbol, it is not working (as per my knowledge.)
do i need to create any structures dynamically ?
Can anybody please help in this regards ?
Your help will be surely rewarded with points.
Waiting for reply..
Regards
VinayHi Vinay ,
Adding to the below code , you can use some more fields in the select stmt as below:-
REPORT ychatest.
PARAMETERS : p_field1 LIKE dd03l-fieldname,
P_field2 LIKE dd03l-fieldname,
p_table LIKE dd03l-tabname.
FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
Now p_field1 & p_field2 belong to the same table since you have give the user to enter only one table name.
This should work fine.
please try & let me know .
Thanks & Regards,
Daniel -
How to select data from a table using a date field in the where condition?
How to select data from a table using a date field in the where condition?
For eg:
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = '31129999'.
thanks.Hi Ramesh,
Specify the date format as YYYYMMDD in where condition.
Dates are internally stored in SAP as YYYYMMDD only.
Change your date format in WHERE condition as follows.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and bdatu = <b>'99991231'.</b>
I doubt check your data base table EQUK on this date for the existince of data.
Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
data itab like equk occurs 0 with header line.
select * from equk into table itab where werks = 'C001'
and <b> bdatu <= '99991231'.</b>
Thanks,
Vinay
Thanks,
Vinay
Maybe you are looking for
-
Determining which method to call from an array of Objects
Hi All, Lets suppose I have an interface, a string method name, and an array of Objects indicating the parameters which should be passed to the method. What Im trying to work out is a way to quickly determine which method should be invoked. I can see
-
Time Machine lost all old backups
I have an iMac 24" with a 750GB drive that only has about 200GB full. I have been using Time Machine to do backups onto a 400GB hard drive, and it has been working fine for a few weeks. Last week I copied 250GB of material onto my Mac's HD (as a back
-
Large Mail Attachment Affecting Mail Program
I have an IMac G5 and use the mail program that came with OS X. The other day I attached a very large movie file to an email I wanted to send to my sister but stupidly, I forgot to compress the movie. I sent the email message but it is now suspended
-
Hello, so far i have managed to write some Applets and install also Cap files on a Card. But i am not able to install my own created cap files... My Environment ist the following: My OS is Windows Vista I am using JavaCard 2.1.1 (Cause my Stick has o
-
How to update apple maps?
I see Statue of Liberty fixed with correct 3D in maps app from a blog....but when I open my maps app,the statue was not fixed....I think that maps update did't came to me....I have a ipad 3 with always connected to net....how to get new map updates..