DBAdapter - Select Query with parameter
Newbie Question : I need to get data from database based on a value entered by the user. I have created a dbadapter with select operation and it accepts one parameter that is used in the where clause. My question is how do I pass the value entered in the form to the db adapter parameter to get the results.
Your human task should take the parameter you're passing into your DB adapter call as a part of its payload. So there should be an incoming and outgoing data association for your interactive activity (human task) passing that value. Then in your service call you should have an incoming data association that maps that parameter into the proper input parameter of the service call.
Similar Messages
-
CANT execute query with parameter on user defined tables using query genera
Dear All,
I have problem when executing query with parameter on user defined tables using query generator.
It seems SBO cannot accept parameter to query user defined tables.
I've tried these:
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
I try to pass the value directly without using parameter and It works
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
This one works
SELECT * FROM RDOC T0 WHERE T0.width =[%0] --- this SUCCESS
and this one works too
SELECT * FROM RDOC T0 WHERE T0.width = 595 --- this SUCCESS
Is there anyone can help me ....???
Thanks,
AlfaI generated this code using query wizard ....
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = (N'2' )
and replaced the (N'2' ) with [%0]
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = [%0]
and It worked ......
Thanks 4 all ..... -
Send values to IN query with parameter
Subject: send values to IN query with parameter
Hello. Hope I'll explain my problem well enough:
I have a query:
-- select id from table where id in ('100')
Now I used parameter for the IN part:
-- select id from table where id in (:param)
and I gave the parameter the value 100.
now I want to have the query with two values:
-- select id from table where id in ('100','200')
I tried to use the parameter and give him the value of: '100','200'.
It didn't worked :(
Is there a syntax to give the parameter more then one value for the IN query (with out using another table or function etc')?
Thanks in advance,Roy.This is the best solution I have for it.
variable parameter varchar2(4000);
exec :parameter := 'SYSTEM,SYS';
select username
from dba_users
where username in ( select COLUMN_VALUE from table (split_string(:parameter,',')))It uses this function
CREATE OR REPLACE
type string_table as table of varchar2(4000)
CREATE OR REPLACE
FUNCTION split_string (
string IN varchar2,
delimiter IN varchar2
) RETURN string_table IS
tab string_table;
pre integer;
post integer;
step integer;
i integer;
BEGIN
pre := 1;
step := length(delimiter);
i := 0;
tab := string_table();
loop
tab.extend;
i := i + 1;
post := instr(string,delimiter,pre);
if ( post = 0 ) then
tab(i) := substr(string,pre);
return tab;
end if;
tab(i) := substr(string,pre,post-pre);
pre := post + step;
end loop;
END;
/Bye Alessandro -
Issue in select query with where clause
Hi guys,
I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
Here is my query which causing the issue,
select * from mytable where myfield = 'myvalue'
But if I use the following query it returns the result correctly.
select * from mytable
Also the myfield value 'myvalue' exists in the table.
I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
Thanks,
Ram.Hi Ram,
I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
select * from employees
where email = '[email protected]'The best way I found to detect this was to use
select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
Jeff -
How to write XSJS Select Query with input parameters
Hello Experts,
I am creating a xsjs file and in that file I am trying to write a Select Query based on a Calculation View
I have tried it the following way:
var query = 'SELECT TOP 100 \"Name\", \"Address\", \"City\", \"Country\" FROM \"_SYS_BIC\".\"Test.HL/AddressView\"'
+ 'WITH PARAMETERS(\'PLACEHOLDER\' = (\'$$P_Name$$\', \' Akhil \'),'
+ '\'PLACEHOLDER\' = (\'$$P_City$$\', \' Lucknow \'))';
But it gives me the "Mixed spaces and tabs error".
How should I write XSJS Select Query with input parameters?
Regards,
Rohit>But it gives me the "Mixed spaces and tabs error".
Mixed spaces and tabs has nothing to do with the syntax of the statement. You used both spaces and the tab in the content - which JSLint doesn't like. Remove the beginning spaces of each line and use only one or the other.
The actual syntax of your statement doesn't look right. The problem is that you are escaping the \ when you don't need to if you are using ' instead of " for your string. You escape with \" in the first line but then escape with \' in the 2nd and 3rd line. That is going to cause serious parsing problems with the command. -
Absolute dynamic select query with dynamic join and where
Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
SELECT (FIELDS) INTO TABLE IT_TABLES
FROM ( (ME->TABLE1) inner join ( me->table2 )
on ( on_condition ) )
WHERE (me->where_fields).
Ags.It worked for me in a following way:
select * into corresponding fields of table <result_table>
from (join_string)
where (l_where).
Where the contents of join_string were dynamically build using concatenation. So it will be something like
concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
<...>
add here matching/reference colums, something like
concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
concatenate join_string temp1 '=' temp2 into join_string separated by space.
<...>
concatenate join_string ')' into join_string separated by space.
And then use similar approach for l_where variable. -
Dynamic select query with dynamic where condition
Hi all,
I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
Please advice, if there is any other way to achieve this requirement.
Thanks,
Sanket Sethi
Code***************
PARAMETERS: p_tabnam TYPE tabname,
p_selfl1 TYPE edpline,
p_value TYPE edpline,
p_where1 TYPE edpline .
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
l_wa_name TYPE string,
ls_where TYPE edpline,
l_having TYPE string,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
* <ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
* INTO ls_where
* SEPARATED BY space.
*APPEND ls_where TO lt_where.
* Creation of the "where" clause
APPEND p_where1 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
* WHERE (lt_where).Hi Sanket,
The above given logic of mine works for you, put the code in the If condition and try-
just like below:
IF NOT P_EBELN IS INITIAL.
lt_where = '& = ''&'' '.
REPLACE '&' WITH p_ebeln INTO lt_where.
REPLACE '&' WITH field_value INTO lt_where.
SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
FROM (p_tabnam)
WHERE (lt_where).
ENDIF.
thanks\
Mahesh -
BDC select query with addition based on all If conditions
Hi can any one send me the select query with conditions like
If Itab is not initial.
Endif. and if possible with valiadations messages also.
IF CHECK_NUMBER of CHECK_ADVICE of the flat file = PAYR-CHECT. Then update SAP field BSEG-XREF2 .
9. When Flat file check Number = PAYR-CHECT then Insert or Update Flat file RECEIPT_DATE into SAP field BSEG-XREF1.
Please send me immediately.> SELECT rsnum
> rspos
> matnr
> werks
> lgort
> shkzg
> aufnr
> bdmng
> enmng
> FROM resb INTO TABLE it_rsnum FOR ALL ENTRIES IN it_aufnr
> WHERE rsnum EQ it_aufnr-rsnum
> AND xloek NE 'X'
> AND postp NE 'X'
> AND resbbdmng GE resbenmng.
> ENDIF.
>
> Database Table RESB: 40,000,000 Records (40 Million)
> Internal Table it_aufnr: 20,000 Entries
> Entries selected from RESB: 150,000.
>
Hi,
the problem is the big for all entries table.
Your 20.000 records FAE will be split into SEVERAL sql statements depending on the size of the table.
Where do you get the it_auftrn from?
If it's another transparent table try to JOIN this table to your big table.
SELECT rsnum
rspos
matnr
werks
lgort
shkzg
aufnr
bdmng
enmng
FROM resb JOIN tab_auftrn on resbrsnum = tab_auftrnauftrn
AND xloek NE 'X'
AND postp NE 'X'
AND resbbdmng GE resbenmng.
Make sure that your WHERE filter and the JOIN keys on both tables are supported by indexes.
150.000 records about of 40 Mio. can definitly be serviced by an appropriate index:
i.e. Index fields (check your PK or secondary indexes):
rsnum
enmng
aufnr
bye
yk -
I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year
Hi Arun ,
Can you explain little bit more ??
what is account doc no?
what are the transactions should be displayed in your output??
-Rajesh N -
How to re-write this big SELECT Query with INNER JOINs?
Hi Experts
I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
INTO TABLE INT_TAB_RES
FROM VBAP AS A INNER JOIN VBAK AS D
ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
INNER JOIN VBEP AS E
ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
WHERE A~VBELN IN s_VBELN AND
D~auart in s_auart AND
D~vkorg in s_vkorg AND
D~vbtyp eq 'C' AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
E~ETENR EQ '1'.
SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
CHECK NOT INT_TAB_RES [] IS INITIAL.
SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
Now, the requirement is:
I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
Please help.
Thx n RgdsHi Nagraj
As of your suggestion, I have re-written the query as below:
* Declarations
TYPES: BEGIN OF TYP_COLL_ORD,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBUP-POSNR,
MATNR LIKE VBAP-MATNR,
KWMENG LIKE VBAP-KWMENG,
KBMENG LIKE VBAP-KBMENG,
ERDAT LIKE VBAK-ERDAT,
ERZET LIKE VBAK-ERZET,
PSTYV LIKE VBAP-PSTYV,
AUART LIKE VBAK-AUART, u201Calready exists in type
ETTYP LIKE VBEP-ETTYP,
EDATU LIKE VBEP-EDATU.
TYPES: END OF TYP_COLL_ORD.
DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
TYPES: BEGIN OF TYP_VBUK,
AUART LIKE VBAK-AUART, u201Chave added this field
VBELN LIKE VBUK-VBELN,
UVALL LIKE VBUK-UVALL,
CMGST LIKE VBUK-CMGST.
TYPES: END OF TYP_VBUK.
DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
*QUERY#1 u2013 for VBAK & VBUK Join
SELECT A~AUART B~VBELN B~UVALL B~CMGST
INTO TABLE INT_VBUK
FROM VBAK AS A INNER JOIN VBUK AS B
ON A~VBELN EQ B~VBELN
WHERE A~VBELN IN s_VBELN AND
A~auart in s_auart AND
A~vkorg in s_vkorg AND
A~vbtyp eq 'C' AND
B~UVALL NE 'A'.
IF NOT INT_VBUK[] IS INITIAL.
SORT INT_VBUK BY VBELN.
DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
*QUERY#2 u2013 for VBAP & VBEP Join
SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
INTO TABLE INT_COLL_ORD
FROM VBAP AS A INNER JOIN VBEP AS B
ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
FOR ALL ENTRIES IN INT_VBUK
WHERE A~VBELN = INT_VBUK-VBELN AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
B~ETENR EQ '1'.
ENDIF.
SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
COMPARING VBELN POSNR.
CHECK NOT INT_COLL_ORD[] IS INITIAL.
LOOP AT INT_COLL_ORD.
CLEAR: L_MTART,L_ATPPR,L_ETTYP.
IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
CHECK SY-SUBRC NE 0.
Now, the issue is:
Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
How to include this value into the INT_COLL_ORD?
Plz suggest.... -
Query with parameter as Array (UDT) very slow
Hi.
I have following Problem. I try to use Oracle Instant Client 11 and ODP.NET to pass Arrays in SELECT statements as Bind Parameters. I did it, but it runs very-very slow. Example:
- Inittial Query:
SELECT tbl1.field1, tbl1.field2, tbl2.field1, tbl2.field2 ... FROM tbl1
LEFT JOIN tbl2 ON tbl1.field11=tbl2.field0
LEFT JOIN tbl3 ON tbl2.field11=tbl3.field0 AND tbll1.field5=tbl3.field1
...and another LEFT JOINS
WHERE
tbl1.field0 IN ('id01', 'id02', 'id03'...)
this query with 100 elements in "IN" on my database takes 3 seconds.
- Query with Array bind:
in Oracle I did UDT: create or replace type myschema.mytype as table of varchar2(1000)
than, as described in Oracle Example I did few classes (Factory and implementing IOracleCustomType) and use it in Query,
instead of IN ('id01', 'id02', 'id03'...) I have tbl1.field0 IN (select column_value from table(:prmTable)), and :prmTable is bound array.
this query takes 190 seconds!!! Why? I works, but the HDD of Oracle server works very hard, and it takes too long.
Oracle server we habe 10g.
PS: I tried to use only 5 elements in array - the same result, it takes also 190 seconds...
Please help!I did (some time ago and it was a packaged procedure) something like
Procedure p(p_one in datatype,p_two in datatype,p_dataset out sys_refcursor) is
the_sql varchar2(32000);
the_cursor sys_refcursor;
begin
the_sql = 'WITH NOTIFICACAO AS( ' ||
' SELECT ' ||
' t1.cd_consultora, ' ||
' where t1.dt_notificacao_cn >= to_date(''01/09/2006'',''dd/mm/yyyy'') ' || -- note the ''
' where rownum <= :W_TO_REC) ' || -- parameter 1
' where r_linha >= :W_FROM_REC '; -- parameter 2
open the_cursor for the_sql using p_one,p_two; -- just by the book
end p;if I remember correctly
Regards
Etbin -
Using sql query with parameter
OK, I can't find any docs on this. I can insert a parameter, but how do I insert that into the sql query?
Your first post asked how to insert a paremeter into a SQL. My example shows a value read query with a SQL function, but any SQL will work with any Query in the same pattern.
a) You call the query with session.executeQuery(query, vectorOfArguments);
b) You use #argument in the SQL string and then query.addArgument("argument");
c) You pass them in a Vector of the order in which you do the addArgument's.
- Don -
Select query with secondary index
hi,
i have a report which is giving performance issues on a perticular select query on KONH table.
the select query doesnt use the primary key fields and table already has around 19 million entries.So there was a secondary index created for the fields in the table.
now, KONH is a client specific table, and hence has MANDT as the first field. when the table is not indexed it is sorted according to the order of fields, like first MANDT, then primary key fields and then remaining fields.. (correct me if i am wrong)
but the secondary index created doesnt has MANDT in it..(yea, a mistake! )...
but instead of correccting the secondary index, i am told to change the select query..
so, i used a "client specific" syntax to sort the issue.. but i dont understand whre i should put the "where mandt eq sy-mandt" clause..
should i put it right after all my secondary index fields are over? or what happens to the order of fields which are not present in the list of secondary index?
kindaly help.
thanx.Hi chinmay kulkarni,
its better if you can ask concerned person to add MANDT field in your index as well....
Indexes and MANDT
If a table begins with the mandt field, so should its indexes. If a table begins with mandt and an index doesn't, the optimizer might not use the index.
Remember, if you will, Open SQL's automatic client handling feature. When select * from ztxlfa1 where land1 = 'US' is executed, the actual SQL sent to the database is select * from ztxlfa1 where mandt = sy-mandt and land1 = 'US'. Sy-mandt contains the current logon client. When you select rows from a table using Open SQL, the system automatically adds sy-mandt to the where clause, which causes only those rows pertaining to the current logon client to be found.
When you create an index on a table containing mandt, therefore, you should also include mandt in the index. It should come first in the index, because it will always appear first in the generated SQL.
Index: Technical key of a database table.
Primary index: The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
Secondary index: Additional indexes could be created considering the most frequently accessed dimensions of the table.
Structure of an Index
An index can be used to speed up the selection of data records from a table.
An index can be considered to be a copy of a database table reduced to certain fields. The data is stored in sorted form in this copy. This sorting permits fast access to the records of the table (for example using a binary search). Not all of the fields of the table are contained in the index. The index also contains a pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
When creating indexes, please note that:
An index can only be used up to the last specified field in the selection! The fields which are specified in the WHERE clause for a large number of selections should be in the first position.
Only those fields whose values significantly restrict the amount of data are meaningful in an index.
When you change a data record of a table, you must adjust the index sorting. Tables whose contents are frequently changed therefore should not have too many indexes.
Make sure that the indexes on a table are as disjunctive as possible.
(That is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.)
For Example...
SELECT KUNNR KUNN2 INTO TABLE T_CUST_TERR
FROM KNVP CLIENT SPECIFIED
WHERE MANDT = SY-MANDT " here MANDT shd be first
AND KUNN2 IN S_TERR
AND PARVW LIKE 'Z%'.
Accessing tables using Indexes
The database optimizer decides which index on the table should be used by the database to access data records.
You must distinguish between the primary index and secondary indexes of a table. The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated
Also pls have a look on below link
http://www.sapfans.com/sapfans/forum/devel/messages/30240.html
Hope it will solve your problem..
Reward points if useful...
Thanks & Regards
ilesh 24x7 -
Select query with UNION clause in database adapter
Friends,
I have got a SQL query with two UNION clause withing it. like
select a,b,c
from a
union
select a,b,c
from b
The schema generated is like below in sequence
<element>a</element>
<element>b</element>
<element>c</element>
<element>a</element>
<element>b</element>
<element>c</element>
So, the columns from different select queries joined with UNION clause are all appeared in schema instead of the distinct columns.
Is there any way around to solve this issue ? or will need to with DB function/procedure.I think I know what you are saying but your example doesn't make sense, your SQL should produce something like
I had to change a, b, c with elementA, elementB, elementC as a and b are reserved html tags.
<elementA>DateA</elementA>
<elementB>DataB</elementB>
<elementC>DataC</elementC>
...What is the result of the query when you run it in SQLPlus? Is it what you expect?
cheers
James -
Dear Experts,
I have writen a inner join code with MKPF and MSEG which taking too much time, while I have used index.
Indexes are:
MSEG
MATNR
WERKS
LGORT
BWART
SOBKZ
MKPF
BUDAT
MBLNR
My Select Query is :
SELECT B~MATNR
B~MAT_KDAUF
B~MAT_KDPOS
B~BWART
B~MENGE
B~MEINS
B~AUFNR
INTO TABLE IT_MSEG
FROM MKPF AS A
INNER JOIN MSEG AS B
ON AMBLNR EQ BMBLNR
AND AMJAHR EQ BMJAHR
WHERE A~BUDAT IN BUDAT
AND B~MATNR IN MATNR
AND B~WERKS IN WERKS
AND B~LGORT IN LGORT
AND B~BWART IN BWART.hi,
you can use for all entries it will work faster then joins
About it:*
FOR ALL ENTRIES WHERE
Syntax
... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
Effect
If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
The internal table itab must have a structured line type and the component comp must be compatible with the column col.
The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
Notes
In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
Example
Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
PARAMETERS p_city TYPE spfli-cityfrom.
TYPES: BEGIN OF entry_tab_type,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF entry_tab_type.
DATA: entry_tab TYPE TABLE OF entry_tab_type,
sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
SELECT carrid connid
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE entry_tab
WHERE cityfrom = p_city.
SELECT carrid connid fldate
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_tab
FOR ALL ENTRIES IN entry_tab
WHERE carrid = entry_tab-carrid AND
connid = entry_tab-connid.
hope it will help you
Rahul sharma
Edited by: RAHUL SHARMA on Sep 11, 2008 8:10 AM
Maybe you are looking for
-
MY IPHONE4 DIED EVEN IF IT'S NOT EMPTY BATTERY. WHAT WILL I DO?
I charged the phone before I leave. When I was on the road, it was still working and all of a sudden, when I was trying to push the power on. My phone is not working anymore. I bought this phone from a friend a year ago. Home button has a problem alr
-
"Software currently unavailable" error while installing printer
I have a Brother MFC-465CN multifunction printer that I used as a standalone USB printer for over a year from my 27" Mac. I recently connected it to my router (printer is networkable) so that I can share with my windows 7 PC. I am easily able to prin
-
i have read many many many different posts and they all helped but none of them fixed the problem, my itunes and quicktime will not load. There is no error message and itunes only flashes for a second, in windows task manages the itunes.exe thing fla
-
Why can't I use any of my apps on a secondary computer?
I never thought I'd have any issues with Adobe, however since purchasing a Creative Cloud Subscription a few days ago I'm having a licensing issue. On my first Windows PC, I downloaded and installed all Apps avaliable to me via Adobe Application Mana
-
How call native method without code modification
"How to access third party's C API from Java Using JNI without modifying the C code"