Sql script with regex

A

Ahmet Kilic

"INSERT INTO CBM_CT_BY_CLT ( "\
" CST_CD, "\
" BLK_REG_SEQ, "\
" BLK_REG_DT, "\
" DEL_FLG "\
") "\
"VALUES ( "\.........

how can I get the table name(CBM_CT_BY_CLT) and column name ( CST_CD
...) from this sql script?
It contains spaces and the script is line by line.
I am trying like this but it is no useless
columnname = text.scan(/"\s+(.*?)\s+"\\/)
please help...
 
P

Pascal J. Bourguignon

Ahmet Kilic said:
"INSERT INTO CBM_CT_BY_CLT ( "\
" CST_CD, "\
" BLK_REG_SEQ, "\
" BLK_REG_DT, "\
" DEL_FLG "\
") "\
"VALUES ( "\.........

how can I get the table name(CBM_CT_BY_CLT) and column name ( CST_CD
..) from this sql script?
It contains spaces and the script is line by line.
I am trying like this but it is no useless
columnname = text.scan(/"\s+(.*?)\s+"\\/)

You will have to write a SQL parser.

Of course, you may try to do a half-assed job with regular
expressions, but SQL is a language with a context-free grammar, so you
need a parser.
 
A

Ahmet Kilic

Pascal said:
You will have to write a SQL parser.

Of course, you may try to do a half-assed job with regular
expressions, but SQL is a language with a context-free grammar, so you
need a parser.

I think SQL parser is very deep for me.
I got it with regex. Thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top