Professional Documents
Culture Documents
Database Access: Kaavian Systems
Database Access: Kaavian Systems
Database Access: Kaavian Systems
Kaavian Systems
Agenda
What to access
Why to access
How do we access
Kaavian Systems
02-Sep-09
Kaavian Systems
Keyword
Function
SELECT
INSERT
UPDATE
MODIFY
DELETE
OPEN
CURSOR,
FETCH,
CLOSE
CURSOR
<target>
<source>
[WHERE <condition>]
[GROUP BY <fields>]
[HAVING
<cond>]
[ORDER BY <fields>]
Kaavian Systems
Reading Data
Kaavian Systems
Defining Selection
Reading a Single Line :
SELECT SINGLE <cols> WHERE
Reading Several Lines :
SELECT [DISTINCT] <cols> WHERE
Reading the Whole Line :
SELECT <lines> *
Kaavian Systems
Defining Selection
Reading Aggregate Data for Columns :
SELECT <lines> <agg> ([DISTINCT] <S1>
Aggregate functions:
MAX: returns the Maximum value of the Column<Si>
MIN : returns the Minimum value of the Column <Si>
AVG : returns the average value of the Column <Si>
SUM : returns the sum value of the Column <Si>
COUNT : returns the total number of lines in the selection
Kaavian Systems
Defining Selection
INTO clause
INTO wa
INTO CORRESPONDING FIELDS OF wa
INTO (f1,,fn)
INTO TABLE itab
INTO CORRESPONDING FIELDS OF TABLE itab
APPENDING TABLE itab
APPENDING CORRESPONDING FIELDS OF
TABLE itab
Kaavian Systems
10
Defining Selection
FROM Clause
FROM dbtab [AS alias]
FROM (dbtabname)
FROM <tab> [INNER] JOIN <dbtab> ON <cond>
<options>
FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS
<alias>]
ON <cond> <options>
CLIENT SPECIFIED
BYPASSING BUFFER
UPTO n ROWS
Kaavian Systems
11
Inner Join
02-Sep-09
Kaavian Systems
12
Example
Kaavian Systems
13
Defining Selection
FOR ALL ENTRIES IN itab WHERE cond
The comparison is performed for each line of the internal
table. For each line, the system selects the lines from the
database table that satisfy the condition. If <itab> is
empty, the addition FOR ALL ENTRIES is disregarded,
and all entries are read.
14
Subqueries
SELECTSINGLE city latitude longitude
Kaavian Systems
15
16
Changing Lines
<cond>]
[WHERE
17
Modifying Lines
Kaavian Systems
18
Deleting Lines
Deleting single line
DELETE <dbtab> FROM <wa>
DELETE dbtab
Kaavian Systems
19
ROLLBACK WORK
Undoes all changes back to the start of the database LUW
Kaavian Systems
20
Performance
Keep the Result Set Small
Minimize the Amount of Data Transferred
Minimize the Search Overhead
Reduce the Database Load
Kaavian Systems
21
Kaavian Systems
22
Kaavian Systems
23
Kaavian Systems
24
Kaavian Systems
25
26
Scenario
Retrieve all the Sales orders in the current
year (eg 2004) where
Sales order is of type OR
The value of the order is more than $1000.00
The number of line items are more than 2
And the sales order does not contain material M-11
Kaavian Systems
27
Reference
The learning material contained in this PowerPoint Presentation is
prepared with the help of http://help.sap.com/ and sap press book. All
rights reserved by SAP AG.
Unless otherwise specifically stated, this learning material is intended
for the sole purpose of class room session, internal use and for
knowledge transfer to the Consultants.
However, for detailed information on this learning
http://help.sap.com / sap press book may be referred.
material,
Kaavian is not liable for any legal liability or responsibility for the
accuracy, completeness or usefulness of any information disclosed in
these learning materials.
No portion of the learning materials shall be modified, reproduced or
transmitted in any form by any means, whether by electronic,
photocopier or otherwise without the written permission of Kaavian. In
no event shall Kaavian be liable for any damage whatsoever resulting in
any action arising in connection with the use of learning material.
Kaavian Systems
28
Discussion
Kaavian Systems