View previous topic :: View next topic
|
Author |
Message |
oerdgie
New User
Joined: 22 Nov 2007 Posts: 64 Location: Germany
|
|
|
|
Hi Folks,
does anybody have an exemple how to insert a VARCHAR field into a DB2 table with REXX ? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This Redbook Dynamic SQL has a rather large chapter on REXX with examples. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Thanks Dick, another one dowloaded to yonder laptop. |
|
Back to top |
|
|
oerdgie
New User
Joined: 22 Nov 2007 Posts: 64 Location: Germany
|
|
|
|
Hey Dick, many thanks !
Greatings from Hartmut (DL Berlin ;-) |
|
Back to top |
|
|
abhisinghal2002
New User
Joined: 02 Jul 2008 Posts: 12 Location: Delhi
|
|
|
|
Not able to download the book on my lappy...
can any one send it across.....@....e-addr removed per forum policy.
Thanks a lot in advance |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
abhisinghal2002 wrote: |
Not able to download the book on my lappy |
Then open this link and then RIGHT CLICK on the 'download PDF hyperlink' (on the displayed page) and 'SAVE LINK AS...'.
That will cause a direct download via your browser to start instead of invoking ADOBE to open (download) the PDF. |
|
Back to top |
|
|
abhisinghal2002
New User
Joined: 02 Jul 2008 Posts: 12 Location: Delhi
|
|
|
|
Thanks a lot... |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Hi!
I've tried inserting a row into DB2 using the following code
The address and contact fields are VARCHAR. How do i modify my code in order to make it run successful?
Current output window shows
Code: |
INSERT OPERATION FAILED. ERROR DETAILS ARE
SQLCODE -301
SQLSTATE 42895
SQL ERROR MESSAGE 004:
***
|
Actual code is
Code: |
/* REXX */ 00010000
ADDRESS TSO "SUBCOM DSNREXX" 00020000
IF RC = 0 THEN 00030000
CALL RUN 00040000
ELSE 00050000
DO 00060000
SIGNAL ON SYNTAX NAME RXSUBCOM_FAILED 00070000
RC = RXSUBCOM('ADD','DSNREXX','DSNREXX') 00080000
SAY 'DSNREXX MADE EXPLICITLY AVAILABLE. RETURN CODE' RC 00090000
SIGNAL OFF SYNTAX 00100000
END 00110000
RUN: 00120000
SQLSTMT1 = "SELECT MAX(AGENTID) FROM AGENT" 00121000
SQLSTMT2 = "INSERT INTO AGENT VALUES ( ?, ?, ?, ?)" 00130000
SAY 'ENTER YOUR DATE OF BIRTH' 00130100
PULL DOBA 00130200
SAY 'ENTER YOUR ADDRESS' 00130300
PULL ADDRESSA 00130400
SAY 'ENTER YOUR CONTACT NUMBER' 00130500
PULL CONTACTA 00130600
ADDRESS DSNREXX 00130700
"CONNECT DSN1" 00130800
"EXECSQL DECLARE C1 CURSOR FOR S1" 00130900
"EXECSQL DECLARE C2 CURSOR FOR S2" 00131000
"EXECSQL PREPARE S1 FROM :SQLSTMT1" 00131100
"EXECSQL DESCRIBE S1 INTO :OUTSQLDA" 00131200
"EXECSQL PREPARE S2 FROM :SQLSTMT2" 00131300
"EXECSQL OPEN C1" 00131400
"EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA" 00131500
IF SQLCODE = 0 THEN 00131600
DO 00131700
AGENTIDA = OUTSQLDA.1.SQLDATA 00131801
AGENTIDA = AGENTIDA + 1 00131901
"EXECSQL CLOSE C1" 00132004
DOBA = '1985-03-24' 00132105
ADDRESSA = 'ASIA' 00132205
CONTACTA = '+919740536135' 00132305
AGENTIDA = 10000004 00132405
"EXECSQL EXECUTE S2 USING :AGENTIDA, :DOBA, :ADDRESSA, :CONTACTA" 00132504
IF SQLCODE = 0 THEN 00132601
SAY 'INSERT SUCCESSFUL' 00132701
ELSE 00133000
DO 00134000
SAY 'INSERT OPERATION FAILED. ERROR DETAILS ARE' 00135000
SAY 'SQLCODE' SQLCODE 00136005
SAY 'SQLSTATE' SQLSTATE 00136105
SAY 'SQL ERROR MESSAGE' SQLERRMC 00136205
END 00137000
END 00137100
ELSE 00137200
DO 00137300
SAY 'DATABASE ERROR OCCURRED IN CALCULATING THE AGENT ID' 00137400
SAY 'SQLCODE' SQLCODE 'AND SQLSTATE' SQLSTATE 00137500
END 00137600
"DISCONNECT DSN1" 00138000
EXIT 00139000
RXSUBCOM_FAILED: 00140000
SAY 'PROBLEM LOADING DSNREXX. RETURN CODE' RC 00150000
EXIT 00160000
|
Thanks in advance. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Just a guess:
CONTACTA = '+919740536135'
though you entered it as a string, I image the plus sign caused the interpreter during the SQL submission to send CONTACTA as signed numeric. |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
I gave CONTACTA = '9740536135' but still it throws the same message. The possibility as it shows SQLCODE=-301 could be due to the varchar nature of the columns ADDRESS and CONTACT |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Problem solved now . If I am accepting CONTACT from the console, I should give in quotes like '9740536135' and if I am assigning in the routine, i should do it this way CONTACTA = "'+919972524373'" |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Vishwamurthy,
thx for the feedback. |
|
Back to top |
|
|
Rexxit
New User
Joined: 24 Jun 2009 Posts: 1 Location: New York
|
|
|
|
I'm having trouble with varchar when inserting using DSNREXX. The varchar defined as 3000 bytes but rexx is changing it to char so I'm unable to insert anything larger than 255 bytes. Any ideas? Thanks. Joe. |
|
Back to top |
|
|
|