IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting hexdecimal value in insert query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 1788
Location: Bloomington, IL

PostPosted: Wed Jul 04, 2012 10:41 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 04, 2012 10:50 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Thu Jul 05, 2012 1:11 am
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

Moderator Emeritus


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

PostPosted: Thu Jul 05, 2012 8:23 am
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
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

Moderator Emeritus


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

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

Hello,

Look here and see if the info from GuyC will help:
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top