If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to substitute Substr() function?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-08, 10:24
katrin_king katrin_king is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
How to substitute Substr() function?

I run the following query:

EXECUTE(
declare global temporary table Hospice_prov
( Id char (29)
,Srv_Dt date
,End_Dt date

)

) by Mconnect;

EXECUTE(


EXECUTE(
insert into session.prov
select distinct
ms.Id
, mc.Start_Dt as Srv_Dt
, mc.End_Dt

from &clmschema..MedS ms
join &clmschema..MedC mc
on ms.Id = mc.Id
where SUBSTR(ms.SPEC_CD,1,2)='32'
and mc.Start_Dt >= '01/01/2005'
and mc.End_Dt <= '12/31/2007'

) by Mconnect;

************************************************** *******

Error log is:

ERROR: CLI execute error: [IBM][CLI Driver][DB2/AIX64] SQL0440N No authorized routine named "SUBSTR" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884

************************************************** ****

It looks like Substr function is not appropriate to DB2 SYNTAX

WHAT SHOULD i REPLACE IT WITH?

Thank you in advance,
Reply With Quote
  #2 (permalink)  
Old 07-11-08, 10:29
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
substr is a valid function. What is the data type of ms.SPEC_CD?

Andy
Reply With Quote
  #3 (permalink)  
Old 07-11-08, 10:35
katrin_king katrin_king is offline
Registered User
 
Join Date: Jan 2005
Posts: 13
character
Reply With Quote
  #4 (permalink)  
Old 07-11-08, 10:42
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I do not know what the problem is, but this should get you what you want:

insert into session.prov
select distinct
ms.Id
, mc.Start_Dt as Srv_Dt
, mc.End_Dt

from &clmschema..MedS ms
join &clmschema..MedC mc
on ms.Id = mc.Id
where ms.SPEC_CD like '32%'
and mc.Start_Dt >= '01/01/2005'
and mc.End_Dt <= '12/31/2007'

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On