SDO_NN with SDO_BATCH_SIZE - which may explain different results?

I used the SDO_NN operator with the SDO_BATCH_SIZE parameter. If I add a condition to the where clause, I get very strange results.

I have tried different methods to find the line closest to the point of table LEITUNG_1.


A request has been:
Select / * + INDEX (LEITUNG_L_SI l1) * /.
L1. ObjectId, SDO_NN_DISTANCE (1) leitung_l l1 dist
netza_l n
where
n.F_ID! = 0 and
n.v_id = 1 and n.f_classl = 'LEITUNG_L' and l1.objectid = n.f_id
and
SDO_NN (L1. Shape, sdo_geometry (3001,1034000,SDO_POINT_TYPE (4045.663,339589.059,0), NULL, null);
(= 5', 1) = "TRUE".
and rownum < 10 order by 2;

The result in Oracle 10.2.0.4:
OBJECTID DIST
---------- ----------
4123 9554.33662
4519 10317.6956
4524 10463.8246
4518 10511.4224
4521 10595.0841
4522 10595.0841
4523 10604.4124
4448 10921.7373
4517 10989.0229
9 selected lines.

Elapsed time: 00:00:36.80

The same query with Oracle 11.2.0.1 with the same data:
OBJECTID DIST
---------- ----------
845 7002.66201
846 7010.9314
929 7776.21253
930 7799.44553
931 7800.36867
926 7867.07714
229 9049.54233
231 9126.17628
843 11403.8868

9 selected lines.

Elapsed time: 00:00:14.81

The other request was
Select / * + INDEX (LEITUNG_L_SI l1) * /.
L1. ObjectId, SDO_NN_DISTANCE (1) l1, n netza_l leitung_l dist
where
-n.f_id! = 0 and
n.v_id = 1 and n.f_classl = 'LEITUNG_L' and l1.objectid = n.f_id
and
SDO_NN (L1. Shape, sdo_geometry (3001,1034000,SDO_POINT_TYPE (4045.663,339589.059,0), NULL, null);
(= 5', 1) = "TRUE".
and rownum < 10 order by 2;


OBJECTID DIST
---------- ----------
206848.000261885
26259.000272029
167419 1.60356646
24910 15.2090952
26258 15.2090952
206527 25.6339523
213233 25.752101
206526 26.7804052
70573-26.8646323

9 selected lines.


The results of 10.2.0.4 and 11.2.0.1 are identical. These results are correct.

Without the condition "n.f_id! = 0", that the query works correctly, with the status of the query gives strange results.
The condition "n.f_id! = 0" should not have any influence on the result because there is no record with f_id = 0.

Other forms of find nearest objects:
If I use the parameter SDE_NUM_RES the query gives correct results the same with or without this condition:

Select / * + INDEX (LEITUNG_L_SI l1) * /.
L1. ObjectId, SDO_NN_DISTANCE (1) l1, n netza_l leitung_l dist
where
n.F_ID! = 0 and - same result without this condition
n.v_id = 1 and n.f_classl = 'LEITUNG_L' and l1.objectid = n.f_id
and
SDO_NN (L1. Shape, sdo_geometry (3001,1034000,SDO_POINT_TYPE (4045.663,339589.059,0), NULL, null);
(= 15', 1) = "TRUE".
order by 2;

OBJECTID DIST
---------- ----------
206848.000261885
26259.000272029
167419 1.60356646
24910 15.2090952
26258 15.2090952
206527 25.6339523
213233 25.752101
206526 26.7804052
70573-26.8646323

9 selected lines.

Elapsed time: 00:00:00.12


If I use SDO_WITHIN_DISTANCE to get the closest objects, all queries
(with or without 'n.f_id! (= 0' condition 10 Oracle or Oracle 11) gives the same correct results:

Select / * + INDEX (LEITUNG_L_SI l1) * /.
L1. ObjectId,
sdo_geom.sdo_distance (L1. Shape, sdo_geometry (3001,1034000,SDO_POINT_TYPE (4045.663,339589.059,0), NULL, null), 0.0001)
Dist
of l1, n netza_l leitung_l
where
n.F_ID! = 0 and - same result without this condition
n.v_id = 1 and n.f_classl = 'LEITUNG_L' and l1.objectid = n.f_id
and
sdo_within_distance (L1. Shape, sdo_geometry (3001,1034000,SDO_POINT_TYPE (4045.663,339589.059,0), NULL, null);
"distance = 27') = 'TRUE" ".
order by 2
;
OBJECTID DIST
---------- ----------
206848.000261885
26259.000272029
167419 1.60356646
26258 15.2090952
24910 15.2090952
206527 25.6339523
213233 25.752101
206526 26.7804052
70573-26.8646323

9 selected lines.

Try the following:

However, if the column in the WHERE clause predicate specifies a non-space column in the table for geometry1 with an associated index, make sure that this index is not used by specifying the NO_INDEX indicator for this index. For example, if there was an index named COLA_NAME_IDX set to the NAME column, you must specify the flags in the previous example as follows:

SELECT / * NO_INDEX (c cola_name_idx), INDEX (c cola_spatial_idx) * / +.
c.mkt_id, c.name... OF cola_markets c,...;

(From 10.2 and 11.2 manual dedicated to the sdo_nn)

Jack

Tags: Database

Similar Questions

  • Click right does not work with Firefox, which may be the problem is Firefox or my computer?

    Click right does not work with Firefox, which may be the problem is Firefox or my computer?

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • Start 2011 13 "Macbook Pro with overheating which may be responsible for problems of logical memory board or app... not addressed in repair under warranty for MBP 15 &amp; 17

    My early 2011 MBP 13 "took 2 battery replacements and is suddenly showing app memory problems, stop suddenly, extremely slow performance... etc.  Note 15 and 17 "in early 2011 MBP are part of a free replacement/repair program with Apple after many years of problem reports and legal action.

    Is my 13 "also part of this clear problem or I am the GROUND?

    Are what program you referring?

    http://www.Apple.com/support/MacBookPro-videoissues/

  • When you try to find the IP address of my computer, I see two different results with two different numbers. Which is accurate?

    original title: a different output for ping - an IP address

    I am trying to determine the name of the computer to an IP address

    When I open a command prompt in a computer (Windows XP connected to our domain) and type ping - a [IP address], I get a result

    When I open a command prompt in another computer (Windows Server 2008 connected to the WORKING group) and type ping - a [IP address], I get a different result

    And there are other times when ping - [IP address] will display the name of the computer on a computer (usually the Windows Server 2008), but not the other

    I tried to google

    1. why this happens

    2. what result is correct

    Please specify.

    The order of DNS in Windows name resolution is as follows:

    1. Name of the local host (file Hosts Local generally in c:\windows\system32\drivers\etc\hosts)
    2. Cache Client DNS resolution
    3. DNS server
    4. Cache of NetBIOS names
    5. WINS server
    6. NetBIOS broadcasts
    7. File LMHosts (same location as the HOSTS file)

    The reason you get different results could be because machines could be on different subnets (different results for broadcast), using a different DNS server machines or are configured for different WINS servers, or the names are already cached because of prior activity.

    HTH,
    JW

  • Display different results with if statements

    Hello

    I'm doing a very simple logic but can't figure out how to do visually in LabView. Please take a look in the file. As you can see on the right, I have a group of 9 possibilities, each of them being true I want the COMPOUND NUMBER indicator to show a different result. I tried to use the structure of the case, but I could not the icon of the indicator in other sous-schemas. I also thought about putting the results in a table and choose the element whereby the possibilities.

    But I'm sure there is an easier way. Help, please.

    Thank you

    LD

    You put the indicator of terminal outside the structure of the case.  Then each case son its respective result in the tunnel leading out of the structure of the case to the indicator.

    (Alternative, but not recommended, use a local variable of the indicator in all other cases, if you use the terminal in one of the cases.)

  • Different results when contacting 11g DB using various connection methods

    Greetings:

    First of all, thank you in advance for any help you can provide.

    I'm looking for help to determine why certain methods of connection to a working DB production 11.2.0.3.0 64-bit, while others do not.  I tried 7 connection methods, some work, some give an ORA-12541: listener TNS:no error.  When connecting to a test instance, all 7 work very well.

    I'm not a server admin, but the following information obtained from them: both servers are running Linux RedHat Enterprise Server 5.10 (Tikanga).  Both run Oracle 11 g Enterprise Edition 11.2.0.3.0 64 bit.  Each is on a different subnet.  Each has a different DNS suffix up to the last section of the suffix, which is the same on both.  I don't know if the firewall rules are different.  Production server is a physical box, test server is a virtual machine.

    Results below are attempts to connect to the production server made from my Win7 64-bit workstation.  Once again, all attempts to test server are successful.

    Method                                                                                                      Result

    ODP.net 12.1.0.1.0 or 12.1.0.1.2 as an object in PowerShell 32 or 64 bit ORA-12541 .net

    . UDL file by using the provider, Oracle OLE DB of the ODAC 64bits 11.x or ORA-12541 12.x

    SqlPlus of Oracle Instant Client 11.x or ORA-12541 12.x

    Toad with entry in file TNSNames.ora success

    SQL Developer using the success TNSNames.ora file entry

    ODBC System DSN using Oracle 11 g pilot success

    TNSPing with entry in file TNSNames.ora success

    So, what's different in the methods of connection or network protocols between these methods that fail and those who succeed?  Our Oracle DBA has tried to help me and claims that the file of the listener on the server is correctly configured.  It seems to be useful, so I don't think it's brushing me off.  I did not have access to check it myself, so must continue in the event that it is.  So I'm assuming that the TNS listener error is generated because my traffic does not reach the DB rather than the listener being misconfigured file.  However, if

    My ultimate goal is to connect to prod using ODP.net in the PS script to make read-only SQL queries.  Works very well with the test, but of course, this data is not current.

    Thanks for any help! -EW

    EW, were all the client tries the same machine or different machines?  I hope your problem is either the entry in the file tnsnames.ora for connections of problem which can be different even from other tools on the machine even if multiple Oracle homes exists on the client.  Check the files tnsnames.ora entries.  If host names are referenced, verify that the client can recognize the hostname (DNS).  You may need to use an IP address instead.  Here's a more complete list of the possible causes of this problem.

    - -

    * Action:

    -If you are using local naming (TNSNAMES. ORA file):

    S ' ensure that "TNSNAMES" is cited as one of the values of the

    NAMES. DIRECTORY_PATH parameter in the Oracle Net profile

    (SQLNET. ORA)

    -Check that a TNSNAMES file. ORA file exists and is in good

    Directory and is accessible.

    -Make sure that the name of the network used as the connect identifier service

    It exists in the TNSNAMES file. ORA file.

    -Make sure that there are no errors of syntax anywhere in the TNSNAMES file. ORA

    file.  Search for unmatched parentheses or stray characters. Errors

    in a TNSNAMES file. ORA file can make it unusable.

    -If you use the directory naming:

    -Check that "LDAP" appears as one of the values of the

    NAMES. DIRETORY_PATH parameter in the Oracle Net profile

    (SQLNET. ORA).

    -Check that the LDAP directory server is in place and that it is

    accessible.

    -Check that the net service name or the database name used as the

    connect identifier is configured in the directory.

    -Check that the default context used is correct by

    by specifying a full network service name or a unique display name of LDAP

    as the login

    -If you use easy connect naming:

    -Check that "EZCONNECT" appears as one of the values of the

    NAMES. DIRETORY_PATH parameter in the Oracle Net profile

    (SQLNET. ORA).

    -Make sure that the host name, port, and specified service

    are correct.

    -Try putting the identifier of connection between quotation marks.

    //

    - -

    As mentioned that a firewall between the client and the database can cause problems.

    - -

    HTH - Mark D Powell.

  • Loop Finder crash after upgrading to El Capitan.  'Finder close unexpectedly when you use the plug-in finder' - the message really is in Norwegian, so it may be different for the English operating system.

    'Finder close unexpectedly when you use the plug-in finder' - the message really is in Norwegian, so it may be different for the English.  The e is a compatibility issue with dropbox or Google drive in El Capitan?  Those are the plug-ins only that I could find.  Thank you very much.

    Please launch the Console application in one of the following ways:

    ☞ Enter the first letters of his name in a Spotlight search. Select from the results (it should be at the top).

    ☞ In the Finder, select go utilities ▹ of menu bar or press the combination of keys shift-command-U. The application is in the folder that opens.

    ☞ Open LaunchPad and start typing the name.

    Step 1

    For this step, the title of the Console window should be all Messages. If it isn't, select

    SYSTEM LOG QUERIES ▹ all Messages

    in the list of logs on the left. If you don't see this list, select

    List of newspapers seen ▹ display

    in the menu at the top of the screen bar.

    In the upper right corner of the Console window, there is a search box to filter. Enter the name of the application crashed or process. For example, if Safari has crashed, you would enter "Safari" (without the quotes).

    Each message in the journal begins with the date and time when it was entered. Select the messages since the time of the last fall, as appropriate. Copy to the Clipboard by pressing Control-C key combination. Paste into a reply to this message by pressing command + V.

    The journal contains a large amount of information, almost everything that is not relevant to solve a particular problem. When you post a journal excerpt, be selective. A few dozen lines are almost always more than enough.

    Please don't dump blindly thousands of lines in the journal in this discussion.

    Please do not post screenshots of log messages - text poster.

    Some private information, such as your name, may appear in the log. Anonymize before posting.

    Step 2

    In the Console window, clear the search box, and then select

    DIAGNOSIS AND diagnostic USE information reports ▹ user

    (not diagnose them and use Messages) in the list of logs on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points downwards. You will see a list of reports of incidents. The name of each report begins with the name of the process and ends with ".crash". Select the most recent report on the process in question. The content of the report is displayed at right. Allows you to copy and paste to validate all of the content, text, not a screenshot.

    I know that the report is long, perhaps several hundred lines. Please report all this anyway. If the report is only a few lines, make sure that you have disabled the search box.

    If you don't see any report, but you know, he had an accident, you have chosen diagnostic and using the list of Log Messages. INFORMATION on the USE of DIAGNOSTIC AND choose instead.

    In the interest of privacy, I suggest that, before posting, you change the UUID ' anonymous, ' a long string of letters, numbers and dashes in the header of the report, if it is present (it cannot be). "

    Please do not post other types of diagnostic report - they are very long and rarely useful.

    When you post the journal excerpt or the accident report, you might see an error message on the web page: "you have included content in your post that is not allowed", or "the message contains invalid characters." It's a bug in the forum software. Thanks for posting the text on Pastebin, then post here a link to the page you created.

    If you have an account on Pastebin, please do not select private in exposure menu to paste on the page, because no one else that you will be able to see it.

  • Different results from the the DLL source code

    Hi all

    I'm new to this forum and also to labview so understandable...

    Then, I got a source project with many under vi of that graphic plots of excel files. I also got the exe after generation.

    The problem is, if I try to compile this project again, the exe gives me different results than what I already have. They should be the same, because I does no update in the source code.

    Can someone explain this behavior? I don't know anything about how it has been made because the guy who create this left the office... I need to make a few updates, but first of all, I have to build corectly.

    Thank you

    Have you compared the date of the exe file with the date of the source code? Are you absolutely sure that no changes have been made to the source code after the build? The construction specifications are part of the project. Unless you changed something there, builds should be the same.

    You have the source code control? Issues like this should not be a if you make and use wisely.

  • OBIEE logical column has same SQL but returns different results

    I have a SQL query with a case statement that returns the correct results by operating in Oracle SQL Developer. I've created several logical columns in OBIEE, one for each case in the original query. However, the results returned by each logical column OBIEE are radically different from the original SQL query results, even if the SQL code is virtually identical.

    For example, a column logical OBIEE that returns incorrect results contains the following SQL code:

    SUM (CASE when

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '% a %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%B %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%c %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like"% %") or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%G %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like"hour %") or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like"%%J") or

    ("Registration - College". "" Effective colleges F. ("' Postal code ' like '%R %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%s %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%T %') or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like"% %") or

    ("Registration - College". "" Effective colleges F. ("" Postal code "like '%x %') or

    ("Registration - College". "" Effective colleges F. ("' Postal code ' like '%Y %')

    THEN 0 OTHERWISE 1 END)

    The case statement in the original SQL query, which returns the correct results, is as follows:

    CASE

    WHEN (postal_zip_code_permanent like "%%K") or (postal_zip_code_permanent like '% %') or (postal_zip_code_permanent like '%m %') or (postal_zip_code_permanent like '%n %') or (postal_zip_code_permanent like "%p %") THEN "Ontario".

    WHEN (postal_zip_code_permanent like '% a %') or (postal_zip_code_permanent like '%B %') or (postal_zip_code_permanent like '%c %') or (postal_zip_code_permanent like '% %') or (postal_zip_code_permanent like '%G %') or (postal_zip_code_permanent like "%hour") or (postal_zip_code_permanent like "%%J") or (postal_zip_code_permanent like "%%R") or (postal_zip_code_permanent like '%s %') or (postal_zip_code_permanent like '%t %') or (postal_zip_code_permanent like '% %') or (postal_zip_ code_permanent like '%x %') or (postal_zip_code_permanent like "%%Y") THEN "Canada, other than Ontario.

    WHEN (substr(postal_zip_code_permanent,1,1) IN ('1 ', '2', '3', '4', '5', '6' ', 7',' 8 ', ' 9',' 0') or (postal_zip_code_permanent like '%d %') or (postal_zip_code_permanent like '%f %') or (postal_zip_code_permanent like ' % I %') or (postal_zip_code_permanent like "% O") or (postal_zip_code_permanent like "%%Q") or (postal_zip_code_permanent like "%%U") or (postal_zip_code_permanent like ' % W ') or (postal_zip_code_permanent like "%%Z")) THEN 'other')

    WHEN (postal_zip_code_permanent like '% + %') or (postal_zip_code_permanent like '%. %') or (postal_zip_code_permanent like ' %? %') or (postal_zip_code_permanent like '% %') or postal_zip_code_permanent IN ('+ ','.', '?)) (',',') And THEN "Invalid."

    WHEN postal_zip_code_permanent is null THEN 'Blank '.

    Of OTHER postal_zip_code_permanent

    END

    Now I see what the problem was. In the original SQL query, each condition is exclusive, for each record will only be categorized in one of the scenarios WHEN. But in OBIEE, each logical column is autonomous, so some records were classified into more than logical column, even if each logical column was supposed to be exclusive.

  • SDO_NN with distance parameter vs sdo_within_distance

    I had a co-worker ask me what was the difference between the use of the operator of sdo_nn with a specified distance and a sdo_batch_size of 0 vs using sdo_within_distance. I explained the difference of high level but could not find any documentation that was more in depth. Does anyone know if there is any documentation that explains how the sdo_nn with a parameter of distance from the use of sdo_within_distance

    Thank you

    Bobby

    SDO_NN can return rows in increasing order of distance, is not the case with SDO_WITHIN_DISTANCE.

  • Get different results even script according to what VM it hits?

    Hello.

    IM starting to Powershell and PowerCLI, so you will know at what level it is on =)

    I get different results depending on what VM my script hits (whetever they may or may not have more than one drive). I do not understand how I can fix this...

    For example, I created 4 new virtual machines.

    TestVMfirst1 have only a single drive

    TestVM02 have 2 drives

    TestVM03 have 3 discs

    TestVM04 have only a single drive

    My goal is to get a CSV with all disks included. I want the name, the data store and SizeGB, this info I get from Get-hard drive.

    When I run my script to select all 4 virtual machines:

    $VMs = get-cluster-name kluster01 : get-vm-name TestVM *

    -----------------------------------------------------------------------------

    $VMs = get-cluster-name kluster01 | Get-vm-name TestVM *.

    $Results = @)

    {foreach ($VM to $VMs)

    $Result = new-object PSObject

    $Result | Add-Member - membertype NoteProperty-name 'Name' - value $VM. Name

    $VMDiskCount = 1

    Get-$VM hard drive | {foreach}

    $disk = $_

    $Result | Add-Member-'Disc ($VMDiskCount) name' name-value $disk. Name - membertype NoteProperty

    $Result | Add-Member-name '($VMDiskCount) Datastore disk' - value $disk. Filename.Split(']') [0]. TrimStart('[') - membertype NoteProperty

    $Result | Add-Member-name 'Disk ($VMDiskCount) SizeGB' - value ([math]: round ($disk.) CapacityKB / 1 MB))-membertype NoteProperty

    $VMDiskCount ++

    }

    $Results += $Result

    }

    $Results | Select-object * | format-table

    -----------------------------------------------------------------------------

    I get the result with max 1 disc:

    Name(1) name of discDisk data store (1)SizeGB disc (1)
    --------------------------------------------
    TestVMfirst1Hard drive 1DS-20140
    TestVM02Hard drive 1DS-20140
    TestVM03Hard drive 1DS-20140

    But if I run the same thing but with TestVM0 * (selects 4-2 VMs):

    $VMs = get-cluster-name kluster01 | Get-vm-name TestVM0 *.

    -----------------------------------------------------------------------------

    $VMs = get-cluster-name kluster01 | Get-vm-name TestVM0 *.

    $Results = @)

    {foreach ($VM to $VMs)

    $Result = new-object PSObject

    $Result | Add-Member - membertype NoteProperty-name 'Name' - value $VM. Name

    $VMDiskCount = 1

    Get-$VM hard drive | {foreach}

    $disk = $_

    $Result | Add-Member-'Disc ($VMDiskCount) name' name-value $disk. Name - membertype NoteProperty

    $Result | Add-Member-name '($VMDiskCount) Datastore disk' - value $disk. Filename.Split(']') [0]. TrimStart('[') - membertype NoteProperty

    $Result | Add-Member-name 'Disk ($VMDiskCount) SizeGB' - value ([math]: round ($disk.) CapacityKB / 1 MB))-membertype NoteProperty

    $VMDiskCount ++

    }

    $Results += $Result

    }

    $Results | Select-object * | format-table

    -----------------------------------------------------------------------------

    I get this result:

    Name(1) name of discDisk data store (1)(1) name of the disc SizeGB disc (2).Disk data store (2)SizeGB disc (2)
    -------------------------------------------- ----------------------------------------
    TestVM02Hard drive 1DS-201Hard 40 2 discDS-20110
    TestVM03Hard drive 1DS-201Hard 40 2 discDS-20210
    TestVM04Hard drive 1DS-20140

    I miss all my disks on TestVM03, I seems that the first VM sets the limit on how many records can be issued in the table... A dirty solution is to create a model on the first target VM disks, but it seems the wrong way to solve my problem.

    Thanks in advance

    You're conclusion is correct, I'm afraid, the first line determines how many properties, you will see.

    Alternatively, you can sort the lines on the number of properties in descending order.

    Something like that

    $Result | Tri-objet-property {($_ |)} Get - Member). {Count of}-descending | Format-Table

  • DATE arithmetic in v SQL SQL Developer Studio - different results

    Hello

    I want a date picker by default for Monday of this week. I'm using TO_CHAR with a format mask so that should give me the number of the day of the week:

    SELECT SYSDATE, to_char(SYSDATE, 'D')
    FROM dual
    

    I get the APEX SQL workshop,

    09/25/2013  4
    

    bad - today is Wednesday.

    Gives the same code in SQL Developer

    25-SEP-13  3
    

    What is correct.

    Am I missing some APEX here which determines the beginning of the week (Monday Sunday v)?

    Thank you very much

    Brian

    Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production

    APEX 4.2.2.00.11

    Windows Server 2008 R2 Enterprise

    I'm guessing that: (from the Oracle documentation)

    The datetime format element D returns the number of the day of the week (1-7). The day of the week that is numbered 1 is implicitly specified by the initialization parameter NLS_TERRITORY .

    For me:

    Select sysdate, to_char(sysdate,'D'), to_char (sysdate, 'Day') of double;

    25 SEP-13 4 Wednesday

    Which is (for me) correct. (Sunday == 1)

    What have we learned?

    NLS_TERRITORY may be different depending on who/how/when the DB connection is made.

    It's the same as NLS_DATE_FORMAT.

    Solution:

    Never trust anything that depends on them, unless the code explicitly sets the value.

    That's why ALWAYS provide you the date format converting string to date using the TO_CHAR();

    MK

  • Different results of exactly the same query

    Hello

    I wrote a function to calculate the days between 2 dates. If I am running in SQL Developer or directly on the oracle server, I get the results I expected. However, if I run on a client by using ODBC, or PHP connection via the OCI8 extension, I get an incorrect result.

    The function takes 2 parameters: 1st and 2nd date and should output the number of non-working days (weekends and holidays) between 2 dates. The coding is not very pretty, but it does not work very well as I said since the client SQL Developer.

    Here is the code:
    create or replace
    FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE)
    --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays)
    --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013
    
    RETURN NUMBER IS
    BANK_HOLS NUMBER;
        ret NUMBER;
    BEGIN
        SELECT count(mydate) INTO ret FROM 
     (SELECT     TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate
                    FROM DUAL
               CONNECT BY LEVEL < =
                                TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss')
                              - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss')
                              + 1)
         WHERE TO_CHAR (mydate, 'DY') IN ('SAT', 'SUN');
         
         
         select count(mydate) into BANK_HOLS from (
         SELECT     TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss') + LEVEL - 1 mydate
                    FROM DUAL
               CONNECT BY LEVEL < =
                                TO_DATE (todate, 'dd-mon-yyyy hh24:mi:ss')
                              - TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss')
                              + 1
         )
         WHERE TO_CHAR (mydate, 'DD-MM-YYYY') IN 
         ('03-01-2011', 
         '22-04-2011',
         '25-04-2011',
         '29-04-2011',
         '02-05-2011',
         '30-05-2011',
         '29-08-2011',
         '26-12-2011',
         '27-12-2011',
         '02-01-2012',
         '06-04-2012',
         '09-04-2012',
         '07-05-2012',
         '04-06-2012',
         '05-06-2012',
         '12-07-2012',
         '27-08-2012',
         '25-12-2012',
         '26-12-2012',
         '01-01-2013',
         '29-03-2013',
         '01-04-2013',
         '06-05-2013',
         '27-05-2013',
         '12-07-2013',
         '26-08-2013',
         '25-12-2013',
         '26-12-2013'
         );
         ret:= ret + BANK_HOLS;
         
        RETURN ret;
    end;
    The problem is only with certain dates. For example, if I use the date '17-SEP-2012' for the two input parameters, I'm waiting for a result draw. In the SQL Developer client, I get the expected result. However, using ODBC or PHP OCI8 (which I believe is using a direct connection to TNS in the DB), the result returned is '1', which is incorrect ("17-SEP-2012" has been a MONDAY ""). If I use the current date (20-SEP-2012), I get the expected (zero) result in both the SQL Developer client and ODBC/PHP client.

    I also tried to use variants of SYSDATE in place and place the date string, to see if I get different results (i.e. today is 20-SEP-2012, so I used SYSDATE-3 to 17-SEP-2012).

    To be clear, I call the function in a select statement: select (sysdate-3, sysdate-3) non_workdays of the double; or select non_workdays (TO_DATE('17-SEP-2012'), TO_DATE('17-SEP-2012')) of double;

    I have spent hours and hours of troubleshooting this, and it makes me crazy!

    I also checked the view V$ SQLAREA the Oracle DB to see what is actually passed to the ODBC client database engine. I was expecting the statement became corrupted somehow, that's why I get strange results, but this was not the case. The statement in the column SQL_FULLTEXT of V$ SQLAREA, showed exactly the statement I performed on the ODBC Client. I tried with the oracle instantclient and full client (10g).

    Can someone help save my sanity please? I am eternally grateful!

    Sorry for the massive post!

    Published by: user12199535 on 20-Sep-2012 12:20

    Your code is a mess. You convert DATE to DATE, e.g. TO_DATE (fromdate, 'dd-mon-yyyy hh24:mi:ss'). TO_DATE function first parameter is a string, while fromdate is the date. That's why Oracle implicitly converts fromdate to the string of default date format that is client dependent and therefore can produce different results on different customers boxes. In addition, your code is dependent on NLS. If the customer has other date language settings, for example German, Sun and SAT are false. And there is no need to separately calculate the weekends and holidays:

    create or replace
      FUNCTION NON_WORKDAYS(fromdate IN DATE, todate IN DATE)
      --Function to calculate non working days between 2 given dates (Weekends & Bank Holidays)
      --Update: Added in a calendar for bank holidays. Bank holidays are listed to the end of 2013
        RETURN NUMBER
        IS
            BANK_HOLS NUMBER;
            ret NUMBER;
        BEGIN
            SELECT  count(mydate)
              INTO  ret
              FROM  (
                     SELECT  trunc(fromdate) + LEVEL - 1 mydate
                       FROM  DUAL
                       CONNECT BY LEVEL < = trunc(todate) - trunc(fromdate) + 1
                    )
              WHERE TO_CHAR(mydate,'DY','NLS_DATE_LANGUAGE = ENGLISH') IN ('SAT','SUN')
                 OR mydate IN (
                               DATE '2011-01-03',
                               DATE '2011-04-22',
                               DATE '2011-04-25',
                               DATE '2011-04-29',
                               DATE '2011-05-02',
                               DATE '2011-05-30',
                               DATE '2011-08-29',
                               DATE '2011-12-26',
                               DATE '2011-12-27',
                               DATE '2012-01-02',
                               DATE '2012-04-06',
                               DATE '2012-04-09',
                               DATE '2012-05-07',
                               DATE '2012-06-04',
                               DATE '2012-06-05',
                               DATE '2012-07-12',
                               DATE '2012-08-27',
                               DATE '2012-12-25',
                               DATE '2012-12-26',
                               DATE '2013-01-01',
                               DATE '2013-03-29',
                               DATE '2013-04-01',
                               DATE '2013-05-06',
                               DATE '2013-05-27',
                               DATE '2013-07-12',
                               DATE '2013-08-26',
                               DATE '2013-12-25',
                               DATE '2013-12-26'
                              );
            RETURN ret;
    end;
    /
    

    SY.
    P.S. I think that I converted your vacation to literals correctly, but still double check date.

  • Two browsers Webkit, two different results

    I just launched a new website for an insurance company and immediately saw a problem in a series of pages, I was check with Safari (webkit). To verify that the site Web launched and that people can start seeing, I loaded it in Google Chrome.

    Let's not the layout. Here is what I get on several pages in Chrome:

    chrome-comstock.png

    That's what I get in Safari, Firefox and Internet Exploiter 7, 8 and 9:

    safari-comstock.png

    This problem occurs on all pages on the Web site. The home page performs very well.

    Here is where is the Web site: http://comstockinsurance.com/about.html

    I thought that if you check something in Safari, Chrome would be no different.

    Huh. Normally they should make about the same because they use the same good rendering engine that Chrome might use the last engine Webkit built in comparison to Safari. I noticed that the server returns a "404" error number - basically the superfish - left.css is missing as well as the jQuery.tweet.css.

    In any case, if the missing CSS files are not the culprit, it seems that the biggest problem is the

    -in Safari it becomes hidden by browsing in Chrome, it is pushed to the right of the net asset value and causes the provision in question you see. Maybe try to put soemthing between the NAV and the
    to erase any question of float which may be caused by your navigation?

    I hope this helps.

  • I have 2 bookmarks with the same name but different stuff in them. I want to remove one, but pass the contemts remaining bookmark

    I have 2 bookmarks with the same name but different stuff in them. I want to remove one, but pass the contemts remaining bookmark

    This is the first mention you made records. See this - https://support.mozilla.org/en-US/kb/Sorting%20bookmarks#w_rearranging-manually - and move individual bookmarks from one folder to the other folder. You may need to press the Alt key to display the Menu bar and the View menu item.

Maybe you are looking for