DB2: Replace Number Value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers DB2: Replace Number Value
# 1  
Old 05-17-2012
DB2: Replace Number Value

Hi

In the below query userreg.status returns a value of 1 (Active) or -1 (Non Active). Ideally, I would like to replace this automatically on the export so instead of getting 1 or -1 I get Active / Non Active.

Quote:
db2 "export to join.csv of del select distinct userreg.logonid, address.firstname, address.lastname,userreg.status from userreg inner join address on address.member_id = userreg.users_id where userreg.USERS_ID in (select MEMBER_ID from MBRROLE where ROLE_ID = -1) with ur"
Any help, as usual, would be greatly apprecited.
# 2  
Old 05-17-2012
Can you post a couple lines of the output of the db2 query please.
If the -1 and 1 are in the last field, then this should work:
Code:
db2 ... | awk  '$NF==1{$NF = "Active"}$NF==-1{$NF = "Non active"}1' FS=OFS=","

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Fscanf to get number and replace.

Hi, I have a file with contents like "abcd 1234" .What i need is get that integer and replace that with 0. So i used fscanf(fp,"%s %d", str, &num); This is having some problem. There can be multiple space/tab between string and number. How to replace that number with 0 in same file? (4 Replies)
Discussion started by: explore
4 Replies

2. Shell Programming and Scripting

Dynamic number to replace with line

Hi, I have file as below COMMIT # at 34572 # at 23432 COMMIT # at 5674 # at 7856 I want to replace with as below (12 Replies)
Discussion started by: kaushik02018
12 Replies

3. Shell Programming and Scripting

Replace first number of each line in a file with another number

Hi, I have a set of files in a directory that I have to read and replace the first occurrence of a number with another dummy number. This is what I have so far but it does not seem to work. The files have lot of other data in each row and each data element is separated by ,@, for file in... (13 Replies)
Discussion started by: scorpioraghu
13 Replies

4. Shell Programming and Scripting

Need to replace a number from string

Dear all, I need your help with some shell scripting which I have just started. I have a file whose content look something like: Pressure 1 1 1e5 Temperature 1 1 300 Volume 1 1 2e-20 And there are other lines too, but these are the lines i wish to play with. These files... (7 Replies)
Discussion started by: hrushi.397
7 Replies

5. Shell Programming and Scripting

Using SED to replace a random number?

Hi all, I need to run a number of scripts which have a certain phrase on them so I have identified these by; grep -l 100 *script | sort -u Normally I could just run something along the lines of; for i in `grep -l 100 *script | sort -u`; do ./${i}; done However before I run each of... (0 Replies)
Discussion started by: JayC89
0 Replies

6. UNIX for Dummies Questions & Answers

Search and replace a number

a=`grep -i a.sh filename.sh|cut -d "|" -f4` b=`expr $a + 1` filename=`grep -i a.sh filename.sh` while read line do echo $line echo $filename if then echo "entered if" nawk ' BEGIN { FS="|"; OFS="|" } { sub('$a', '$b', $4) print $0}' filename.sh fi echo "exit if" done <... (1 Reply)
Discussion started by: hs.giri
1 Replies

7. UNIX for Advanced & Expert Users

Search and replace a number

a=`grep -i a.sh filename.sh|cut -d "|" -f4` b=`expr $a + 1` filename=`grep -i a.sh filename.sh` while read line do echo $line echo $filename if then echo "entered if" nawk ' BEGIN { FS="|"; OFS="|" } { sub('$a', '$b', $4) print $0}' filename.sh fi echo "exit if" done <... (1 Reply)
Discussion started by: hs.giri
1 Replies

8. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

9. UNIX for Dummies Questions & Answers

Exception while loading DB2 driver Class.forName("com.ibm.db2.jcc.DB2Driver")

Hi... I m working on UNIX z/OS. Actually i have to pass the parameters from the JCL to java-db2 program thru PARM. I am able to pass the arguments but the problem occured is, it is throwing an exception while loading the db2 driver as 'Javaclassnotfound:com.ibm.db2.jcc.DB2Driver'... (0 Replies)
Discussion started by: Sujatha Gowda
0 Replies
Login or Register to Ask a Question