Extract text from a SQL Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract text from a SQL Script
# 1  
Old 01-06-2012
Extract text from a SQL Script

Hi All,

I want to extact text which start with "Group" case insenstive and end with ";" and in between there should be "partition"(case insenstive) .

I write a script, but that script also giving me FILE2.txt and file3.txt as outputs. I shouldn't get anything from file2 and file3. Beacuse in file 2 and 3, these keyword are part of two different queries. Not part of one SQL.

file1.txt

Code:
Sel
;
1
2
3
4
5
6
7
8
9
10
update benchmark_app.dropme4
from
(sel a.empid from
benchmark_app.dropme3 a
GROUP by 1
QUALIFY row_number() over (partition by a.empid order by a.managername desc) = 1) c
set empid4 = c.empid
where 
benchmark_app.dropme4.empid4 = c.empid
;

file2.txt

Code:
sel empno
  ,name
from emp
partition
;

file3.txt

Code:
sel empno
   ,ename
  ,partition by 
from  emp
group by 1,2
;

sel empno
   ,ename
from emp
partition
;

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 01-06-2012 at 05:02 PM.. Reason: code tags, please!
# 2  
Old 01-06-2012
You already have a topic on this.

I even posted suggestions in it a little while ago, and asked you a question you still haven't answered even in this new topic.

Please don't crosspost.

Please don't register multiple accounts to try and get away with crossposting.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substr/Instr in shell script or extract part of text

Hi, I need to extract part of a text to two variables text is "PL/SQL procedure successfully completed. ERROR ----------------------------------------------------------------- Test Error Message PLUSVAR ---------- 1" I want "Test Error Message" in one variable and "1" in another variable.... (11 Replies)
Discussion started by: vedavrath
11 Replies

2. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies

3. Shell Programming and Scripting

Script extract text from txt file with grep

All, I require a script that grabs some text from the gitHub API and will grep (or other function) for a string a characters that starts with (") quotes followed by two letters, may contain a pipe |, and ending with ) . What i have so far is below but it's not returning anything. ... (4 Replies)
Discussion started by: ChocoTaco
4 Replies

4. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

5. Shell Programming and Scripting

Perl script to extract text from image file

Hi Folks, Could you please share your ideas on extracting text from image file(jpg,png and gif formats). Regards, J (1 Reply)
Discussion started by: scriptscript
1 Replies

6. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

7. Shell Programming and Scripting

How to extract the sql from file?

Hi Firends I have this type of file Rows read = 4823832 Statement text = SELECT QUEUE, REPLY_QUEUE, REPLY_QMGR FROM HUB_REF.CORNERSTONE.HUB_REF_QUEUE AS RQ WHERE (RQ.SERVICE_NAME = 'modifyParty' OR RQ.SERVICE_NAME = '*') AND RQ.SERVICE_TYPE =... (1 Reply)
Discussion started by: atul9806
1 Replies

8. Shell Programming and Scripting

script to parse text file into sql commands

Hello all, I tried searching for something similiar before posting but couldn't come up with anything that fit what I need. In Linux, I'm trying to parse through a number of files and take the info in them and put it into mysql. My file is a dump from an expect script: ---filename... (3 Replies)
Discussion started by: hamanjam
3 Replies

9. Shell Programming and Scripting

How to extract WHERE clause from a SQL using UNIX???

Hi, I need to know how to extract entire WHERE clause from a SQL statement using UNIX command. For example: If following is the SQL then how to extract entire WHERE clause: UPDATE <TABLE_NAME_1> SET <FIELD_NAME> = VALUE WHERE CONDITION_1 AND CONDITION_2 = (SELECT FIELD_NAME FROM... (15 Replies)
Discussion started by: ustechie
15 Replies

10. Shell Programming and Scripting

Need to extract .sql files

Hi, I am trying to extract all .sql files present in a particular directory and its sub directories. How can i do this using shell script or awk? any help would be earnestly appreciated. thanks. (1 Reply)
Discussion started by: sprinleo
1 Replies
Login or Register to Ask a Question