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

How to use DCLGEN variable as host variable in INSERT stmt


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

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Fri Sep 30, 2005 6:29 am
Reply with quote

icon_question.gif Hi folks,
I am using COBOL program to insert values in to a db2 table. The dclgen variables for varchar data type has a length field along with the data field. How to use that dclgen variable as host variable in an INSERT statement. Please help me.

Quote:

Knowledge in your hands for your journey ahead
Back to top
View user's profile Send private message
ak1972

New User


Joined: 25 Aug 2005
Posts: 7

PostPosted: Sat Oct 01, 2005 6:48 am
Reply with quote

The length field tells you how many bytes to insert

MOVE DCLGEN-VAR-WITH-LEN (1:DCLGEN-LENGTH-VAR)
TO WS-VARCHAR-DATA
Then write your sql statement using WS-VARCHAR-DATA
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Tue Oct 04, 2005 9:40 am
Reply with quote

Hi ak1972

Thanks for your reply.
I could'nt get the actual use of the Above statements why is it needed can you emphasize on it.


Thanks,
Muralikrishnan S
Back to top
View user's profile Send private message
krishnaiahc

New User


Joined: 31 Aug 2005
Posts: 21

PostPosted: Fri Oct 28, 2005 5:17 am
Reply with quote

Hai,

DCLGEN variable....
10 VBXSTMT-XACT-DESC.
49 VBXSTMT-XACT-DESC-LEN PIC S9(4) USAGE COMP.
49 VBXSTMT-XACT-DESC-TEXT PIC X(650).

data movement in COBOL::

MOVE LENGTH OF HAASTM-XACT-DESC
TO VBXSTMT-XACT-DESC-LEN

MOVE HAASTM-XACT-DESC-DTL TO VBXSTMT-XACT-DESC-TEXT

Host Variable in SQL statement::
EXEC SQL
INSERT INTO VBXSTMT
VALUES
(...
....
:VBXSTMT-XACT-DESC)

Please let me know if you have concerns...

Regards,
Krishna.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Identify Program Insert DB2 7
Search our Forums:

Back to Top