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
 

 

Query using SUBSTRING on a column of type CLOB

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sasanka
Warnings : 1

New User


Joined: 18 Jan 2008
Posts: 34
Location: India

PostPosted: Mon Jul 04, 2016 1:01 pm    Post subject: Query using SUBSTRING on a column of type CLOB
Reply with quote

Hi,

I am using a table in which one column is defined as below:

EMP_INFO CLOB (5M) NOT NULL

I am storing data of size 342575 bytes into column EMP_INFO

After inserting rows into this table, I am trying to use SUBSTRING to see the last 100 bytes of stored data and using below query (in SPUFI):

SELECT SUBSTRING(CLOB(EMP_INFO), 342475, 100)
FROM EMP_TAB
FETCH FIRST 1 ROW ONLY
WITH UR;

But, I am getting SQLCODE # -171, ERROR: THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT 3 OF SUBSTRING IS INVALID

Please someone help me to correct my query.

Thanks.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Mon Jul 04, 2016 3:51 pm    Post subject:
Reply with quote

Have you run a query to determine the actual length of each value of EMP_INFO?

Why did you not use the code tags for your query? Code tags should be used for all data and code.
Back to top
View user's profile Send private message
sasanka
Warnings : 1

New User


Joined: 18 Jan 2008
Posts: 34
Location: India

PostPosted: Mon Jul 04, 2016 8:00 pm    Post subject: Reply to: Query using SUBSTRING on a column of type CLOB
Reply with quote

Hi,

The actual length of EMP_INFO is 342575 and I am executing the query in SPUFI and got the sql error as mention in my earlier post.

Thanks..
Back to top
View user's profile Send private message
sasanka
Warnings : 1

New User


Joined: 18 Jan 2008
Posts: 34
Location: India

PostPosted: Tue Jul 05, 2016 2:23 pm    Post subject: Reply to: Query using SUBSTRING on a column of type CLOB
Reply with quote

Hi,

Can anyone please provide me a correct query with SUBSTRING used on a CLOB column of a table.

Thanks
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Jul 05, 2016 9:31 pm    Post subject:
Reply with quote

Let us see if you are right about the offset, Try this.
Code:
SELECT SUBSTRING(CLOB(EMP_INFO), 342475)
 FROM EMP_TAB
 FETCH FIRST 1 ROW ONLY
 WITH UR;

Quote:
The actual length of EMP_INFO is 342575
How did you find this? And why not to filter only the employee that is in context( the one you inserted)? Or if everything is right then what value is stored in that position as then, you may need CAST function to make it compatible?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Tue Jul 05, 2016 9:40 pm    Post subject:
Reply with quote

Quote:
Can anyone please provide me a correct query with SUBSTRING used on a CLOB column of a table.


You have already asked for help - do not repeat yourself. Responses are made if:
Someone knows
Someone wants to answer

This is a volunteers board - no one gets paid for responding and they do it, if they do it, as and when they see fit.
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 SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 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
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


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