IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Parsing SQLServer SQL/ENDSQL on v6.2, Fails if AND or OR at end of line
Marlon
post 17 Jun 2010, 15:00
Post #1


Member
**

Group: Members
Posts: 15
Joined: 14-February 06
Member No.: 1,235



There's a bug in the parser for SQL/ENDSQL in 6.2.41 running on Windows against SQLServer.

This will fall over with an SQL error

SQL
SELECT * FROM <TABLE>
WHERE :$ABC = 'Y'
OR
:$ABC = 'X'
ENDSQL

whereas this won't:

SQL
SELECT * FROM <TABLE>
WHERE :$ABC = 'Y'
OR
(:$ABC = 'X')
ENDSQL

and neither will this:

SQL
SELECT * FROM <TABLE>
WHERE :$ABC = 'Y'
OR :$ABC = 'X'
ENDSQL

The problem is the parser effectively produces
OR:$ABC = 'X'
instead of
OR<space>:$ABC = 'X'
when the OR (same for an AND) ends the line and the next line doesn't start with a bracket.

The version that fails on SQLServer works fine on Oracle.

ProIV accept it's a bug and hopefully it will be fixed.
Go to the top of the page
 
+Quote Post
CurtisZ
post 18 Jun 2010, 16:01
Post #2


Member
**

Group: Members
Posts: 15
Joined: 23-September 08
From: Seattle, Washington, USA
Member No.: 2,078



FYI - The following would probably be a good work-around

SQL
SELECT * FROM <TABLE>
WHERE :$ABC = 'Y'
OR :$ABC = 'X'
ENDSQL

Could be done as:

$X_STRING = ' OR ' + $ABC + ' = ' + CHAR(39) + 'X' + CHAR(39) + CHAR(32)

SQL
SELECT *
FROM <TABLE>
WHERE :$ABC = 'Y'
:$X_STRING
ENDSQL


Go to the top of the page
 
+Quote Post
Marlon
post 19 Jun 2010, 10:42
Post #3


Member
**

Group: Members
Posts: 15
Joined: 14-February 06
Member No.: 1,235



Hi,
There's no need for such an elaborate work-around. Just having the OR on the same line of logic as the :$ABC = 'X' works. The parser screws up when you have OR on one line and :$ABC = 'X' on the next line.

QUOTE(CurtisZ @ 18 Jun 2010, 17:01) *
FYI - The following would probably be a good work-around

SQL
SELECT * FROM <TABLE>
WHERE :$ABC = 'Y'
OR :$ABC = 'X'
ENDSQL

Could be done as:

$X_STRING = ' OR ' + $ABC + ' = ' + CHAR(39) + 'X' + CHAR(39) + CHAR(32)

SQL
SELECT *
FROM <TABLE>
WHERE :$ABC = 'Y'
:$X_STRING
ENDSQL

Go to the top of the page
 
+Quote Post
CurtisZ
post 21 Jun 2010, 20:47
Post #4


Member
**

Group: Members
Posts: 15
Joined: 23-September 08
From: Seattle, Washington, USA
Member No.: 2,078



QUOTE(Marlon @ 19 Jun 2010, 03:42) *
Hi,
There's no need for such an elaborate work-around. Just having the OR on the same line of logic as the :$ABC = 'X' works. The parser screws up when you have OR on one line and :$ABC = 'X' on the next line.


laugh.gif

Ah, okay, I slightly misunderstood the post then...
Go to the top of the page
 
+Quote Post
DARREN
post 21 Jul 2010, 14:01
Post #5


ProIV Guru
*****

Group: Members
Posts: 259
Joined: 6-December 00
From: Florida,USA
Member No.: 550



You also do not need to define the * in the SQL statement as the parser will work out the columns that you need. Defining the * tells PROIV to return all the columns for the rows, even if you are not using them in your function which can make it less efficient.

QUOTE(CurtisZ @ 21 Jun 2010, 20:47) *
QUOTE(Marlon @ 19 Jun 2010, 03:42) *
Hi,
There's no need for such an elaborate work-around. Just having the OR on the same line of logic as the :$ABC = 'X' works. The parser screws up when you have OR on one line and :$ABC = 'X' on the next line.


laugh.gif

Ah, okay, I slightly misunderstood the post then...


--------------------
Things should be made as simple as possible, but not simpler
Go to the top of the page
 
+Quote Post

Fast ReplyReply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 5th September 2010 - 17:06