Sponsored Content
Top Forums Shell Programming and Scripting converting the data type in unix shell script Post 302247843 by kmanivan82 on Thursday 16th of October 2008 12:18:41 PM
Old 10-16-2008
converting the data type in unix shell script

I am writing a unix shell script that will extract records from table and write into a file.
Code:
======================================
#! /bin/ksh
############################
#   AFI Monitor Script
############################
. /db2/uszlad48/sqllib/db2profile
export mondir=/home/bmwdev1/script/krishna/arc
export monlog=$mondir/r1.log
# connect to DB
db2 connect to r2pdev user bmwdevup using summer08
# extract the records from the table ZB_RCBL_ERROR_MSG_MIG
db2 -x "SELECT A.LINE_OF_BUSINESS, A.USER_UPDATED, A.ERROR_STATUS_CD, A.STATE_CD, A.AGENT_DIST, A.AGENT_ID, A.COMPANY_CD, A.REGION_CD, A.PLCY_CONTRACT_NUM, A.EFF_DT, A.BILLING_ACCT_NUM, A.PREMIUM_AMT, B.MSG_NUM, B.MSG_ID, B.MSG_TYP, B.MSG_TEXT FROM BMWDEV1.ZB_RCBL_ERROR A, BMWDEV1.ZB_RCBL_ERROR_MSG B WHERE A.TRACKING_NUM = B.TRACKING_NUM AND A.TRACKING_NUM_SUFFIX = B.TRACKING_NUM_SUFFIX AND A.TIMESTAMP_UPDATED >= '2008-10-01-00.00.00.000000' AND A.TIMESTAMP_UPDATED < '2008-10-05-00.00.00.000000' WITH UR" >> $monlog
# disconnect from DB2
db2 terminate
exit 0
======================================

Following is the output I have got by executing this script
Code:
F                R2P          E               22       02         102      B21        08        929460723         10/07/2008 M866516384            -1669.46 002                          I       One or more uncleared errored receivables for the policy                                            
A                R2P          E               22       02         102      B01        08        175056956         09/22/2008 M277377095              237.60 003                          I       Policy / Contract Account Number are pending in the ZB_MASTER_DATA_LOG                              
F                R2P          E               22       02         330      B21        08        929460103         09/29/2008 M275350821             1772.29 038     >4                   I       Enter an amount                                                                                     
F                R2P          E               22       02         330      B21        08        929460103         09/29/2008 M275350821             1150.00 002                          I       One or more uncleared errored receivables for the policy                                            
F                R2P          E               36       35         330      B21        02        929460739         10/08/2008 P897680301             1824.93 003                          I       Policy / Contract Account Number are pending in the ZB_MASTER_DATA_LOG

The problem what i am facing is the field Premium_amt is available in the file in character format. I going to FTP this text file to mainframe. There they will format the data. While formatting they have to add the premium amount. If it is available character format we will not be able to sum all the premium amount. If it is avilable in packed decimal we will convert into decimal and will sum it up.
Can anyone help me to fix this problem.
Krishnakanth
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract data using UNIX shell script?

Hello All, I am starting with UNIX. Any help is highly appreciated. How to extract data using UNIX shell script? And how do you export data using UNIX shell scripts into Microsoft Excel format? Thank you. (3 Replies)
Discussion started by: desiondarun
3 Replies

2. Shell Programming and Scripting

How to type the Omega symbol Ω in unix shell script

Hi, I have a data file delimited by Ω symbol, I would like to use this in grep and cut command. but How to type this Omega symbol. Thanks Murugesan (1 Reply)
Discussion started by: NagaMurugesan
1 Replies

3. UNIX for Dummies Questions & Answers

Verify the data type in a file with UNIX function

I am seeking help on this UNIX function, please help. Thanks in advance. I have a large file, named as 'MyFile'. It was tab-delmited, I am told that each record in column 1 is unique. How would I verify this with UNIX function or command? (1 Reply)
Discussion started by: duke0001
1 Replies

4. Shell Programming and Scripting

Unix shell script converting temperatures.

:confused:Please I really need help with an assignment question. I need to write a script that will take the input from a file and convert the number from Centigrade(Celcius) to Fahrenheit or vice versa. Thank you so much. I really need it to be detailed. Please remember the input comes from a file. (1 Reply)
Discussion started by: starter101
1 Replies

5. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (0 Replies)
Discussion started by: dear_abhi2007
0 Replies

6. Shell Programming and Scripting

How to fetch data from oracle in unix shell script

Hi, How to fetch data from oracle database in unix shell scripting. list=`sqlplus -s ds_user/dsuser@EMI <<EOF set feedback off set serveroutput on set heading off set pagesize 0 set tab off select IP_ID from table / exit EOF` The output is not what i expected.I need output in... (4 Replies)
Discussion started by: Anusha_Reddy
4 Replies

7. Shell Programming and Scripting

Data export UNIX shell script

Hi, I want to write a shell script which connect to my database with the following credentials : User name : user PWD : rap_user_1 Hostname : app.Unix.Gsm1900.Org Port : 7862 SID : PTNC1 Once connected to DB i want to fetch data with the help of a SQL statement and expoet... (4 Replies)
Discussion started by: neeraj617
4 Replies

8. 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

9. Programming

Visual Basic converting a decimal data type to a label with currency format

Here is the code that I am working with. I have tried several other things. any suggestions? Lbl_Cost_Output.Text = (dDistance * dCostPerMile).ToString("C") The label is formatted correctly in terms of value 0.00 but no dollar sign appears. Please let me know if you have any questions. (1 Reply)
Discussion started by: briandanielz
1 Replies

10. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (2 Replies)
Discussion started by: Barbara1234
2 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-k] [-q] [-t time] [file [command ...]] DESCRIPTION
The script utility makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. If the argument command ... is given, script will run the specified command with an optional argument vector instead of an interactive shell. Options: -a Append the output to file or typescript, retaining the prior contents. -k Log keys sent to program as well as output. -q Run in quiet mode, omit the start and stop status messages. -t time Specify time interval between flushing script output file. A value of 0 causes script to flush for every character I/O event. The default interval is 30 seconds. The script ends when the forked shell (or command) exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. The script utility works best with commands that do not manipulate the screen. The results are meant to emulate a hardcopy terminal, not an addressable one. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism). HISTORY
The script command appeared in 3.0BSD. BUGS
The script utility places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. It is not possible to specify a command without also naming the script file because of argument parsing compatibility issues. When running in -k mode, echo cancelling is far from ideal. The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. BSD
June 6, 1993 BSD
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy