Reason behind hashcode for String

I want to know how the formula was designed for the hashcode of String class.
Also as a continuation, is there a difference between the generation of hashcode in different versions of java (may be in other classes as well) ? :)

sabre150 wrote:-
public class TwoStringWithTheSameHashCode
public static void main(String[] args)
int hash1 = "ABCDEa123abc".hashCode();
int hash2 = "ABCDFB123abc".hashCode();
System.out.println(hash1 + " " + hash2);
Good point. I mean, it's not impossible to get collisions. I have to admit I didn't really sit and analyze the function to try to calculate the probability. So the answer may very well be that it tends to spread the hashes out in practice. Well, at least, that's the whole idea, right? So maybe there is a better algorithm for it.
As for full uniqueness, that's impossible in general -- that's the definition of a hashcode, after all (unless your hashcode is just to return the same value). There are, however, industry-standard algorithms that generate pretty large sets of possible hashcodes (MD5, SHA1, SHA256...)
In the end, the best hashcode depends on your data set and what you're willing to sacrifice. If you have a data set of only 10 distinct values, you're (theoretically) not going to benefit much from a hash much at all. If you have millions/billions/etc of unique values (say, all strings up to 1024 chars), then a hashcode which pushes it into 256 bytes is going to collide eventually if you put every possible string into it. The trick is much collision you're okay with, how big your target space is, and how much work you want to do to get a hash.

Similar Messages

  • I bought whatsup on 5th of june and my account has been debited for INR 60.  Today(8th june) again my account has been debited for INR 55.  I want to know the reason behind it?

    i bought whatsup on 5th of june and my account has been debited for INR 60.  Today(8th june) again my account has been debited for INR 55.  I want to know the reason behind it?

    You could go to the app store on your phone then tap on the update button bottom right then tap on purchases at the top and see what has been bought on your phone also you could goto itunes in you romputer and click on your account once itunes store has been selected from the left then click on account and enter your password and scroll down to Purchase history and click on "see all" and have a look at recent purchases

  • Does anybody know a reliable hashCode-function for strings?

    Hello,
    I would like to exchange hashcodes between clients and server, both running at different jre's (even msjvms are running it) - and for the same string they should be identical.
    Javadoc mentions that Object.hashCode() may vary from imlpementation, but I would need an implementation which would be consistent across jvms.
    Does anybody know a reliable function which does compute a integer-hash-value out of string?
    Reliable means that its quite unlikely that two different strings get the same hash-value (although I know this cannot be guaranteed 100%).
    Thanks in advance, lg Clemens

    Even the hashcode() API points out that
    it is just a suggestion that it returns the memory
    address of an object, an implementation that might
    differ from other JVMs. So if you'd rely on that
    behaviour, you'd need to check JVM vendors as well.True, and that is why you shouldn't rely on the fact that Object.hashCode returns the memory address, but I think it's safe to rely on the fact that String.hashCode returns the same hashCode on all platforms (if they are using the same Java version).
    The javadoc for String.hashCode says:
         * Returns a hash code for this string. The hash code for a
         * <code>String</code> object is computed as
         * <blockquote><pre>
         * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
         * </pre></blockquote>
         * using <code>int</code> arithmetic, where <code>s</code> is the
    * <i>i</i>th character of the string, <code>n</code> is the length of
    * the string, and <code>^</code> indicates exponentiation.
    * (The hash value of the empty string is zero.)
    * @return a hash code value for this object.
    So that contract must be fulfilled by all implementations.
    Kaj

  • I love my Verizon, yes I really love my verizon that the only reason behind this story

    Hi there,
    I love my Verizon, yes I really love my verizon that the only reason behind this story but the service made me hate the same Verizon. When I took the Verizon connection I was so happy because I am doing a right thing. but now I feel the same that I have done a wrong thing.
    1. Gift Card is reaching me till now.. hope I will get it when my contract ends!!!
    I ordered this FiOS service by February and got a offer of 200$ gift card from Best Buy... I am getting the card till now.. no tracking.. no response... whenever I call them the response is really very nice. the call will be on hold for about an hour and then a voice will come then I have to explain the situation for about 20 mins, then he/she find the gift card is delivered to some other address. Then give me a waiting period of 3 weeks. I have waited atleast 5 * 3 weeks, between these period of time atleast 20 calls to you guys.
    Don't you think how lucky I am... ha
    A GREAT customer service.. which made me so happy. Thank you one and all.
    2. Billing Issues:
    I took a plan called FiOS freedom bundle offer. It costs  $ 94.99 when I ordered, but later I came to know that is excluding taxes, that is fine so the total expected was some where around 105 to 110 $. But how great it worked for me... I haven't paid that less amount till now. see how much I paid till now...
    Month Amount
    March $189.53
    April   $120.07
    May   $120.07
    June  $113.40
    July   $113.39
    and now the story begins again...
    August $152.83
    Whenever I call the customer care to ask clarification they will tell "**this will not be charged from next month". But there will be no answer why that was charged. I never even thought of writing this big story to some one like you but I am really sorry to say if this continues then your business will never endup in success.
    Please consider this as me one and only request and do something.
    $200 worth of Best Buy gift Card and
    Take away all the additional options in my package and give me the bundle offer bill I ordered $94.99 + Taxes. I wont encourage paying not even one dollar more than that.
    With lots of worries on my ever best Verizon,
    James {personal information removed for privacy}
    Message Edited by CharlotteS on 08-14-2008 08:35 PM
    Solved!
    Go to Solution.

    Since this is a user Forum, James, you'll probably need to contact Verizon again.  Contact Us  
    The only thing I can offer is this link:  http://www22.verizon.com/awaitingfreereward/  
    Good luck and sorry we couldn't be more of a help.

  • First call attempt fails with 12000; reason="Routes available for this request but no available gateway at this point"

    We've installed a new Audiocodes Mediant 1000B gateway for our customer.  They only have about 6 users enabled for Enterprise voice and using Lync for all calls.  They have an intermittent problem whereby the first call attempt to a number on the
    PSTN fails with 12000; reason="Routes available for this request but no available gateway at this point".  There is only one PSTN gateway installed.  All routes point to this gateway.  What I found initially is that the calls
    were failing after 10 seconds which is the default "failovertimeout" in the OutboundRouting.exe.config.  I found this post http://voipnorm.blogspot.co.uk/2012/06/lync-2010-gateway-timeout-call-failures.html and
    changed the value to 20 seconds.  Subsequent failures failed after 20 seconds (the new value).  The interesting thing is that the second attempt even a couple of seconds later succeeds.  My Lync server event log has 46046 "A call to a PSTN
    number failed due to non availability of gateways." for the failed call and 46047 "A PBX gateway is now responding to requests after some failures." for the successful call moments later.
    My environment is Lync 2010.  A single enterprise edition Front End with collocated mediation.  The server is virtual and in a different physical location to the gateway.  The two sites are connected via a LES1000.  The RTT between the
    sites is very low so it isn't necessarily networking.
    In the Syslog output on the Audiocodes we don't see the call even reach the gateway.  It's likely that Lync has simply marked the gateway as down and doesn't route the first call.  Then it wakes up and marks it as up and routes the next call.
    Update wise I'm on 4.0.7577.183, 199 and 217 for those that are up to date and the only components that are behind say that 223 is available.  Those being Core Components, Lync Server, Conferencing Server and Web Components.
    As I said, this is intermittent, apparently doesn't happen for every user (which I don't buy), but is easily replicated on request.
    I definitely think changing the failovertimeout value has reduced the number of failures.  But realistically I don't want users sitting there for 20 seconds before their call fails.  Or 19 seconds for the call to route.
    I've found a few posts on this and similar issues.  I don't get the 25051 or 25052 errors.
    Any help gratefully appreciated.
    Regards
    Randy Chapman
    Best Regards Randy Chapman

    Try to change the value of Failovertimeout to 1000.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Could you tell me what is the reason behind all this?

    Hi
      Zp0001, we have 510 pcs in stock, but for some reasons we can’t commit the orders that we have on the system. When we go into a xyz order 308 for example), the system commits only to February, even if we could do a partial shipment.
    Could you tell me what is the reason behind all this?

    Please look into availability check for that particular material,
    based on the availability check the system determines whether to
    confirm the sales order (if the sales order qty > inshe stock (either
    rejection/partial confirmation - depends upon the availability check),
    followed by determination of delivery date

  • Reason behind Difference in cardinality from estimation.

    Hi,
    Below is the plan and the dbms_xplan.display_cursor out put for the same. I am getting difference in cardinality estimation which is major one. What must be the reason behind the same. i have verified that all the stats for index and table are updated.
    SELECT
            XDS_XCHGTRANSACTIONID,
             XDS_TXSTATE,
             XDS_ACTIONDATE,
             XDS_INBOUND,
             XDS_DOCTYPE,
             XDS_DOCSUBTYPE
        FROM a, b, c   WHERE     b.XCHGPROFILEPK = a.XDS_XCHGPROFILEPK
             AND b.PAYID = c.PAYID
             AND a.XDS_TXSTATE IN ('PARTIAL', 'COMPLETE', 'PENDING')
             AND CREATINGAPP = 'DISB'
             AND COMPANYPK = 15144193056
             AND a.XDS_ACTIONDATE BETWEEN 1337890976198 AND 1338392336151
             AND a.XDS_YEAR IN 2012
             AND a.XDS_MONTH IN 5
    ORDER BY a.XDS_ACTIONDATE
    Index IDX_XDS_N1 is on a(XDS_MONTH,XDS_YEAR,XDS_ACTIONDATE)
    | Id  | Operation                      | Name                    | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |*  1 |  TABLE ACCESS BY INDEX ROWID   | c                       |      1 |      1 |      0 |00:00:00.68 |    2284 |    405 |
    |   2 |   NESTED LOOPS                 |                         |      1 |      1 |      1 |00:00:00.68 |    2284 |    405 |
    |   3 |    NESTED LOOPS                |                         |      1 |      1 |      0 |00:00:00.68 |    2284 |    405 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| a                       |      1 |      1 |      0 |00:00:00.68 |    2284 |    405 |
    |*  5 |      INDEX RANGE SCAN          | IDX_XDS_N1              |      1 |      1 |   2280 |00:00:00.12 |      30 |     28 |
    |*  6 |     TABLE ACCESS BY INDEX ROWID| b                       |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |
    |*  7 |      INDEX UNIQUE SCAN         | P_XCHGPROFILE           |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |
    |*  8 |    INDEX RANGE SCAN            | IDX_PAYID               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |
    Predicate Information (identified by operation id):
       1 - filter("COMPANYPK"=15144193056)
       4 - filter(("XDS_TXSTATE"='COMPLETE' OR "XDS_TXSTATE"='PARTIAL' OR "XDS_TXSTATE"='PENDING'))
       5 - access("XDS_MONTH"=5 AND "XDS_YEAR"=2012 AND "XDS_ACTIONDATE">=1337890976198 AND
                  "XDS_ACTIONDATE"<=1338392336151)
       6 - filter("CREATINGAPP"='DISB')
       7 - access("XDS_XCHGPROFILEPK"="XCHGPROFILEPK")
       8 - access("B"."PAYID"="C"."PAYID")

    930254 wrote:
    Hi,
    Below is the plan and the dbms_xplan.display_cursor out put for the same. I am getting difference in cardinality estimation which is major one. What must be the reason behind the same. i have verified that all the stats for index and table are updated. Can't say based on what you have posted so far. Some suggestions/questions:
    1) Do you get same difference if you simplify the query so that it includes only one table (i.e. a) with predicates on that table?
    2) DB Version ?
    3) Is XDS_ACTIONDATE supposed to be a date stored as NUMBER?

  • What can be the reason behind getting the Dialer Detail

    what can be the reason behind getting the Dialer Detail
    CallResult = 2 "Error condition while dialing"

    Sorry buddies, for bothering you, without providing enough details.
    We are running Java based ERP for our client, with Oracle Application Server 10.1.3.1.
    OS is Sun Solaris 10
    Database is Oracle 11g
    We found the following errors in /product/10.1.3.1/OracleAS_1/Apache/Apache/logs/error_log file.
    [Mon Jun  8 11:01:41 2009] [error] [client <ipaddr>] [ecid: 1244439100:<server ip>:17034:0:70,0] mod_oc4j: request to OC4J iisapp:8890 failed: AJP error: bad header
    [Mon Jun  8 11:11:36 2009] [error] [client <ipaddr>] [ecid: 1244439685:<server ip>:16312:0:2255,0] request failed: error reading the headers
    [Mon Jun  8 13:25:52 2009] [warn] [client <ipaddr>] oc4j_socket_recvfull timed out
    We have done the following changes recently
    => KeepAlive TImout changed to 5 secs from default 15
    => Changed the MaxPermSize to 512M in opmn.xml
    => Our Max Clients setting changed to 350 from default 150.
    Can someone help us by providing the possible reasons for the occurence of said errors.
    Regards,

  • Byte[] character encoding for strings

    Hi All,
    I tried to convert a string into byte[] using the following code:
    byte[] out= [B@30c221;
    String encodedString = out.toString();
    it gives the output [B@30c221 when i print encodedstring.
    but when i convert that encodedstring into byte[] using the following code
    byte[] output = encodedString.getBytes();
    it gives different output.
    is there any character encode needed to give the exact output for this?

    Sorry, but the question makes no sense, and neither does your code. byte[] out= [B@30c221;
    String encodedString = out.toString(); The first line is syntactically incorrect, and the second should print something like "&#x5B;B@30c221", which isn't particularly useful. The correct way to convert a String to a byte[] is with the getBytes() method. Be aware that the byte[] will be in the system default encoding, which means you could get different results on different platforms. To remove this platform dependency, you should specify the encoding, like so: byte[] output = encodedString.getBytes("UTF-8"); Why are you doing this, anyway? There are very few good reasons to convert a String to a byte[] within your code; that's usually done by the I/O classes when your program communicates with the outside world, as when you write the string to a file.

  • "buffer too small for string or missing null byte" inserting CR in excel

    I have created a Crystal Report based on below stored procedure.
    DELIMITER $$
    DROP PROCEDURE IF EXISTS `ww_test`.`PRD_Data_sp` $$
    CREATE PROCEDURE `ww_test`.`PRD_Data_sp` (in cyear int, in cmonth int, in groupby varchar(20), in Inv_type varchar(4))
    BEGIN
      select
              CASE WHEN groupby='Date' THEN  (p.FKDAT)
                   WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
              END ,
              sum(p.QTYSAM),
              sum(p.CASESSOLD),
              sum(p.SOLDDOL)
              from ww_test.prd_data p
              where (month(p.FKDAT)=cmonth and year(p.FKDAT)=cyear) and
                     ((p.FKART) is null or not(p.FKART in ("FAZ","ZMBB","FAS",Inv_Type))) and
                     ((p.AUART) is null or not(p.AUART in ("ZMBB")))
              Group by
                  CASE WHEN groupby='Date' THEN  (p.FKDAT)
                       WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
                  END
              Order by
                  CASE WHEN groupby='Date' THEN  (p.FKDAT)
                       WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
                  END;
    END $$
    DELIMITER ;
    I have used Add Command to create report based on this.
    call ww_test.prd_data_sp({?Year},{?Month},{?GroupBy},{?InvType});
    I am able to refresh the report in crystal and as well in Infoview without any problem.
    But when i try to insert this report in Excel using Live Office it gives me error. I able to insert other crystal reports without any problem.
    An error occurred while opening the report. The report does not exist; you have insufficient rights to open the report; or you cannot make a connection to the BusinessObjects Web Service. (LO 02010)
    Failed to open report (LO 26619)
    Cannot open report document 
    Buffer too small for string or missing null byte.
    can anyone suggest where i am going wrong? Any input is appreciated.
    Crystal Reports 2008
    Live Office XI 3.1
    BOEdge XI 3.1
    Xcelsius 2008
    Thanks ,
    Madhavi

    With the CurrentValue method
    Crpt.ParamFields[3].CurrentValue := memo1.Text;
    Is there another solution ?

  • Buffer too small for string - Crystal Report for Vs2010

    Hello,
        I have recently upgrade my VS2010 project to Crystal Report for Visual Studion 2010.
        I have some reports that contains more than 512 characters in the Report Comments section.
        When I try to do a RptDoc.SaveAs(vPath, false) the following error is raised:
    Buffer too small for string or missing null byte.
          at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.SaveAs in :line 0
          at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.SaveAs in :line 0
          at CrystalDecisions.CrystalReports.Engine.ReportDocument.SaveAs in :line 0
        This line SaveAs was working has expected with Crystal Report 2008. Any idea on why it is not working anymore.
    Thank you.
    Charles

    Hello Don,
        I have start a little project to retest the behavior.
       I have create a new report in Crystal Report 2008 just by clicking New, Finish and Save.
       In a new Windows Application in Vs2010 ,I have added the following Crystal Report Reference.
        CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0
       CrystalDecisions.Shared, Version=13.0.2000.0
    I have then try the following code and found out the limit of ReportComment is 511 but in the Crystal Report 2008 designer and runtime the limit did not apply.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim objRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
          Dim i As Integer = 0
          Try
             objRpt.Load("c:\temp\empty.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
             Do
                i += 1
                objRpt.SummaryInfo.ReportComments = New String("X", i)
             Loop
             objRpt.SaveAs("c:\temp\dfh_save.rpt", False)
          Catch ex As Exception
             MsgBox("i: " & i)
             MsgBox(ex.Message)
          End Try
    End Sub
         I am able to put has many characters if I insert the report in the Vs2010 Solution.
         If you prefer I can send you my little project.
    Thank you.
    Charles
    <code> should be
    Edited by: Don Williams on Feb 4, 2011 12:47 PM

  • Program for string comparision in ABAP

    Hi,
    I require a program in abap for string comparision

    Comparing Strings
    Similarly to the special statements for processing strings, there are special comparisons that you can apply to strings with types C, D, N, and T. You can use the following operators:
    <operator>
    Meaning
    CO
    Contains Only
    CN
    Contains Not only
    CA
    Contains Any
    NA
    contains Not Any
    CS
    Contains String
    NS
    contains No String
    CP
    Contains Pattern
    NP
    contains No Pattern
    There are no conversions with these comparisons. Instead, the system compares the characters of the string. The operators have the following functions:
    CO (Contains Only)
    The logical expression
    <f1> CO <f2>
    is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not occur in <f2> .
    CN (Contains Not only)
    The logical expression
    <f1> CN <f2>
    is true if <f1> does also contains characters other than those in <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
    CA (Contains Any)
    The logical expression
    <f1> CA <f2>
    is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
    NA (contains Not Any)
    The logical expression
    <f1> NA <f2>
    is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that occurs in <f2> .
    CS (Contains String)
    The logical expression
    <f1> CS <f2>
    is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    NS (contains No String)
    The logical expression
    <f1> NS <f2>
    is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    CP (Contains Pattern)
    The logical expression
    <f1> CP <f2>
    is true if <f1> contains the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:
    for any character string *
    for any single character +
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify
    characters in upper and lower case
    the wildcard character "" (enter # )
    the wildcard character "" (enter # )
    the escape symbol itself (enter ## )
    blanks at the end of a string (enter #___ )
    NP (contains No Pattern)
    The logical expression
    <f1> NP <f2>
    is true if <f1> does not contain the pattern <f2>. In <f2>, you can use the same wildcards and escape character as for the operator CP.
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    DATA: F1(5) TYPE C VALUE <f1>,
          F2(5) TYPE C VALUE <f2>.
    IF F1 <operator> F2.
       WRITE: / 'Comparison true, SY-FDPOS=', SY-FDPOS.
    ELSE.
       WRITE: / 'Comparison false, SY-FDPOS=', SY-FDPOS.
    ENDIF.
    The following table shows the results of executing this program, depending on which operators and values of F1 and F2.
    <f1>
    <operator>
    <f2>
    Result
    SY-FDPOS
    'BD '
    CO
    'ABCD '
    true
    5
    'BD '
    CO
    'ABCDE'
    false
    2
    'ABC12'
    CN
    'ABCD '
    true
    3
    'ABABC'
    CN
    'ABCD '
    false
    5
    'ABcde'
    CA
    'Bd '
    true
    1
    'ABcde'
    CA
    'bD '
    false
    5
    'ABAB '
    NA
    'AB '
    false
    0
    'ababa'
    NA
    'AB '
    true
    5
    'ABcde'
    CS
    'bC '
    true
    1
    'ABcde'
    CS
    'ce '
    false
    5
    'ABcde'
    NS
    'bC '
    false
    1
    'ABcde'
    NS
    'ce '
    true
    5
    'ABcde'
    CP
    'b'
    true
    1
    'ABcde'
    CP
    '#b'
    false
    5
    'ABcde'
    NP
    'b'
    false
    1
    'ABcde'
    NP
    '#b'
    true
    5
    goto sap library if intsalled in ur system and check the above one....

  • Wat should be the regular expression for string MT940_UB_*.txt to be used in SFTP sender channel in PI 7.31 ??

    Hi All,
    What should be the regular expression for string MT940_UB_*.txt and MT940_MB_*.txt to be used as filename inSFTP sender channel in PI 7.31 ??
    If any one has any idea on this please let me know.
    Thanks
    Neha

    Hi All,
    None of the file names suggested is working.
    I have tried using - MT940_MB_*\.txt , MT940_MB_*.*txt , MT940*.txt
    None of them is able to pick this filename - MT940_MB_20142204060823_1.txt
    Currently I am using generic regular expression which picks all .txt files. - ([^\s]+(\.(txt))$)
    Let me know ur suggestion on this.
    Thanks
    Neha Verma

  • ORA-13223: duplicate entry for string in SDO_GEOM_METADATA table and

    I got the above error while trying to insert a record into the table SDO_GEOM_METADATA. However, when querying this table I did find any duplicate table_name, column_name pair that match with the error.
    Here are the steps that I worked on:
    1. Add a geometry column into an existing table.
    ALTER TABLE GEO_MAP ADD (ORG_GEOM mdsys.sdo_geometry);
    2. Register the new column into mdsys
    insert into USER_SDO_GEOM_METADATA
    values ('GEO_MAP','ORG_GEOM',
    mdsys.sdo_dim_array(
    mdsys.sdo_dim_element('LONG',-180,180,0.00005),
    mdsys.sdo_dim_element('LAT',-90,90,0.00005)
    8307)
    I got the error ORA-13223: duplicate entry for string in SDO_GEOM_METADATA table even there was no such record in there.
    3. I inserted values in the column ORG_GEOM fine.
    4. However, when I tried to create the index for this column I got the error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read
    Please help.
    Thanks.

    SQL> select * from mdsys.sdo_geom_metadata_table;
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    QW_USER1 GEO_REF
    LOC_GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('LONG', -180, 180, .00005), SDO_DIM_ELEMENT('LAT',
    -90, 90, .00005))
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    8307
    MDSYS SDO_CMT_CBK_RTREE_TAB
    GEOM
    SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .000000005), SDO_DIM_ELEMENT('Y',
    SDO_OWNER SDO_TABLE_NAME
    SDO_COLUMN_NAME
    SDO_DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)
    SDO_SRID
    -90, 90, .000000005))
    The situation is we have 2 tables (GEO_MAP, and GEO_REF) that have spatial columns. Everything worked fine until when one of the queries that searched through the table GEO_MAP ran so slow, we decided to rebuild the related spatial index by dropping and recreating it. However, after I dropped it I could not recreated. Keep getting the error:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13203: failed to read USER_SDO_GEOM_METADATA view
    ORA-13203: failed to read
    Any help is very much appreciated.

  • ORA-01460 at REPLACE for strings longer than 4000 characters

    the following code works fine for vVar_Value less than 4001 characters but raises an ORA-01460 for strings equal to or larger than 4001 characters in my environments.
    declare
    vVar_Value VARCHAR2(32000) := '';
    begin
    for i in 1..4000 loop
    vVar_Value := vVar_Value||'X';
    end loop;
    dbms_output.Put_Line('length(vVar_Value): '||length(vVar_Value));
    SELECT REPLACE( vVar_Value, 'NO_MIDDLE_NAME', '') INTO vVar_Value FROM DUAL;
    exception
    when others then
    raise;
    end;
    any advice would be most apprectiated.
    thanks in advance.

    Why the heck are you using select from dual?
    Just use vVar_Value := REPLACE( vVar_Value, 'NO_MIDDLE_NAME', ''); and everything will be OK
    in SQL limit for varchar2 is 4K, only in PL/SQL you can use 32K
    Gints Plivna
    http://www.gplivna.eu

Maybe you are looking for