Shortest way to retrieve from KONM Table
Hi,
Can anyone tell me how to write a query for, the shortest and quickest way to retrieve the data from KONM Table?
Sample Record in the KONM Table will be as given below.
KNUMH KSTBM KBETR
007......... 1 .......... 50
007......... 11 ........ 45
007......... 55 .........40
When i give my input Quantity (KSTBM) as 4, i should get the price (KBETR) as 50. i.e., input quantity between 1 to 10 is 50. Input Quantity between 11 and 54 is 45. Anything Greater than 55 to next greater quantity is 40,...
Is there any function module available to retrieve the record?
Also best optimized logic, will be given a full mark.
Hello Vijay
I am assuming that you have value in KNUMH with you...
here's the idea in brief..
select the values.. sort by quantity descending.. then populate a range with LE option... the first entry in the interal table which meets the condition is the value u require..
Sort of Pseudo code:
ranges: r_kstbm for kstbm.
r_kstbm-sign = 'I'.
r_kstbm-option = 'LE'.
r_kstbm-low = p_kstbm. <your quantity value comes here>
select <your fields> from KONM into table i_konm where KNUMH eq p_knumh.
if sy-subrc = 0.
sort i_konm by kstbm descending.
loop at i_knom where kstbm in r_kstbm.
<The price required> = i_konm-kbetr.
exit.
endloop.
endif.
Message was edited by:
Arun Nair
Similar Messages
-
Data Retrieval from Cluster Table - BSEG
Hi all,
I need to retreive data related to document line items from BSEG whose CLEARING DATE (AUGDT) is greater than a user given date for TWO COMPANY CODES (say 0010/0200).
as BSEG is a cluster table, it has huge data and taking large amt of time can anybody suggest a better way of retrieving data for the above conditions(fastly)
Thanks in Advance,
Lakshmihi,
use second. index tables:
customers: BSAD
vendors: BSAK
G/L acc.: BSAS
sample:
SELECT (felder) FROM bsad into TABLE stab
WHERE bukrs = bukrs
AND kunnr IN kunnr
AND gsber IN gsber
AND augbl <> space
AND hkont IN akont
AND augdt GT p_date.
regards Andreas
Message was edited by: Andreas Mann -
I need to retrieve data from ZL table and prepare a report comparing the Actual, Previous and Old records in the table for an employee for a particular period.
Are there any particular function modules for this data retrieval?
Thanks.Hi bala,
I did not get what you were trying to tell me. I went to SE37 and tried for anything that starts with "zlit" .. but returned no results.
And also I dont want time management to payroll.
I want to retrieve data from the B2 in PCL2 cluster.
i.e I want to retrieve data from the ZL table in the cluster for a particular payperiod and particular employee.
Thanks very much in advance! -
Fast data retrieval from large tables
Hello,
we have created a table in oracle 10g DB. at an average there are around 20-30 rows inserted onto the table. so in 1 mnth the record count for the table is around 800-900 rows.
in one year which is becoming to 10,000 rows. so speed up data retreval from this bulk data we need suggestion. various things that come to my mind are -
Indexing of table/# Index of table/partitioning of table/materialized view etc.
but not sure what exactly needs to be done here. please suggest on how smooth data retreival can be chaived whatever be the size of the table.
Thanks,
SamHere is a simple look of your data progression.
year Row
1 10,000
5 50,000
10 1,00,000
50 5,00,000
100 10,00,000You need to wait another 100 years to reach a million. And million is not a big number when it comes to Oracle.
So as others have stated what the objective behind your question?
basically the choice of Index or Partition mainly depends on how the data is going to be accessed from a table. If I am going to access all the rows of a table every time then there is no use of both the features. I would just prefer a FTS. In that situation i would be looking how to optimize my FTS.
So you need to set you objective clear before picking up the solution. Just because you have a hammer you cant go around banging the wall ;) -
Function modules for data retrieval from diff. tables
Hi,
I would just like to ask if there are function modules that can be used to retrieve data from the ff. tables:
TSAD3T
KNVV
ESTRH
for TSAD3T i need to get the value of title_medi
for KNVV i need to get the fields klabc vkorg vtweg
for ESTRH i need to get the fields subcat subid.
Thanks.I doubt if you have such a FM
-
PC Crashed, No Back-up of music, is there any way to retrieve from ipod
I just posted another one regarding same problem. I restored pc, but had to reinstall iTunes, now when I try to plug in my ipod, iTunes says that my ipod is synced with another iTunes library, and asks if I want to sync with this one, but if I do, it erases everything?
It is not listed in my computer either? When I click cancel, my ipod appears in itunes, but I cannot copy or do anything to any of the songs there?
Please help, any help is GREATLY appriciated...
KellyConnect your iPod to your computer. When you get the message that it is linked to a different library and asking if you want to link to this one and replace all your songs etc, press "Cancel". When your iPod appears in the iTunes source list change the update setting to manual, when using most of the utilities listed below your iPod needs to be enabled for disc use, changing to manual update will do this by default. Check the "manually manage music and videos" box in Summary then press the Apply button: Managing content manually on iPod
Once you are safely connected there are a few things you can do to restore your iTunes from the iPod. If you have any iTunes Music Store purchases the transfer of purchased content from the iPod to authorised computers was introduced with iTunes 7. A paragraph on it has been added to this article: Transfer iTunes Store purchases using iPod
The transfer of content from other sources such as songs imported from CD is designed by default to be one way from iTunes to iPod. However there are a number of third party utilities that you can use to retrieve the music files and playlists from your iPod. You'll find that they have varying degrees of functionality and some will transfer movies, videos, photos, podcasts and games as well. Have a look at the web pages and documentation, this is just a small selection of what's available, they are generally quite straightforward. You can also read reviews of some of them here: Wired News - Rescue Your Stranded Tunes
TuneJack Windows Only
iPod2PC Windows Only
iGadget Windows Only
iDump Windows Only
iRepo Windows Only
iPodRip Mac & Windows
YamiPod Mac and Windows Versions
Music Rescue Mac & Windows
iPodCopy Mac and Windows Versions
There is also a manual method of accessing the iPod's hard drive and copying songs back to iTunes on Windows or a Mac. The procedure is a bit involved and won't recover playlists but if you're interested it's available at this link: Two-way Street: Moving Music Off the iPod
Whichever of these retrieval methods you choose, keep your iPod in manual mode until you have reloaded your iTunes and you are happy with your playlists etc then it will be safe to return it auto-sync. I would also advise that you get yourself an external hard drive and back your stuff up, relying on an iPod as your sole backup is not a good idea and external drives are comparatively inexpensive these days, you can get loads of storage for a reasonable outlay. -
Data retrieve from one table control to another table control
Hi all,
I had an requirement like to create Two table controls.
for first Table control i had an sel field defined as 'MARK'.
when i check the row in the first table control think it is header data for sales order .
all the item details have to retrieve in the second table control.
This is my requirement, i am not able to trigger when selecting the row in table control.
will anybody had an experience like this.
Regards,
MadhaviHi Madhavi,
If we need the case to display header and item as mentioned in 2 table controls....
we can display in table control 2/item only (the line items of the one selected in the table control 1 or the header )...so ,at a time we need to display line items for only 1 header ....
so ...first disable the selections/multiple selections to disable the row selector
We have already declared a field type C to capture the value for the field selector...so we can convert this field to a radio button and then assign a function code to the radio button at screen level
Whenever you click on the radio button ..immediately the function code is triggered..then in PAI ..we can check and find the header record with 'X' and populate the data for the table control 2
Hope it helps
Regards
Byju -
Data retrieval from keko table with conditions as for a group of same mat
hi Freinds,
the problem iam facing here is i have certain materials in table keko , among which i need to retrieve the material with date as the latest one for that particular material provided costing status is 'FR' and Release is "X'.
here is the example i gave where material 14ce2-1krs has 3 different dates , i need to retreive the latest one .... like this for 15ce2..
plz reply ... thanks...
Material Costing Date Costing Status Release 14CE2-1K-RS 02.25.2007 FR 14CE2-1K-RS 04.01.2007 FR X 14CE2-1K-RS 04.29.2007 FR X
15CE2 01.20.2007 FR X
15CE2 03.10.2007 FR X
15CE2 05.14.2007 FR X
15CE2 07.22.2007 FR XHi,
Sort ITAB by <Material> <Date> descnding.
Delete adjacent duplicates comparing Material.
Then table will contain material with latest date.
Hope this helps... -
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. -
Query to retrieve from partitioned table
i have a table called xyz which is having 5 columns
(client,datmonth,productid,productname,productdesc)
and it is partitioned as
column client is the primary partition
column datamonth is subpartitioned based on client
if i have to select both client and datamonth how to do it by select query
i arrived till
select * from xyz partition <clientid-partition>
but unable to proceed further
any help?Like that ?
DROP TABLE XYZ ;
CREATE TABLE XYZ
( client_No NUMBER(10) Not Null check (CLIENT_NO > 0)
, datmonth DATE Not Null
PARTITION BY RANGE( client_No )
SUBPARTITION BY LIST (datmonth)
SUBPARTITION TEMPLATE
( SUBPARTITION SP_2005 VALUES (To_Date('20050101','YYYYMMDD'))
, SUBPARTITION SP_2006 VALUES (To_Date('20060101','YYYYMMDD'))
, SUBPARTITION SP_2007 VALUES (To_Date('20070101','YYYYMMDD'))
, SUBPARTITION SP_DEFAULT VALUES (DEFAULT)
( PARTITION P_0001 VALUES LESS THAN (2)
, PARTITION P_0002 VALUES LESS THAN (3)
, PARTITION P_0003 VALUES LESS THAN (4)
, PARTITION P_0004 VALUES LESS THAN (5)
, PARTITION P_Others VALUES LESS THAN (MAXVALUE)
INSERT INTO XYZ
SELECT Mod( RowNum,6)+1 Client_No
, Add_Months( Trunc( SysDate, 'YYYY') , Mod( DBMS_RANDOM.random, 24)) DateMOnth
FROM DUAL CONNECT BY ROWNUM <= 100
SELECT * FROM XYZ PARTITION (P_0001) A;
SELECT * FROM XYZ SUBPARTITION (P_0001_SP_2006) A;
SELECT * FROM XYZ SUBPARTITION (P_0002_SP_2006) A;
mi -
Hi,
I have a table and the below query is used to fetch around 3 lakh record.
select * from emp where start_date between sysdate and (sysdate -30).
It was taking more time(more than 1hr), hence i created index on the start_date column and now could get records in 1/2 hr, can you please suggest other ways of quick data retrieval from this table.
Thank YouHello,
What's your oracle version? You said 3 lakh (300 K) records and you have indexed sysdate column. How many records is this table contains? You can also try partitiong (Monthly by Range using start_date on this table which further improve query to reterieve data for entire month. Also like other suggested collecting stats you should try this
exec DBMS_STATS.GATHER_TABLE_STATS ('TESTME',EMP',NULL,25,FALSE, 'FOR ALL INDEXED COLUMNS SIZE AUTO',2,'ALL');Also, if you running this query from sqlplus (client or server), before running set arraysize 500 or 1000 (you can find optimal values by compairing explain plans)
Regrds
Edited by: OrionNet on Jan 6, 2009 11:25 PM -
Creat View from Multiple tables , Multiple Select
Hello Everyone ,
I have a question and am not sure if this the correct forum to post it .
I have two table studentTable and CourseTable which is each student take more than one course . 1:M
for example Student1 take 2 courses (C1 , C2).
Student2 take 3 courses (C1,C2, C3).
I need to create a table/View that contain student information plus all the courses and the score for each course in one row.
for example
Row1= Student1_Id ,C1_code ,C1_name ,C1_Score ,C2_code,C2_name ,C2_Score
Row2=
Student2_Id,C1_code, C1_name,C1_Score,C2_code ,C2_name ,C2_Score , C3_code,C3_name,C3_Score
and since Student 1 just took two courses , I should enter NULL in 'Course 3 fields'
My Struggle is in the insert statement
I tried the following but it show an error
Insert Into Newtable
( St_ID, C1_code,c1_name, C1_Score ,C2_code ,C2_name,C2_score,C3_code ,C3_name,C3_score)
Select
(Select St_ID from StudentTable)
(Select C_code,c_name,c_Score
from Coursetable,SudentTable
where course.Stid =Studet.stid)
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid ),
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid );
I'm fully aware that the New table will break the rules of normalization ,but I need it in this way for specifc purpose.
I tried also the PIVOT BY functionality but no luck with it .
FYI , I'm not expert in using SQL Syntax , I just know the basic.
I will be great full for any helpfull suggestions to try ,
thank you very much.First Table is Member table which Represent
Students Information
.The fields in this table are
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
Second Table is Modules table which include
the Courses' scores that Student took .
The fields in this table are
Module_result_k(Primary Key), member_sk(Foreign key to connect to Member table), member_stage_sk
,module_k(Foreign key to connect to Module table), module_confirmed_grade_src, credit_or_result
Third Table is
AllModuleInfo which is include
general information for each course .The fields in this table are
Module_k (Primary key), module_name ,module_code, Module_credit, Module stage.
The New table
that I will create has the following fields
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
" This will be retrieved from Member table"
Also will include
Module 1_name ,module1_code, Module1_credit, Module1_ stage, member1_stage_sk
, module1_confirmed_grade_src, credit1_or_result
Module 2_name ,module2_code, Module2_credit, Module2_ stage, member2_stage_sk
, module2_confirmed_grade_src, credit2_or_result
I will repeat this fields 14 times which is equal to Maximum courses number
that any of the students took.
//// I hope now my questions become more clear -
Parameter retrieve from variable_table
I have a parameter like this:
l_cheque CONSTANT varchar2(6) := 'CHEQUE';How do I set my parementer like this?
l_cheque CONSTANT varchar2(6) := 'select variable from variable_table where name = 'Cheque';The reason why I am retrieving from my table is because I want to make sure my parameter is able to change to the value that whatever my variable_table is changed to. Is it possible to do it this way?You can proceed like this.
l_cheque variable_table.variable%type;
select variable into l_cheque from variable_table where name = 'Cheque';
Is this you require?
Regards
Raghu -
Inserting data from one table into another table using PL/SQL
HI,
I am trying to insert values from one table into another using PL procedure, the values I want to retrieve from the table riverside1 are charac_id and charac_type and insert these values into another table called riverside2 , the stored procedure zorgs_gorfs(x,y) accepts two parameters which are 2 charac_id's of d characters in riverside1 then using insert statements inserts these characters from riverside1 into riverside2.
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id)
VALUES
(x);
INSERT INTO riverside2
(charac_id)
VALUES
(y);
END zorgs_gorfs;
/This works but the problem im having is that when I also try to insert the charac_type as well as the charac_id it doesnt work below is the code:
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);
END zorgs_gorfs;
/can someone kindly sort me outmodify this sql
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);as
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id in ( x,y));But my suggestion would be consider revising your approach. It does not look that good.
Thanks,
karthick. -
Delete records from multiple table
Hi,
I need to delete records from multiple tables using a single delete statement. Is it possible ? If so please let me know the procedure.
Kindly Help.
Thanks,
Alexander.Hi Tim,
Syntax of DELETE statement does not allow for multiple tables to be specified in this way. Infact, none of the DMLs allow you to specify table names like this.
Technically, there are other ways of deleting from multiple tables with one statement.
1. "Use a trigger":
What was probably meant by this is that you have a driving-table on which you create a on-delete trigger. In this trigger, you write the logic for deleting from other tables that you want to delete from.
This does mean a one-time effort of writing the trigger. But the actual DML operation of deleting from all the tables would be simply triggered by a delete on driving-table.
2. Dynamic SQL:
Write a PL/SQL code to open a cursor with table-names from which you want the data to be deleted from. In the cursor-for loop, write a dynamic SQL using the table-name to delete from that table.
3. Using Foreign-Key constraint with Cascade-Delete:
This I feel is a more 'cleaner' way of doing this.
Having to delete data from multiple tables means that there is some kind of parent-child relationship between your tables. These relationships can be implemented in database using foreign-key constraints. While creating foreign-key constraint give the 'on delete cascade' clause to ensure that whenever data is deleted from parent-table, its dependent data is deleted from child-table.
Using foreign-key constraint you can create a heirarchy of parent-child relationships and still your DELETE would be simple as you would only have to delete from parent-table.
IMPORTANT: Implementing foreign-key constraints would also impact other DML operations that you should keep in mind.
Maybe you are looking for
-
How do I send "unlimited" text in a parameter using "POST" in Ajax
I'm trying to send large amounts of text data to the server using POST rather than GET, using Ajax However, I am only able to send a max of 9.76 kb I start with a jsp page, which calls a javascript method that utilises Ajax, which sends the text in a
-
How to set an array element in an object type of array??
Hi, I have set attribute as follow: Color[] colors; Color[] colors = new Color[20]; colors[0] = "Red"; colors[1] = "blue";I can't compile this code. It said: "Incompatible type -found java.lang.String but expected Colors Could you tell me how to set
-
Exchange XML document containing serialized DDIC objects
Hi, Suppose you have an itab "z_table" with generic linetype. The table may contain any ddic structure or table. Furhter you want to exchange the itab "z_table" between the Systems A and B using XML. We are using the following code to serialize the i
-
Workflow problem during import of record
Hi, We get the following error message during import of a record using import manager: 4868 2008/05/05 15:12:44.861 Error: RC: 0x80000002 4868 2008/05/05 15:12:44.861 Error: Failed to GetJoinCheckOutRights. [Owner: WF Owner; Job Id: 10165] Curr
-
Hi can anyone help me in the game sacra terra I can not use the syringe to pick up the stone eating acid despite the fact the hint shows to do it. Every time I put it to the right place it just returns to its original position. All help appriciated