Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: create a perl script for pattern matching

by Ben Win Lue (Friar)
on Jul 01, 2005 at 09:34 UTC ( #471617=note: print w/replies, xml ) Need Help??

in reply to create a perl script for pattern matching

It is rather easy to recognize a start of an SQL-Statement, because very few words are used. Mostly Select, Update, Insert or Delete and very few other words.
The problem is to recognize the end of the Statement. Are there semicola (";") at the end?
The rest is as easy as shown by holli.
  • Comment on Re: create a perl script for pattern matching

Replies are listed 'Best First'.
Re^2: create a perl script for pattern matching
by VSarkiss (Monsignor) on Jul 01, 2005 at 14:20 UTC

    Slightly OT, but

    It is rather easy to recognize a start of an SQL-Statement
    Is it? Here are some random snippets from past code I've written.

    select max(prod_id) from product where effdt = (select max(effdt) from product)
    insert order (prod_id, prod_cnt) select prod_id, count(*) from product group by prod_id
    How many statements was that? In fact it's two, but if you just count keywords, you'll get four.

    The point is not to underestimate the tasks that faces the OP. Trying to make it work by just matching keywords gets the wrong answer against normal, everyday SQL very easily. SQL has a definite grammar that's precise, but it's not easy to parse thru. Additional difficulty comes from recognizing all the vendor-specific extensions to the language, but let's not go into that. :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://471617]
[erix]: hey planetscape :)
[planetscape]: howdy stonecolddevin, erix
[Sinistral]: eric Aye. I thought I typed that wrong. All hail Randall! I listen to him on FLOSS Weekly
[Discipulus]: i think his vacuus, trombon like, absence of meaning, joined with a ostentatious style, after many years irritates the most
[erix]: easy to get wrong -- I guess that was sund's point, too :P
[Discipulus]: planetscape welcome back! (or is well comeback?)
[Discipulus]: fore every 2 good old monks that come back, we will accept 1 clinical
[planetscape]: Might be "well, come back!" Discipulus ;-)
[stonecolddevin]: that's a 2.0 k/d ratio, i'll take it

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2017-06-22 21:00 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (530 votes). Check out past polls.