consider the following is the contents of the file
cat 11.sql
drop procedure if exists hoop1 ;
Delimiter $$
CREATE PROCEDURE hoop1(id int)
BEGIN
END
$$
Delimiter ;
.
.
.
.
drop procedure if exists hoop2;
Delimiter $$
CREATE PROCEDURE hoop2(id int)
BEGIN
END
$$
delimiter ;
.
.
DROP VIEW IF EXISTS view1;
CREATE VIEW view1
AS
SELECT blah blah FROM blah etc etc
WHERE blah blah
GROUP BY id;
.
.
.
DROP VIEW IF EXISTS view2;
CREATE VIEW view2
AS
SELECT blah blah FROM blah etc etc
WHERE blah blah
GROUP BY id;
.
.
.
drop procedure if exists hoop3;
Delimiter $$
CREATE PROCEDURE hoop2(id int)
BEGIN
END
$$
Delimiter ;
its not working properly.. i want the all the procedures from CREATE PROCEDURES to Delimiter ( or it can be small case delimiter) in one file and also all views from CREATE VIEW to ";" which marks the end of that particular view in another file.... how to do this.. :-/ plz help :wall:
echo "`sed -n "/$firstword/,/;/ w viewextract.sql" < onlyviews1.sql`"
where firstword is CREATE VIEW some view name.. similarly procedure name....
now my doubt is consider i have two procedures of same name.. so when i execute this
echo "`sed -n "/$firstword/,/[dD]elimiter/ w extractproc.sql" < onlyproc1.sql`"
and if
cat onlyproc1.sql
CREATE PROCEDURE ABC(id int)
BEGIN
END
$$
Delimiter ;
CREATE PROCEDURE xyz(id int)
BEGIN
END
$$
Delimiter ;
CREATE PROCEDURE ABC(id int)
BEGIN
END
.
.
.etc
the sed command will write two procedures to the file extractproc.sql which are repeated.. is there any way to make sure the command takes only one procedure and writes it to the file...?
then extractproc.sql will have two procedures of same name... but i was the fle to have only one procedure...is there any way we could do it in one line... i could ofcourse do it using while loop by writing to another file till first procedure ends but its time consuming which leads to code inefficiency...