Visit The New, Modern Unix Linux Community


Append a particular string after occurrence of particular string.


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Append a particular string after occurrence of particular string.
# 1  
Append a particular string after occurrence of particular string.

Hi Friends,

Good morning.

Appended a particular string after occurrence of particular string in a file.

my file abc.sql as below

Code:
create or replace  function f1(p_cust_no IN VARCHAR)
RETURN number IS
DECLARE
v_country country.customer_tbl%TYPE;	
    begin
    	begin
	    select country
	    into v_country
	    from customer_tbl;

exception
when others
then
bbk.createmsg(MST.notexisted(),'notexisted',p_cust_no);
pfg := false;
				
v_msgtext := bbk.createmsg(MST.isterminated(),
                                      'isterminated',
    	    	    	    	       v_gst,
    	    	    	    	       v_country,
                                      p_cust_no);
							  
pfg := false;				
			
 	    v_msgtext := bbk.createmsg(MST.isterminated(),
                                      'isterminated',
    	    	    	    	      v_cgst,
    	    	    	    	       v_country,
                                      p_cust_no);
								  
pfg := false;			

end;

In the given input file Where ever is bbk.createmsg existed in that after second occurrence of ",". Every thing should be appended with tstcre.noconvert().

The expected output would be

Code:
bbk.createmsg(MST.notexisted(),'notexisted',tstcre.noconvert(p_cust_no));

v_msgtext := bbk.createmsg(MST.isterminated(),
                                      'isterminated',
    	    	    	    	       tstcre.noconvert(v_gst),
    	    	    	    	       tstcre.noconvert(v_country),
                                      tstcre.noconvert(p_cust_no));
							  
v_msgtext := bbk.createmsg(MST.isterminated(),
                                      'isterminated',
    	    	    	    	      tstcre.noconvert(v_cgst),
    	    	    	    	       tstcre.noconvert(v_country),
                                      tstcre.noconvert(p_cust_no));

Please help me .
Thanks in advance.
# 2  
This is SQL for what database, exactly?
# 3  
Oracle DB
# 4  
And how do you intend to solve your issue to append some text in your file?
# 5  
We have to search for bbk.createmsg string.
Once it's found from there we have to search for second occurrence of ",".
After that Every string should be appended with tstcre.noconvert().

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #439
Difficulty: Easy
A graphics processing unit (GPU) is a specialized electronic circuit designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Last occurrence of a string

I apologize if it was asked before but I couldn't find something related. I want to replace 2 strings in a file e.g pwddb=Lar1wod (need to replace string after =) pwdapp=Wde2xe (need to replace string after =) AND in same file want to find last occurrence of a string (SR2-134561),... (2 Replies)
Discussion started by: J_ang
2 Replies

2. Shell Programming and Scripting

Find string in file and append new string after

Hi All, I'm trying to insert a string into a file at a specific location. I'd like to add a string after the parent::__construct(); in my file. <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function... (6 Replies)
Discussion started by: jjkilpatrick
6 Replies

3. Shell Programming and Scripting

Find a string occurrence if twice in a line

Hello All, I want to check if a delimiter is existing twice in a line of a text file. Suppose flat file is like this 234 | 123 123 | 345 456 | 563 | 234 | 548 So the the 3rd line has two delimiters, How can we find the lines in such a file having more then one delimiters I tried... (5 Replies)
Discussion started by: nnani
5 Replies

4. Shell Programming and Scripting

How to append string checking other same string?

Hi , I have a file likeA-0044150|ABC/Frito/ A-0044150|GFHU A-0150075|Bud Racing A-0187811|Bud Light A-0187811|RW&B signmaking I Want the o/p likeA-0044150|ABC/Frito/,GFHU A-0150075|Bud Racing A-0187811|Bud Light,RW&B signmaking (2 Replies)
Discussion started by: jagdishrout
2 Replies

5. Shell Programming and Scripting

How to append a string by comparing another string?

Hi , I have one file like BUD,BDL BUDCAR BUD,BDL BUDLAMP ABC,CDF,KLT ABISKAR ABC,CDF,KLT CORNEL ABC,CDF,KLT KANNAD JKL,HNM,KTY,KJY JAGAN JKL,HNM,KTY,KJY HOUSE JKL,HNM,KTY,KJY KATAK JKL,HNM,KTY,KJY KOLKA The o/p should be like BUD,BDL BUDCAR,BUDLAMP ABC,CDF,KLT... (4 Replies)
Discussion started by: jagdishrout
4 Replies

6. Shell Programming and Scripting

Append a searched string with another string using sed

Hi, I need to replace and append a string in a text if grep is true. For eg: grep ABC test.txt | grep -v '\.$' | awk {'print $4'} | sed "s/ ? How do I replace all instances of "print $4" using sed with another sring? Eg of the string returned will be, lx123 web222 xyz Want to... (8 Replies)
Discussion started by: vchee
8 Replies

7. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

8. Shell Programming and Scripting

remove characters from string based on occurrence of a string

Hello Folks.. I need your help .. here the example of my problem..i know its easy..i don't all the commands in unix to do this especiallly sed...here my string.. dwc2_dfg_ajja_dfhhj_vw_dec2_dfgh_dwq desired output is.. dwc2_dfg_ajja_dfhhj it's a simple task with tail... (5 Replies)
Discussion started by: victor369
5 Replies

9. Shell Programming and Scripting

Displaying only First Occurrence of a String

Hi, My requirement is that I should search for a particular string and display the string only once if there is more occurrence of the same string in a file. e.g In the given below log file,the string AMQ5037 comes twice.I want to search for this string and display it only once.grep will... (5 Replies)
Discussion started by: charudpss
5 Replies

10. Shell Programming and Scripting

Search a string and append text after the string

Hi, I have a file like this... <o t="Batch" id="8410" p="/" g="32"> <a n="name"> <v s="DBBA1MM"/> </a> <a n="owner"> <v r="/Administrator"/> </a> <a n="rights"> <v s="95"/> </a> <a n="debugLevel"> <v s="3"/> </a> <a n="avsStoreLoc"> <v... (8 Replies)
Discussion started by: kesu2k
8 Replies

Featured Tech Videos