How This code works?

Database
Enthusiast

How This code works?

Hi folks,

This code is used for finding the start and end date of the partition, constrainttext is a column in a DBC veiw table. let me know why should they added 13 and -37

select
substring
(
constrainttext
FROM index(constrainttext,'BETWEEN DATE') +13
FOR 12
)
, substring
(
constrainttext
FROM index(constrainttext,'NO RANGE') -37
FOR 12
)
from dbc.indexconstraints
where databasename = 'travel'
and tablename = 'branch_item'

Result:

returns the overall partition from and to dates

'2003-08-03' '2005-12-31'

Thanks
Vedamurthy
2 REPLIES
Enthusiast

Re: How This code works?

First it is finding the starting position of substring 'BETWEEN DATE' using index function then adding 13 to get the starting position of the first Date range , then reading 12 characters from there to get the DATE value.

Same technique for the other column.

Enthusiast

Re: How This code works?

Thanks for your reply

Many Thanks
Vedamurthy