(SQL) Parser with Gupta

General discussion forum about all databases other than SqlBase.
anuta

(SQL) Parser with Gupta

Post by anuta » 26 May 2015, 09:31

Hi,

because SQL Server 2012 doesnt support the compatibility level 80 anymore,
I have to convert our dynamically created SQL-Queries from '89 into ANSI Syntax.

I mean the stuff like:

select * from A, B, C
where A.x *= B.y and A.z = 'ok' and C.user = 'Smith' and C.last_change = A.last_change

must on the fly, programmatically be reparsed into something like this:

select * from A left join B on A.x = B.y and A.z = 'ok' join C on 1=1
where C.last_change = A.last_change and C.user = 'Smith'

or

select * from A
left join B on A.x = B.y
and A.z = 'ok'
join C on C.last_change = A.last_change
and C.user = 'Smith'

Ok, it can be an option to use the Microsoft.SqlServer.Management.SqlParser.Parser. Dunno. But maybe - maybe I have to use the new logic for Oracle too (later, who knows?), and so i think it is better to realise it from scratch with Gupta directly. Unfortunately, string parsing abilities are very districted and funny there. For example, as I tried to use, absolute innocently, SalStrTokenize(sWhere, ' AND ') to roughly split my where clause into terms, what I got? The understanding that the aforementioned function only works with a single character as delimeter.

The question here is - does anybody had realized something like this or maybe already wrote some helpers for string processing in Gupta? Something like Sax or such?

Thanks in advance

Christof
Germany
Posts: 191
Joined: 06 Mar 2017, 07:27
Location: Frankfurt, Germany

Re: (SQL) Parser with Gupta

Post by Christof » 27 May 2015, 08:05

For string processing tasks I am mainly using an iterating tokenizer, which is supporting multiple characters as delimiter. Due to the internal use of SalStrScan(...), delimters are not being recognized case sensitive.

See the small sample file, which contains the tokenizer class and a tiny test class.
You do not have the required permissions to view the files attached to this post.

anuta

Re: (SQL) Parser with Gupta

Post by anuta » 28 May 2015, 08:22

Hallo Christof,

thank You a lot.

In a meantime, I did it per pedes. Was a pressing issue.I will try to replace some awful piece of code with Yours.

Greetings from Berlin

anuta

Re: (SQL) Parser with Gupta

Post by anuta » 28 May 2015, 10:38

witty

FRBhote
India
Posts: 2201
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Re: (SQL) Parser with Gupta

Post by FRBhote » 30 May 2015, 13:16

Do let us know when you figure out how to do it. We have the same problem.

anuta

Re: (SQL) Parser with Gupta

Post by anuta » 05 Jun 2015, 09:24

I have done it - quick and dirty (SQL syntax is only partially covered, but for our needs, that does it.)

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 1 guest