 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[10.0.158 BETA] - Formatting issues 2 |
|
I've run into difficulties when trying to incorporate the INTO part of a SELECT statement into my SELECT rules.
Given is the following code:
 |
 |
SELECT a._year, a._quarter, a._source_name, a._db_name, a._path, a.drop_db_stmt, a.create_db_stmt, a.create_tab_stmt, a.index_stmt, a.xfer_stmt, a.remove_stmt FROM @archives AS a ORDER BY a._year, _quarter;
|
and the following two rules:
#1
 |
 |
SELECT ... AS ..., ... = ...
INTO ...
FROM ... AS ..., ... JOIN ... ON ... = ... AND ... OR ... WHERE ... = ... AND ... OR ... GROUP BY ..., ... HAVING ..., ... ORDER BY ..., ...;
|
and #2 which is a slightly modified version of the factory default (also, note that it is missing the INTO part)
 |
 |
SELECT
... AS ...
,... = ...
FROM
... AS ...
,...
JOIN
...
ON ... = ...
AND ...
OR ...
WHERE ... = ...
AND ...
OR ...
GROUP BY
...
,...
HAVING
...
,...
ORDER BY
...
,...
;
|
Passing the above one-liner through #1 only drops the closing ; to the next line, which clearly is not the desired output.
 |
 |
SELECT a._year, a._quarter, a._source_name, a._db_name, a._path, a.drop_db_stmt, a.create_db_stmt, a.create_tab_stmt, a.index_stmt, a.xfer_stmt, a.remove_stmt FROM @archives AS a ORDER BY a._year, _quarter
;
|
Allowing this (or the original one-liner) through #2 will give this:
 |
 |
SELECT
a._year
,a._quarter
,a._source_name
,a._db_name
,a._path
,a.drop_db_stmt
,a.create_db_stmt
,a.create_tab_stmt
,a.index_stmt
,a.xfer_stmt
,a.remove_stmt
FROM
@archives AS a
ORDER BY
a._year
,_quarter
;
|
Now throwing this left-over to #1 again just makes a greater mess:
 |
 |
SELECT a._year, a._quarter, a._source_name, a._db_name, a._path, a.drop_db_stmt, a.create_db_stmt, a.create_tab_stmt, a.index_stmt, a.xfer_stmt, a.remove_stmt
FROM
@archives AS a
ORDER BY
a._year, _quarter
;
|
Removing the INTO ... from the rule will force it to behave as expected.
 |
 |
SELECT a._year, a._quarter, a._source_name, a._db_name, a._path, a.drop_db_stmt, a.create_db_stmt, a.create_tab_stmt, a.index_stmt, a.xfer_stmt, a.remove_stmt
FROM @archives AS a ORDER BY a._year, _quarter;
|
Of course, that ruins codes containing INTO in exchange. Also adding INTO to the #2 rule makes it screw INTO-less code. I've tried to have two SELECT rules, one with INTO and one without but it doesn't seem to work.
Shouldn't all the non-first keywords regarded as optional and only used as anchors? Any hints on how to get the best of both worlds?
|
|
Wed Aug 29, 2018 12:33 pm |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
I also have a rule for IF BEGIN:
 |
 |
IF ... AND ... OR ...
BEGIN
<stmtList>;
END
|
Using this with #2 yields the expected result:
 |
 |
IF @debug > 0
BEGIN
SELECT
a._year
,a._quarter
,a._source_name
,a._db_name
,a._path
,a.drop_db_stmt
,a.create_db_stmt
,a.create_tab_stmt
,a.index_stmt
,a.xfer_stmt
,a.remove_stmt
FROM
@archives AS a
ORDER BY
a._year
,_quarter
;
END
|
However, #1 breaks even this one:
 |
 |
IF @debug>0
BEGIN
SELECT a._year, a._quarter, a._source_name, a._db_name, a._path, a.drop_db_stmt, a.create_db_stmt, a.create_tab_stmt, a.index_stmt, a.xfer_stmt, a.remove_stmt
FROM @archives AS a ORDER BY a._year, _quarter;END
|
|
|
Wed Aug 29, 2018 12:42 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|