Adding one more table to the select statement joining 4 tables gives dump
Hi All,
There is a select statement using which four tables namely VBAK,VBAP,LIPS and LIKPUK(view) are joined(inner join).Here, date and time fields are selected from LIPS and used.
My requirement is to consider the Date (LIKP - WADAT_IST) instead of LIPS-ERDAT and time(LIKP-SPE_WAUHR_IST) is to be used instead of LIPS-erzet.
Neither LIPS nor LIKPUK contains time(SPE_WAUHR_IST) field. And, I cannot remove LIPS table or LIKPUK view as each contains a unique field which is used in the report.
When I tried to join LIPS in the select query, it is going to dump.
Can someone suggest a good approach ?
Thanks,
Pavan
Thank you for the detailed explanation of the dump.
The dump details together with your code lead to the answer: 42.
Regards,
Clemens
Similar Messages
-
Calling an SP takes over 200% more time over the select statement
As part of my POC converting a SQL Server application over to SAP HANA, I'm find that CALL is taking over 200% more time than calling the SELECT statement directly. The result is that the application that uses ODBC against HANA with CALL statements is taking much more time than SQL Server. I'm finding this for all stored procedure calls in the application. Here is an example:
CREATE PROCEDURE dbo.usp_GetOrdersByCustomerID
(IN C_ID bigint)
LANGUAGE SQLSCRIPT DEFAULT SCHEMA "DBO" READS SQL DATA
AS BEGIN
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Customer JOIN dbo.Orders ON C_ID = O_C_ID
WHERE C_ID = :C_ID
ORDER BY O_ID DESC;
END;
When using the following CALL statement in SAP HANA Studio
CALL dbo.usp_GetOrdersByCustomerID(3429);
I get execution times that look like this:
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 9 ms 663 µs (server processing time: 8 ms 115 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 11 ms 851 µs (server processing time: 8 ms 238 µs)
Fetched 5 row(s) in 0 ms 62 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 8 ms 522 µs (server processing time: 6 ms 892 µs)
Fetched 5 row(s) in 0 ms 93 µs (server processing time: 0 ms 0 µs)
When I execute the select statement with the hard coded parameter value, I get much faster results:
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 430 µs (server processing time: 2 ms 424 µs)
Fetched 5 row(s) in 0 ms 73 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 105 µs (server processing time: 2 ms 210 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 694 µs (server processing time: 2 ms 810 µs)
Fetched 5 row(s) in 0 ms 60 µs (server processing time: 0 ms 0 µs)
I have 500,000 rows in the Customers table and 2,500,000 rows in the Orders table. The tables are COLUMN tables.
Is there an optimization that I'm missing?
Regards,
BillHi Bill,
Can you please try something:
tab_cust =
SELECT
C_F_NAME,
C_L_NAME,
C_EMAIL
FROM dbo.Customer
WHERE C_ID = :C_ID;
tab_orders =
SELECT
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM dbo.Orders ON C_ID = O_C_ID
WHERE O_C_ID = :C_ID
SELECT TOP 20
C_F_NAME,
C_L_NAME,
C_EMAIL,
O_ID,
O_TOTAL,
O_DTS,
O_FM_DTS
FROM :tab_cust JOIN :tab_orders ON C_ID = O_C_ID
ORDER BY O_ID DESC;
END;
Expected behavior: The data set for each of the tables is filtered out and then joined. Although the filter is expected to be pushed to each of the joined tables even in your case, but this is worth the try.
Regards,
Ravi -
How to compare two fields from the same table in the select statement
Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is cptotchek = 0, but there are the records in aufk , where, aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
RegardsHi ,
it will not return any value when you are using column of same table
such as Date Field , Because while Using Aggregate Function it will not check with self column
. For that you have to take data in one internal table and then you can work on it .
And if you are worried about Performance it will not affect , untill you are selecting only required data .
you can try this way .
data: cptotchek type i.
types : begin of w_aufk.
include structure aufk .
types : end of w_aufk .
data : it_aufk type standard table of w_aufk with header line .
select * into corresponding fields of table it_aufk
from aufk .
loop at it_aufk .
if it_aufk-erdat = it_aufk-idat2 .
write : / it_aufk-erdat , it_aufk-idat2 .
else .
delete it_aufk .
endif .
endloop.
Regards
Deepak. -
Adding one more field to the VL06O report
Hi everybody
When u execute the TR code VL06O a screen will appear from that screen select list outbound deliveries and then provide some date and execute.
The output will come having fields delivery,ship-to-party,name of ship-to-party like that 7 fields are there and now i want to see one more field called shipment number in the output along with the previuos 7 fields.
what should i do it is a standard program?
please guide me?Hello.
See note 128150 to more details.
There are user exists to add new fields (user fields).
Regards. -
Adding one more field to the Base line price screen (MEk3)?
Hi,
Now we are entering the base line price for each material.
My requirement is
1) Ability to enter in baseline prices by part by supplier.
If no supplier is entered then the baseline value applies to all suppliers. If a price needs to be recorded specific to a supplier, then the supplier code must be entered. Thus, a part may have two entries (one for all suppliers, and one or more for each unique supplier that needs to be recorded).
How to proceed for this requirement..how to start ...please help me..is this config change or code change..or it is related to custom or standrard change?
please help..Hello,
You can define access sequence (SPRO->Materials Management->Purchasing->Conditions->Define Price Determination Process) for the condition type to look at Vendor/Material level and Material level in the sequence. Please make the access Exclusive so that no further search is carried out once a condition record for Vendor/Material level is found.
Thanks,
Venu -
Adding one more selection field in the standard data source
Hi SAP Gurus,
I'd like to know how to add one field as a selection field for the data source.I used 0FI_GL_4 Datasource .It has 2 selection.Now I want to add one more field as a selection field .How to mark that field as selection?I tried by using RSA6 ,But I'm unable to change the previous selection.
Please let me know how to fix it?
I'll assign the points ...
Thanks & regards
RajaPradip,
when ever you create any Generic DS, you can find generic DS(I checked this), comming append fields(it's happend to me)... there is no meaning.. as we know... we will extract the data for append fields using existing DS.
Comming Raju:
to my knowledge, you should not add that field as selection enabled(wait for others posts). I had seen many posts for working on this... by updating the Table ROOSFIELD table for the respective DS. I never implemented this... if you update this using any custom program be careful. Ihave ccreated the program for append fields not for Standard Extractor.
Try to search any SAP Notes: 571985
All the best.
Regards,
Nagesh Ganisetti. -
Adding 2 more rows to a select without inserting rows to base table
hello all,
i have a below simple select statement which is querying a table.
select * from STUDY_SCHED_INTERVAL_TEMP
where STUDY_KEY = 1063;
but here is the situations. As you can see its returning 7 rows. But i need to add
2 more rows..with everything else default value or what exist... except adding 2 more rows.
i cannot insert into base table. I want my end results to increment by 2 days in
measurement_date_Taken to 01-apr-09....so basically measurement_date_taken should
end at study_end_Date...
IS THAT EVEN POSSIBLE WITHOUT INSERTING ROWS INTO THE TABLE AND JUST PLAYIHY AROUND WITH
THE SELECT STATEMENT??
sorry if this is confusing...i am on 10.2.0.3
Edited by: S2K on Aug 13, 2009 2:19 PMWell, I'm not sure if this query looks as good as my lawn, but seems to work anyway ;)
I've used the 'simplified version', but the principle should work for your table to, S2K.
As Frank already pointed out (and I stumbled upon it while clunging): you just select your already existing rows and union them with the 'missing records', you calculate the number of days you're 'missing' based on the study_end_date:
MHO%xe> alter session set nls_date_language='AMERICAN';
Sessie is gewijzigd.
Verstreken: 00:00:00.01
MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
2 select 1063 study_key
3 , to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
4 , to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
5 , to_date('01-APR-09', 'dd-mon-rr') study_end_date
6 from dual union all
7 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
8 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
9 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
10 select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
11 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
12 select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
13 ) -- actual query:
14 select study_key
15 , phase_start_date
16 , measurement_date_taken
17 , study_end_date
18 from t
19 union all
20 select study_key
21 , phase_start_date
22 , measurement_date_taken + level -- or rownum
23 , study_end_date
24 from ( select study_key
25 , phase_start_date
26 , measurement_date_taken
27 , study_end_date
28 , add_up
29 from (
30 select study_key
31 , phase_start_date
32 , measurement_date_taken
33 , study_end_date
34 , study_end_date - max(measurement_date_taken) over (partition by study_key
35 order by measurement_date_taken ) add_up
36 , lead(measurement_date_taken) over (partition by study_key
37 order by measurement_date_taken ) last_rec
38 from t
39 )
40 where last_rec is null
41 )
42 where rownum <= add_up
43 connect by level <= add_up;
STUDY_KEY PHASE_START_DATE MEASUREMENT_DATE_TA STUDY_END_DATE
1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
9 rijen zijn geselecteerd.If there's a simpler way (in SQL), I hope others will join and share their example/ideas/thoughts.
I have a feeling that this is using more resources than needed.
But I've got to cut the daisies first now, they interfere my 'lawn-green-ess' ;) -
Passing of internal table values to the select statement as SETS
Hi All,
Is there any way that i can restrict the values of a internal table to be passed to a select statement set by set..
say for eg: if a itab has 1000 entries i want the first 500 to be going out in a select statement as a comparision for all entries and then the next set of 500 to go out..
Please let me know.. this is very urgent..<b>Appending Several Lines</b>
You can also append internal tables to index tables using the following statement:
APPEND LINES OF <itab1> TO <itab2>.
This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
When you append an index table to another index table, you can specify the lines to be appended as follows:
APPEND LINES OF <itab1> [FROM <n1>] [TO <n 2>] TO <itab2>.
<n 1 > and <n 2 > specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
Then u can use <b> FOR ALL ENTRIES</b> in select query.
regards
vinod -
Question on Updating the rows of a table using a SELECT Statement
Hi,
I am trying to set all of the R_IDs in one table to the ID from another table using a join.
Here is the SQL I came up with. I don't this is correct though.
UPDATE TABLEA A
SET R_ID=(Select Id from TABLEB B
WHERE A.DEE=B.DEE AND
B.RNUM=1);
Does this make sense?You can try the join view.
UPDATE ( SELECT table_a.id AS a_id,
table_b.id AS b_id,
table_a.col1 AS a_col1,
table_b.col1 AS b_col1,
table_a.col2 AS a_col2,
table_b.col2 AS b_col2,
table_a.col3 AS a_col3,
table_b.col3 AS b_col3
FROM table_a,
table_b
WHERE table_a.id = table_b.id)
SET a_col1 = b_col1,
a_col2 = b_col2,
a_col3 = b_col3;
However it may result in
ORA-01779: cannot modify a column which maps to a non key-preserved tableThis is because the key-preserving property of a table does not depend on the actual data in the table. It is, rather, a property of its schema. For example, if in table_b there was at most one record for each id value, then table_a.id would be unique in the result of a join of table_a and table_b, but table_a would still not be a key-preserved table. By adding the unique/primary key on the id column of table_b we can assure that if table_b.id were part of the result set of the join view then it would be unique. This makes table_a key preserved.
Thus, in order to update a join view we must assure that the columns involved in the join view from the source table are unique. We do this by creating a unique or primary key on those columns.
However, if you do not mind taking responsibility for making sure that there is one-to-one cardinality between the source and destination rows, then you might try the correlated subquery
UPDATE table_a
SET (col1, col2, col3 ) =
( SELECT col1, col2, col3
FROM table_b
WHERE table_b.id = table_a.id )
WHERE EXISTS
( SELECT col1, col2, col3
FROM table_b
WHERE table_b.id = table_a.id ) -
Adding one more participant to approve the task in workflows
Hi All,
I'm having a requirement of adding the adding one more workflow user for approving the task. How to add one more workflow user in the human and allow him to approve the task which has been already approved by another workflow user, means it is hierarchical approval.
First the task has been approved by assignee then finally the task has been approved by the approver who has admin rights.
Regards,
CHHi,
I have added the users but i need to approve the same task for twice then it is propagating the data to the other end. Is there any hierarchy that we have to
define for the user inside human task.
Everytime I'm approving the request for twice. How to approve the request for only one time.
Regards,
CH -
Is it Possible to join 4 or more tables in a Select Statement?
Hello guys,
Can I do Inner Join 4 or 5 tables in a select statement?U HAVE TO SERCH FOR KEY FIELD FOR THAT . MEANS HOW TABELS ARE RELATED EACH OTHE FOR THIS U ALSO USE SQ02
FOR EXAMPLE
SELECT bkpf~belnr
bkpf~gjahr
bkpf~bukrs
bkpf~blart
bkpf~bldat
bkpf~budat
bkpf~usnam
bkpf~tcode
bkpf~xblnr
bsik~lifnr
bsik~bupla
bsik~secco
INTO CORRESPONDING FIELDS OF TABLE itab_pur
FROM bkpf INNER JOIN bsik
ON bkpfbelnr = bsikbelnr
and bkpfbukrs = bsikbukrs
WHERE bkpf~bukrs IN co_code
AND bkpf~budat IN pos_dt
AND bkpf~tcode IN t_code
AND bsik~secco IN se_code.
U CAN ALSO ADD MORE TABLE BASED ON CONDITION -
Case sensitive statement in the select-statement
Hi All,
i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
table-name_column like 'some_name'
I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
Do someone has an other proposal?check...
Select statement
It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
If in your system there are only stored in either caps or small the you can perform the select twice .
But i myself dont find it to be such a good solution , but you can give it a try
There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field -
Can call a function in the select statement?
Is there any ways to call a function in the select statement?
what I like to do is this:
select deptno, totalEmployees(deptno), TotalSalary(deptno)
from emp;
I know it can be done by count(*) and join tables, but my case
is much more complex and the where clauses are different from
one function to another, and have many tables to join and many
combinations
ThanksFunctions can be used in a select statement subject to certain
restrictions, see
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
server.817/a85397/statem9b.htm#2062024
It's under "CREATE FUNCTION> Keywords and Parameters> function>
Restrictions on User-Defined Functions"
Here is an except...
When a function is called from within a query or DML statement,
the function cannot:
a) Have OUT or IN OUT parameters
b) Commit or roll back the current transaction, create or roll
back to a savepoint, or alter the session or the system. DDL
statements implicitly commit the current transaction, so a user-
defined function cannot execute any DDL statements.
c) Write to the database, if the function is being called from a
SELECT statement. However, a function called from a subquery in
a DML statement can write to the database.
d) Write to the same table that is being modified by the
statement from which the function is called, if the function is
called from a DML statement.
Except for the restriction on OUT and IN OUT parameters, Oracle
enforces these restrictions not only for the function called
directly from the SQL statement, but also for any functions that
function calls, and on any functions called from the SQL
statements executed by that function or any function it calls. -
Oracle Error while execute the Select statement
Hi all,
I have two database, from one databse to another datadase, i am not able get value. while i am generating the select statement in one database, it throws an
error ORA-00942: table or view does not exist.
For this, what i have to do.can anyone post more detail on this.
Any idea?Please do not create duplicate threads.
ORA-00942: table or view does not exist -
How to test the select statement.
Hi All,
How to test the select statement.
Is there any Oracle sqlplus or toad kind of tool to test the query.
thanks
sivaUse SQL Trace (ST05) and choose 'Explain one SQL Request'. Enter your SQL command as it should be executed in the underlying database. e.g. if the db is Oracle, the statement should be entered as:
SELECT matnr,werks,lvorm,dispo
FROM marc
WHERE mandt = :a AND
matnr = :b AND
werks = :c
In the above :a, :b and :c are place holders for the actual comparison values. You dont have to enter those values. When you choose 'Explain' button, you will find the 'Execution Plan'. The important parameter which denotes the efficiency of the SQL statement is the 'Cost'. The cost should be as low as possible. The table access should be through INDEX UNIQUE SCAN. If you get a FULL TABLE SCAN and higher cost, you need to fine-tune your statement by modifying the where clause.
If you dont know Oracle SQL statements, execute the program in trace mode and go to the trace and you will find the underlying SQL statements issued to the database.
Regards
Suresh Radhakrishnan
Maybe you are looking for
-
Trouble using a function in the where clause
Hello, I am using a function found at ask.tom.oracle.com which converts a long data type to a character. The function is returning an error when it is placed in the where clause. The sql statement , error message and the function from ask tom are sho
-
Too many calls to retrieveRefCursor
Greetings, I've implemented a programmatic ViewObject that is populated with the results of an Oracle REF_CURSOR returned by a PL/SQL Store Procedure as an out variable (twisted, right?) My problem is that, in a simple page with only the table of thi
-
Cannot Access Shortcut Menu for Adding Input/Output in Formula Node
This is a wierd problem. I cannot access the shortcut menu in formula node. I right click the border, nothing happens. Anyone run into this before? Is there any other way to add inputs and outputs? I am running Vision Builder AI and want to use a for
-
Very slow workflow in loghtroom 4.1
Good day to everybody, I'm writing this especially for adobe because I'm very frustrated with the workflow in adobe Lightroom 4 and 4.1. So the main problem is that I have a powerful computer: 3,3 GHz X 6 cores, 8 Giga of DDR 3, a 260 GTX Nvidia card
-
Org. value sync job in ERM
Hello experts, Scenario: Our backend system consist HR component, but we do not use it and therefore do not want to implement the HR RTA So my question is, Is it possible to skip the HR contents for the org. value sync job in ERM? As we encounter err