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 > looking for DB2 function equivalent to INSTR() in Oracle (was "Please Help")

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-19-07, 06:04
kalpana_mur kalpana_mur is offline
Registered User
 
Join Date: Jun 2007
Posts: 4
Exclamation looking for DB2 function equivalent to INSTR() in Oracle (was "Please Help")

I am looking for the funtion in Db2 which is equivalent to INSTR() funtion
in Oracle.So far i have looked at funtions "LOCATE" and "POSSTR" in DB2
which provide similar but LESS funtionality than INSTR() in Oracle.I am
using DB2 8.0 .Any help will be greatly apprecitaed.

the INSTR() funtion in Oracle does the following thing ----

instr (string1, string2, [start_position], [nth_appearance])

string1 is the string to search.

string2 is the substring to search for in string1.

start_position is the position in string1 where the search will start. This
argument is optional. If omitted, it defaults to 1. The first position in
the string is 1. If the start_position is negative, the function counts back
start_position number of characters from the end of string1 and then
searches towards the beginning of string1.

nth_appearance is the nth appearance of string2. This is optional. If
omiited, it defaults to 1.
Reply With Quote
  #2 (permalink)  
Old 06-19-07, 08:03
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
There is no equivalent built in function in DB2 for LUW.

Andy
Reply With Quote
  #3 (permalink)  
Old 06-25-07, 06:01
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The only missing pieces are the "n-th appearance" and negative start positions... You can easily implement both in a SQL-bodied function or recursive query.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 06-26-07, 00:27
kalpana_mur kalpana_mur is offline
Registered User
 
Join Date: Jun 2007
Posts: 4
Thank u. I used cast(?,varchar(255)) and it worked.
Reply With Quote
  #5 (permalink)  
Old 06-26-07, 00:41
kalpana_mur kalpana_mur is offline
Registered User
 
Join Date: Jun 2007
Posts: 4
Red face Help required

one of the column in table called reports in db2 database was changed from organization_sequence_bigint to organization_sequence_number.
therfore the queries which access this table reports is giving the following error.

10:03:03 [SELECT - 0 row(s), 1.371 secs] [Error Code: -668, SQL State: 57016] Operation not allowed for reason code "7" on table "DASUSR1.REPORTS".

What is the problem?
Reply With Quote
  #6 (permalink)  
Old 06-29-07, 03:03
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have a look at error message SQL0668, which reads:
Quote:
$ db2 "? sql668"

SQL0668N Operation not allowed for reason code
"<reason-code>" on table "<table-name>".

Explanation:

Access to table "<table-name>" is restricted. The cause is based
on the following reason codes "<reason-code>":

7 The table is in the reorg pending state. This can occur after
an ALTER TABLE statement containing a REORG-recommended
operation.

User Response:

7 Reorganize the table using the REORG TABLE command (note that
INPLACE REORG TABLE is not allowed for a table that is in the
reorg pending state).

sqlcode : -668

sqlstate : 57007
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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