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

Query using SUBSTRING on a column of type CLOB


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Jul 04, 2016 3:51 pm
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
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Jul 05, 2016 9:31 pm
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: 2455
Location: Hampshire, UK

PostPosted: Tue Jul 05, 2016 9:40 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top