MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to fetch a value from table using Binary value

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
ramanajeem
Beginner


Joined: 13 Sep 2006
Posts: 5
Topics: 1
Location: India

PostPosted: Wed Sep 13, 2006 6:24 am    Post subject: How to fetch a value from table using Binary value Reply with quote

Hi,

Is there any function that converts integer to actual value?

My requirement is

- Unload Integer field XXXX from a table to flat file.
- Using XXXX, I need to fetch a YYYY variable field from another table. But I could not fetch a value from another table as variable XXXX is stored in binary form in flat file. So, Can anyone provide their inputs to fetch the value?

Thanks in advance.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 13, 2006 7:25 am    Post subject: Reply with quote

ramanajeem,

Quote:

Is there any function that converts integer to actual value?


Yes there are , the scalar functions CHAR or DIGITS can be used to convert the integer to readable format.

The CHAR scalar function is explained in detail here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.11?SHELF=&DT=20010718164132&CASE=

The DIGITS scalar function is explained in detail here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.27?SHELF=&DT=20010718164132&CASE=

Quote:

My requirement is

- Unload Integer field XXXX from a table to flat file.
- Using XXXX, I need to fetch a YYYY variable field from another table. But I could not fetch a value from another table as variable XXXX is stored in binary form in flat file. So, Can anyone provide their inputs to fetch the value?


Why do you want to unload and then fetch the values once using the unload file when you can do that all in a single query ? More over the SQL has a limit of 32760 bytes. So if your unload file is too big then it will fail.

Try this query

Code:


SELECT *
  FROM TABLE_B
 WHERE INT_COL_IN_TABLE_B IN (SELECT INT_COL_IN_TABLE_A
                                FROM TABLE_A)


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Sep 13, 2006 7:26 am    Post subject: Reply with quote

ramanajeem,

Say you are trying to unload to a flat file the following three colums, u can use CHAR function for column XXXX to display in readable format in your SYSREC DD statement.
Code:

SELECT NAME,CHAR(XXXX),ADDRESS FROM TABLENAME1;


Now for your second question use:
Code:

SELECT YYYY FROM TABLENAME2 WHERE CHAR(XXXX) = 'SOMEVALUE';

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
ramanajeem
Beginner


Joined: 13 Sep 2006
Posts: 5
Topics: 1
Location: India

PostPosted: Wed Sep 13, 2006 8:19 am    Post subject: Reply with quote

Hi Kolusu and Shekar123,

Thanks for your reply.

This is my actual requirement.

one table has 4 columns and the 1st column(XXXX) is an INTEGER type. Now I have to insert a new column with type TS to this table as a 1st Cloumn. I am follwing these steps to complete my task.
- Unload the data.
- While unloading Input flat file will be created with complete table data.
- Write a program to read INPUT flatfile. Read record by record from INPUT flat file, get the value of 1st column which is in INTEGER type in table and in binary format in flat file. I am getting an error while reading another table to fetch TS value using 1st column value which in binary format.

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 13, 2006 8:39 am    Post subject: Reply with quote

ramanajeem,

Quote:

Now I have to insert a new column with type TS to this table as a 1st Cloumn.


What is type TS? You are complicating the requirement. It can be done with a single SQL

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Sep 13, 2006 8:40 am    Post subject: Reply with quote

Kolusu,

Can we not do this by the following steps ?

1.Alter the table by adding a new column of type TIMESTAMP.
2.Unload the Table data to a Flat file
3.Run a SORT utility to fill in the first column with TIMESTAMP values in the flat file.
4.Load the table with the flat file which will have the new altered table structure.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 13, 2006 8:48 am    Post subject: Reply with quote

shekar123 wrote:
Kolusu,

Can we not do this by the following steps ?

1.Alter the table by adding a new column of type TIMESTAMP.
2.Unload the Table data to a Flat file
3.Run a SORT utility to fill in the first column with TIMESTAMP values in the flat file.
4.Load the table with the flat file which will have the new altered table structure.


I couldn't relate TS type to timestamp. If it is indeed Timestamp column, then you need to format the data as CCYY-MM-DD-HH.MM.SS.NNNNNN. if his input is only integer then how can you format to Timestamp format?

You don't need all the 4 steps , you can simply do it using a SQL query itself provided you know the rules of populating the Timestamp format


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramanajeem
Beginner


Joined: 13 Sep 2006
Posts: 5
Topics: 1
Location: India

PostPosted: Wed Sep 13, 2006 8:57 am    Post subject: Reply with quote

Hi all,

Sorry for the confusion. TS stands for Timestamp.

Thanks
Back to top
View user's profile Send private message
ramanajeem
Beginner


Joined: 13 Sep 2006
Posts: 5
Topics: 1
Location: India

PostPosted: Wed Sep 13, 2006 9:07 am    Post subject: Reply with quote

Hi,

Is there any way that I can fetch a value from a table using the value stored in Binary format in flatfile?

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 13, 2006 9:11 am    Post subject: Reply with quote

ramanajeem,

Why do you keep asking the same question over and over? Your question answered in the 2nd post it self? You are not clear with your requirements and ask the question over and over

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ramanajeem
Beginner


Joined: 13 Sep 2006
Posts: 5
Topics: 1
Location: India

PostPosted: Wed Sep 13, 2006 9:44 am    Post subject: Reply with quote

Hi Kolusu,

It would be great if you could help me on this.

I have flat file with 3073 Characters as shown below. Using the data available in IN-FILE, I need to build OUT-FILE. Please remeber that IN-FILE data is in flat file in binary format. Now using the value available WS-IN-FIELD1(In Binary format), I need to read another table to fetch a value for WS-OUT-FIELD1-TS to build OUT-FILE. But while fetching the value I am reciving an SQL error.

01 WS-UNLOADED-FLAT-REC.
05 WS-IN-FIELD1 PIC S9(9) COMP.
05 WS-IN-FIELD2 PIC S9(9) COMP.
05 WS-IN-FIELD3-LEN PIC S9(4) COMP.
05 WS-IN-FIELD3-TXT PIC X(60).
05 WS-IN-FIELD3-TXT-NI PIC X(1).
05 WS-IN-FIELD4-TXT-SZ PIC S9(4) COMP.
05 WS-IN-FIELD4-TXT PIC X(3000).

01 WS-LOAD-FLAT-REC.
05 WS-OUT-FIELD1-TS PIC X(26) COMP.
05 WS-OUT-FIELD1 PIC S9(9) COMP.
05 WS-OUT-FIELD2 PIC S9(9) COMP.
05 WS-OUT-FIELD3-LEN PIC S9(4) COMP.
05 WS-OUT-FIELD3-TXT PIC X(60).
05 WS-OUT-FIELD3-TXT-NI PIC X(1).
05 WS-OUT-FIELD4-TXT-SZ PIC S9(4) COMP.
05 WS-OUT-FIELD4-TXT PIC X(3000).

I am using following query to fetch a value.

EXEC SQL
SELECT FIELD_TS
INTO :WS-OUT-FIELD1-TS
FROM TABLE
WHERE COLUMN = :WS-IN-FIELD1
END-EXEC.

I hope I put my query little clear this time.

Thanks in advance.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group