Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {seq, altPrio, optPrio, Expression, ver, starPrio, AlsoIn, verNotLang} from "../combi";
import {SQLFrom, SQLCond, SQLClient, SQLGroupBy, SQLHaving, SQLForAllEntries,
DatabaseConnection, SQLHints, SQLOptions, SQLPrivilegedAccess, SQLOrderBy} from ".";
import {Release, LanguageVersion} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
import {SQLFieldListLoopGreedy} from "./sql_field_list_loop_greedy";
import {SQLFieldsLoop} from "./sql_fields_loop";
import {SQLUpTo} from "./sql_up_to";
import {SQLSource} from "./sql_source";
import {SQLSetOpGroup} from "./sql_set_op_group";
export class SelectCTE extends Expression {
public getRunnable(): IStatementRunnable {
const where = seq("WHERE", SQLCond);
const bypass = "BYPASSING BUFFER";
const privileged = ver(Release.v758, SQLPrivilegedAccess);
const offset = ver(Release.v751, seq("OFFSET", SQLSource));
const conn = optPrio(verNotLang(LanguageVersion.KeyUser, DatabaseConnection));
const groupHaving = seq(optPrio(SQLGroupBy), optPrio(SQLHaving));
const tail = seq(
groupHaving,
optPrio(seq(SQLOrderBy, optPrio(SQLUpTo), optPrio(offset))),
optPrio(SQLHints),
optPrio(privileged),
optPrio(SQLOptions),
conn,
);
const sqlStyle = seq(
SQLFrom,
optPrio(SQLClient),
optPrio(bypass),
ver(Release.v750, SQLFieldsLoop, {also: AlsoIn.OpenABAP}),
optPrio(SQLForAllEntries),
optPrio(where),
tail,
);
const abapStyle = seq(
optPrio("DISTINCT"),
SQLFieldListLoopGreedy,
SQLFrom,
optPrio(SQLClient),
optPrio(bypass),
optPrio(SQLForAllEntries),
optPrio(where),
tail,
);
const union = seq("UNION", optPrio(altPrio("DISTINCT", "ALL")));
const intersectExcept = altPrio(seq("INTERSECT", optPrio("DISTINCT")),
seq("EXCEPT", optPrio("DISTINCT")));
const setOp = altPrio(ver(Release.v750, union, {also: AlsoIn.OpenABAP}),
ver(Release.v756, intersectExcept));
const operandSql = seq(SQLFrom, optPrio(SQLClient), optPrio(bypass), ver(Release.v750, SQLFieldsLoop, {also: AlsoIn.OpenABAP}),
optPrio(SQLForAllEntries), optPrio(where), groupHaving);
const operandAbap = seq(optPrio("DISTINCT"), SQLFieldListLoopGreedy,
SQLFrom, optPrio(SQLClient), optPrio(bypass), optPrio(SQLForAllEntries),
optPrio(where), groupHaving);
const operandCore = altPrio(operandSql, operandAbap);
const unionOperand = altPrio(SQLSetOpGroup, seq("SELECT", operandCore));
const unionTail = starPrio(seq(setOp, unionOperand));
const selectBody = seq("SELECT", altPrio(sqlStyle, abapStyle));
return seq(selectBody, unionTail);
}
}
|