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 > string function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-19-05, 07:03
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
string function

This is a very newbie question. I am editing a business obects report using WebIntelligence.

I need to limit the string that is returned, I was hoping to do this by allowing everything before the first fullstop. Any suggestions??

Any suggestions would be appreciated.

Thank You
Reply With Quote
  #2 (permalink)  
Old 12-19-05, 07:10
gardenman gardenman is offline
Registered User
 
Join Date: Apr 2004
Posts: 54
Quote:
Originally Posted by shinny
This is a very newbie question. I am editing a business obects report using WebIntelligence.

I need to limit the string that is returned, I was hoping to do this by allowing everything before the first fullstop. Any suggestions??

Any suggestions would be appreciated.

Thank You
there is function SUBSTR:

(@) values substr('1234567890',1,5)

1
-----
12345

1 record(s) selected.
Reply With Quote
  #3 (permalink)  
Old 12-19-05, 08:19
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
This was my effort

=Substr([CSR Reporting Category Description],.)

it returned unspecified error.

Im sure ive a mistake in there somewhere though
??
Reply With Quote
  #4 (permalink)  
Old 12-19-05, 09:32
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Quote:
=Substr([CSR Reporting Category Description],.)
I think you're writing Access SQL or something similar.

Your query should look something like this (to get only the first 100 characters):
Code:
SELECT substr(tableorigin.long_field, 1, 100)
FROM tableorigin;
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #5 (permalink)  
Old 12-19-05, 09:40
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
it is not possible for me to say how many characters i need. It will never be the same. I only require the first sentence so therefor was trying the find the first fullstop.

Any suggestions?
Reply With Quote
  #6 (permalink)  
Old 12-19-05, 09:51
murali_sb murali_sb is offline
Registered User
 
Join Date: Dec 2005
Posts: 39
Alternatively you can use locate function (substr is provided, no idea why instr is not??), this would be useful if you don't know how many characters to remove using substr.

basically select substr([CSR Reporting Category Description], 1, locate('.', [CSR Reporting Category Description]) -1)

pls note 2 things - depending upon how the string is you might need to use appropriate start point, i mean, 1 should be replaced by appropriate number. Also end point should be string - 1 since locate will give you the location of string so to ignore it in the resultant string you might have to use - 1.

hope this helps.
Reply With Quote
  #7 (permalink)  
Old 12-19-05, 10:00
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
You should look for the first occurenvce of the fullstop character '.', using
POSSTR('source-string','search-string') and using the result of that to limit the length of the field.
Code:
SELECT substr(tableorigin.long_field, 1, POSSTR(tableorigin.long_field, '.'))
FROM tableorigin;
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #8 (permalink)  
Old 12-19-05, 11:25
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Code:
substr([CSR Reporting Category Description], 1, 
    locate('.', [CSR Reporting Category Description]) -1)
What is this "[ .... ]" thing ? Is this DB2 SQL or Business Objects talk ?
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #9 (permalink)  
Old 12-20-05, 03:12
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
I dont know what the [..] is all about dont know much about BO but im writing this formula in the formula definition bar in WebIntelligence. it automatically appears when you select an object.

=substr([CSR Reporting Category Description];1;Match([CSR Reporting Category Description];"."))

this did not work, changed locate to match as locate was not an option.
Ive tried changing ; to ' and " to ' but still always returns syntax error

?
Reply With Quote
  #10 (permalink)  
Old 12-20-05, 03:15
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
POSSTR cannot be used either : (
Reply With Quote
  #11 (permalink)  
Old 12-20-05, 03:23
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
=Substr([CSR Reporting Category Description];0;Match([CSR Reporting Category Description];"."))

returns

The expression/sub-expression at position 53 uses an invalid data type. Specify a valid data type. (Error: WIS 10037)

??
Reply With Quote
  #12 (permalink)  
Old 12-20-05, 11:07
murali_sb murali_sb is offline
Registered User
 
Join Date: Dec 2005
Posts: 39
is this really DB2 query then? maybe you need to consult Web Intelligence/BO documentation.
Reply With Quote
  #13 (permalink)  
Old 12-21-05, 02:33
shinny shinny is offline
Registered User
 
Join Date: Mar 2005
Location: Ireland
Posts: 35
Its a DB2 database that is why i coose this forum
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