Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inserting hexdecimal value in insert query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Dibyendu Mandal

New User


Joined: 08 Dec 2011
Posts: 10
Location: India

PostPosted: Wed Jul 04, 2012 9:58 pm    Post subject: Inserting hexdecimal value in insert query
Reply with quote

Hi,
I want to insert some hex value in a table.But the data type of the column is char.How can I do this.
Ex: I want to insert hex'3c00' in table,while the column datatype is char.
I am trying to insert atleast 100 rows.
Please help.
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Jul 04, 2012 10:41 pm    Post subject:
Reply with quote

Prefix the string with BX and cast it to CHAR.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 04, 2012 10:42 pm    Post subject:
Reply with quote

would you consider,
looking at the manual,
learning about char datatype and what values a char column can contain.
how many bytes in the char datatype column?

spufi, qmf, db2 batch utility, imbedded sql?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 04, 2012 10:50 pm    Post subject:
Reply with quote

Hello,

Place this value in a host variable and use this for the insert.

If this is "real" data (as opposed to sme testing), hopefully, you are producing an audit trail so there are not "mysteries" in the data. Right ?
Back to top
View user's profile Send private message
Dibyendu Mandal

New User


Joined: 08 Dec 2011
Posts: 10
Location: India

PostPosted: Thu Jul 05, 2012 12:44 am    Post subject:
Reply with quote

Hi Dick,
I am not using any cobol or any other host language.My requirement is I need to insert around 500 rows with hex value for testing purpose.
its through SPUFI and my column is char datatype(char(20) for example).
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Thu Jul 05, 2012 1:11 am    Post subject:
Reply with quote

guess what - any hex value is a valid char value. If necessary cut and paste the character(s).
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 8:23 am    Post subject:
Reply with quote

Hello,

Then embed the hex value in the values used for the INSERT.

As i mentioned before, this should NOT be done for real data (i.e. QA, PROD, etc). I have worked with organizations who terminate people for updating "real" data on the fly. . . fwiw.

You (or some incompetent above you) may believe this is acceptable, but is one of the most dangerous things that someone can do. Personally, i will not update data this way unless is is "my" data and then only if i've created a backup. We ALL do make mistakes and we need to get back to where we were.
Back to top
View user's profile Send private message
Dibyendu Mandal

New User


Joined: 08 Dec 2011
Posts: 10
Location: India

PostPosted: Thu Jul 05, 2012 8:46 am    Post subject:
Reply with quote

Hi Dick,
I understand that we should not use this in QA and prod.I am using the data for some negative testing.As soon as the testing is over we will backout the changes.
You told -"Then embed the hex value in the values used for the INSERT. "
How to do this.Normal insert like-
insert into employee
(empno,fname)
values(x'0030',dev);
is not working.Can you please provide me the structure of the query.[/img]
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 9:19 am    Post subject:
Reply with quote

Hello,

Look here and see if the info from GuyC will help:
http://ibmmainframes.com/viewtopic.php?t=58199&start=0

Scroll thru the entire topic.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts SQL Query optimization. arunsoods DB2 12 Sun Sep 04, 2016 6:27 am
No new posts Insert Lines in JCL with Rexx after a... Willy Jensen CLIST & REXX 3 Tue Aug 30, 2016 4:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us