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

VARCHAR definition..if length is not given what will happen?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vverma9

New User


Joined: 20 Jun 2007
Posts: 2
Location: noida

PostPosted: Thu Jul 29, 2010 4:56 pm
Reply with quote

Hi,

Define host variables for VARCHAR cols in DB2 as fallows:

01 varchar.
49 len pic 9(4) comp.
49 data pic x(200).

My Question's are:

1) Can I define the length variable other than 'COMP' picture clause mentioned above in Sql DB2?

2) What happened If I have not given the length parameter in the Varchar definition?? What abend code it will send?? Should it will take the default length??

vverma9,Mumbai
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jul 29, 2010 5:40 pm
Reply with quote

1) no
2) won't work.
don't know,don't care.
no
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Jul 30, 2010 4:18 pm
Reply with quote

I have seen few working codes handling varchar without the length variable. This would work only for selects. I had to modify one such program and I followed the variable definitions. The update and inserts were not appropriate without the length variable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jul 30, 2010 6:00 pm
Reply with quote

you can not reference the 49 levels in sql, you must reference the group item.

and as Bharath Bhat said,
with select, db2 sets the length-variable.

UPDATE, INSERT you have to set the host variable to an appropriate value
before invoking the SQL
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jul 30, 2010 6:54 pm
Reply with quote

On an update or insert DB2 will use the first 2 bytes as the length!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jul 30, 2010 7:01 pm
Reply with quote

dbz wrote:
you can not reference the 49 levels in sql, you must reference the group item
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 Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top