Select where Bedingung mit @

Getting started ... Alles für einen gelungenen Start.
3 Beiträge • Seite 1 von 1
3 Beiträge Seite 1 von 1

Select where Bedingung mit @

Beitrag von Niels (ForumUser / 77 / 18 / 9 ) »
Hallo zusammen,

ich habe jetzt schon öfters Selectanweisungen gesehen in denen mit einem @ in der where Bedingung gearbeitet wurde.

Kann mir wer erklären wofür dieses @ genau ist und was dies bewirkt?

Hier ein kleines Beispiel welches ich im Forum gefunden habe.
Ralf Wenzel hat geschrieben:

Code: Alles auswählen.

SELECT scarr~carrname, spfli~connid, sflight~fldate 
INTO CORRESPONDING FIELDS OF TABLE @itab FROM ( ( scar 
INNER JOIN spfli 
  ON spfli~carrid   = scarr~carrid 
  AND spfli~cityfrom = @p_cityfr 
  AND spfli~cityto   = @p_cityto ) 
INNER JOIN sflight 
  ON sflight~carrid = spfli~carrid 
  AND sflight~connid = spfli~connid ). 
Vielen Dank schon mal

Gruß

Niels

gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Re: Select where Bedingung mit @

Beitrag von Thomas R. (Expert / 755 / 78 / 34 ) »
Hallo Niels,
das ist die neue "striktere" OPEN-SQL-Syntax - Unterscheidung von Datenbank- und "Hostvariablen"(Programmvariablen).

MfG
Thomas R.

Re: Select where Bedingung mit @

Beitrag von black_adept (Top Expert / 4086 / 126 / 940 ) »
Hallo Niels,

die Antwort von Thomas ist die "kurze" Antwort.
Falls du gerade kein 7.40 SP5 oder höheres System zur Verfügung hast, hier die Änderungen in der "ABAP-Neuheiten" Doku, die man aus dem Editor erreichen kann:

Für die Beantwortung deiner Frage: Punkt 2.
SAP_DOKU hat geschrieben:Open SQL in Release 7.40, SP05

1. Comma-separated lists

2. Escape character for host variables

3. SQL expressions

4. Switching automatic client handling

5. Rule changes for joins

6. Evaluating INTO CORRESPONDING

7. Access to CDS views

8. Stricter checks for syntax rules

9. Strict mode in the syntax check


Modification 1

Comma-Separated Lists



In Open SQL, all operands in lists can now be separated by commas and this is also the recommended way of separating them from Release 7.40, SP05. Until now, comma-separated lists could only be used when single target fields were specified in parentheses after INTO in SELECT and when data objects were specified in parentheses after WHERE. Comma-separated lists are now also possible in Unicode programs where the program attribute fixed point arithmetic is activated:
• In the statement SELECT

◦When columns, aggregate expressions, or SQL expressions are specified in the SELECT list
◦When columns are specified after GROUP BY
◦When columns are specified after ORDER BY
• In the statement UPDATE

◦When change expressions are specified after SET

This makes blank-separated lists obsolete. If one of these lists is separated by commas, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

The constraint that blanks were forbidden after the opening parenthesis in comma-separated lists after INTO and IN if more than one comma occurs (if more than one data object is specified) no longer applies from SP05.





Modification 2

Escape Character for Host Variables



ABAP data objects used in Open SQL statements (usually variables) are now interpreted as host variables, as in statically embedded Native SQL. From Release 7.40, SP05, host variables can and should be prefixed with the escape character @. Host variables without the escape character are obsolete. If the escape character is used in front of a name of an Open SQL statement, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

The escape character can only be used in Unicode programs, in which the program property fixed point arithmetic is activated. Using the escape character requires a strict syntax check of the complete statement. During this check, any errors that would normally only be displayed as syntax warnings are reported as syntax errors.





Modification 3

SQL Expressions



From Release 7.40, SP05, SQL expressions can be specified in a comma-separated SELECT list. The result of an expression of this type (whose operands can be the names of columns or host variables) is determined by the database system and passed to the application server in the appropriate column of the results set.

SQL expressions can only be used in Unicode programs, in which the program attribute fixed point arithmetic is activated. If SQL expressions are used, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.





Modification 4

Switching Automatic Client Handling



The new addition USING CLIENT clnt, which can be specified in all Open SQL statements as an alternative to CLIENT SPECIFIED, switches automatic client handling to the client specified in clnt.

When the addition USING CLIENT is used, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.





Modification 5

Rule Changes for Joins



The following previous constraints on joins have been lifted:
• From Release 7.40, SP05, it is no longer the case that all comparisons of the ON condition must contain a column from a database table or view on the right side as an operand.


• From Release 7.40, SP05, the right side of a join expression is no longer restricted to single tables or views. The right side can itself be a (parenthesized) join expression whose results set is then evaluated.


• In Release 7.40, SP05 and higher, LEFT OUTER JOIN and RIGHT OUTER JOIN can be used., ,


• From Release 7.40, SP05, fields from the right side in the WHERE condition of the current SELECT statement can be specified in LEFT OUTER JOIN. Fields from the left side can be specified in RIGHT OUTER JOIN.


In SELECT statements that exploit the rule changes above, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.





Modification 6

Evaluating INTO CORRESPONDING



If all required components are statically identifiable, the assignment of the fields in the addition CORRESPONDING after INTO is now determined when the program is generated and is not delayed until runtime.

The addition INTO CORRESPONDING now affects the results set defined in the SELECT list. If one or more names match, all the columns for which there are no name matches are removed from the results set. If there are no name matches, none of the columns are removed from the results set.





Modification 7

Access to CDS Views



SELECT can be used to access CDS views, which have been defined with the DDL of the ABAP CDS by using DEFINE VIEW.

Automatic client handling is performed for client-specific CDS views. If this handling is deactivated with addition CLIENT SPECIFIED, the client column is part of the results set, even though the column is not an element of the CDS view. The new addition CLIENT SPECIFIED of statement TYPES can be used to declare a suitable target area. New additions for CLIENT SPECIFIED after FROM make it possible to address the column in the SELECT statement.

If the real name cdsViewName is used for accesses (as recommended), the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.





Modification 8

Stricter Checks on Syntax Rules



In Release 7.40, SP02, a new SQL parser was introduced for Open SQL. These parser performs stricter checks on some rules than the old parser. More specifically, the same parser is now used for statically specified Open SQL and for the content of dynamic tokens. In Release 7.40, SP02, this parser will initially only be used for the statement SELECT. From Release 7.40, SP05, the new parser will be used for all Open SQL statements. One consequence of this is that any following syntax constructs that have always contained errors now produce syntax errors or runtime errors.
•Corrections for the WHERE Condition
All corrections in Release 7.40, SP02 that apply to the WHERE condition now also apply to the statements DELETE, OPEN CURSOR, and UPDATE from Release 7.40, SP05.

Example

From Release 7.40 SP05, syntax errors for:

DELETE FROM spfli WHERE NOT NOT carrid = 'LH'. •Corrections for dynamic tokens
All corrections in Release 7.40, SP02 that apply to dynamic tokens now also apply to all Open SQL statements from Release 7.40, SP05.

Example

From Release 7.40 SP05, exception for:

DELETE FROM (`SPFLI .`) WHERE (`. CARRID = 'LH'`). •Correction for OPEN CURSOR
The addition WITH HOLD of the statement OPEN CURSOR can be used only in reads performed on the standard database. If the addition CONNECTION is specified at the same time, a runtime error was produced before Release 7.40 SP05 (and not a syntax error), if the database table was specified dynamically. This gap was closed in Release 7.40 SP05.

Example

From Release 7.40 SP05, syntax errors for:

OPEN CURSOR WITH HOLD cursor
FOR SELECT *
FROM ('SPFLI') CONNECTION con.




Modification 9

Strict Mode in the Syntax Check



If one the new features listed here is used in an Open SQL statement, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.








Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag (Insgesamt 2):
iboNiels

live long and prosper
Stefan Schmöcker

email: stefan@schmoecker.de

Seite 1 von 1

Vergleichbare Themen

2
Antw.
2067
Views
Frage zu Bedingung im SELECT
von Zwenn » 29.07.2008 08:03 • Verfasst in ABAP® für Anfänger
3
Antw.
9374
Views
Select mit itab in where-Bedingung
von fcmfanswr » 14.07.2011 10:29 • Verfasst in ABAP® Core
5
Antw.
3309
Views
SO in SELECT-Anweisung mit dynamischer Where-Bedingung
von Marcus » 08.10.2005 17:49 • Verfasst in ABAP® Core
8
Antw.
12363
Views
dynamische Where -Bedingung mit Select-Option
von BesenWesen » 21.08.2006 12:12 • Verfasst in ABAP® für Anfänger
1
Antw.
5307
Views
Loop mit Select-Options in der Where-Bedingung
von made » 11.11.2005 09:12 • Verfasst in ABAP® für Anfänger

Über diesen Beitrag


Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.

Unbeantwortete Forenbeiträge

Daten an Tabelle binden
vor 10 Stunden von Bright4.5 1 / 207
aRFC im OO-Kontext
vor 4 Wochen von ralf.wenzel 1 / 1849
Hilfe bei SWEC/SWE2
letzen Monat von retsch 1 / 8451