Unexpected result.

I think both the queries should return 0 records. But they didn't. Am i missing some points.
select TO_CHAR(SYSDATE,'/dd/MM/yy/') v_no
-- || LPAD(TO_CHAR(NVL(MAX(TO_NUMBER(SUBSTR(LPAD('GLP/30/03/10/00001 ',18,'0'),14))),0)+1),5,'0')
from dual where dual.dummy = '2';
select TO_CHAR(SYSDATE,'/dd/MM/yy/')
|| LPAD(TO_CHAR(NVL(MAX(TO_NUMBER(SUBSTR(LPAD('GLP/30/03/10/00001 ',18,'0'),14))),0)+1),5,'0') v_no
from dual where dual.dummy = '2';
0 rows selected
1 rows selected

Hi,
The second query is using an aggregate function (MAX).
When you use an aggregate function without a GROUP BY clause, the query always returns exactly one row. You may have noticed this before when doing
SELECT  COUNT (*)
FROM    table_x;where table_x has no rows.

Similar Messages

  • Network Model  - Arcs create unexpected results

    Hello Spatial Users,
    I have created a road network using the "Automatic" Network Definition, loaded all the nodes and links, and everything seems to be OK. It all validates, links and nodes have the correct values. It is an undirected network.
    I can create shortest paths, but the issue I'm having is arcs within the links are returning unexpected results. It is as though the start of the arc is used and then it follows the arc and jumps back to the end of the line - so the shortest path is not the shortest with all this jumping from start to finish of the arcs within the line string.
    Do I need to convert the arcs to lines or am I missing something else? I was hoping that because it was 'undirected' this would resolve this issue.
    We are using 11.1.0.6.0.
    Thanks for your help,
    Kerryne

    Hi, Kerryne,
    NDM doesn't support arcs in its spatial path representation. For arcs it will only use start and end pt of the arc. You need to approximate arcs as linear segments for link geometry to get a more accurate path geometry.
    Regards,
    Jack

  • Unexpected result from treenode.getPath() ???

    Hi,
    I am using Jtree in application.
    The tree is as following
    - Desktop
          -C:\
              - Folder1
              - File2
         - D:\I want to expend the node Folder1 as selected node. To do that I got the FileNode Folder1 and do
    TreePath path=new TreeaPath( folder1node.getPath() );
    int row=tree.getRowForPath(path);
    jtreetable.expend(row);
    But the problem is with the path returned. I must get the path [Desktop, C:\, Folder1] but I am getting path [Folder1].
    What I am doing wrong. Is there any other way to expend a particular node programatically ?
    Thanks

    Andy,
    You should contact support with regards to this issue. It is a known
    problem, you can reference CR042529.
    Cheers!
    Adam
    "Andy Kimbrough" <[email protected]> wrote in message
    news:3ae8b1f7$[email protected]..
    randomly I get the following error in my weblogic.log. The server stopsresponding and I get about a million of these entries, what is going on? I
    am running on Linux 6.2....<Error> <Posix Performance Pack>
    <mdw2.neomorphic.com> <myserver> <ExecuteThread: '49' for queue: 'default'>
    <><><00000><Uncaught Throwable in processSockets>java.io.IOException:
    unexpected result from poll: -1at weblogic.socket.PosixSocketMuxer.pool
    (Native Method)at weblogic.socket.PosixSocketMuser.processSocktesat
    weblogic.socket.SocketReaderRequest.executeat
    weblogic.kernel.ExecuteThread.executeat weblogic.kernel.ExceuteThread.run

  • Unexpected Result with Application Process

    Hi Everyone,
    I have an application process which is producing unexpected results. The code is below. What does is, updates one table, then based on that update inserts some data into a different table. The process workes fine. However, when the table gets updated it updates by 2 when it should only update by 1. Does anyone see where i am going wrong?
    Its really anoying lol
    Thanks in Advance
    -N.S.N.O.
    Code*
    BEGIN
    update pzrckt01 set CLK_NEXT_NR = CLK_NEXT_NR+1 where CLK_PARTITION_ID='QWC';
    htp.p('Start debugging');
    htp.p('QWC_KEY_ID : ' ||wwv_flow.g_x02);
    htp.p('SYS_ID : ' ||wwv_flow.g_x03);
    htp.p('QWC_DELETE_CD: ' ||wwv_flow.g_x04);
    htp.p('QWC_CUS_ID : ' ||wwv_flow.g_x05);
    htp.p('COU_ID_QWC : ' ||wwv_flow.g_x06);
    insert into PZRCUT01 (QWC_MYTNT_ID,QWC_KEY_ID,SYS_ID,QWC_DELETE_CD,QWC_ADD_TD,QWC_ADD_USER_ID,QWC_UPDT_TD,QWC_UPDT_USER_ID,QWC_SOFTLOCK_TS,QWC_CUS_ID,COU_ID_QWC) values ((select clk_next_nr from pzrckt01 where CLK_PARTITION_ID ='QWC'),wwv_flow.g_x02,wwv_flow.g_x03,wwv_flow.g_x04,(select sysdate from dual),(select :APP_USER from dual),(select sysdate from dual),(select :APP_USER from dual),(select systimestamp from dual),wwv_flow.g_x05,wwv_flow.g_x06);
    EXCEPTION WHEN OTHERS THEN
    htp.p('Exception');
    htp.p(SQLERRM);
    END;

    Hey,
    There are no triggers on these tables im working with. A way to get around waht im tryin to do is have 2 application processes, one for the update and one for the insert. but to do this i would need them to be fired off using the same button.
    for example in my HTML Header having a function within a function.
    function pzrcut01Insert(){
    function pzrckt01Update(){
    var ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=update_pzrckt01',null);
    var ajaxRequest1 = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=PZRCUT01_INSERT',null);
    ajaxRequest1.addParam('x02', $v('P6_QWC_KEY_ID'));
    ajaxRequest1.addParam('x03', $v('P6_SYS_ID'));
    ajaxRequest1.addParam('x04', $v('P6_QWC_DELETE_CD'));
    ajaxRequest1.addParam('x05', $v('P6_QWC_CUS_ID'));
    ajaxRequest1.addParam('x06', $v('P6_COU_ID_QWC'));
    var Answer = confirm('Are you sure you want to update?');
    if (Answer) {
    gReturn=ajaxRequest1.get();
    if (gReturn) {
    alert(gReturn);
    ajaxRequest1.get();
    alert('Attempted Insert Processed');
    }else{
    alert('Attempted Insert Cancelled');
    would this be possible?
    -N.S.N.O.

  • Method from Random class yields unexpected results

    Hi,
    I understand that the following code should generate a random integer within the range of 0 - 3, but the range is actually 0 - 4. Can someone tell me why it doesn't behave as expected? Could it be the version of Java I'm using?
    Random rand = new Random(47);
    int a = rand.nextInt(4);Thanks!

    gluedtothecomputer wrote:
    You're right! It seemed to be producing unexpected results because I had incorporated a switch statement without breaks (part of my assignment). So, .nextInt() works as expected.
    Thanks!Since you didn't post that code or even allude to it, it would have been hard for use to guess that's what you did, right?
    That's why the best way to ask for help is for you to write and post a SSCCE .
    Keep that in mind for your next post.

  • Colors in JTable - unexpected result when scrolling

    Hi Guys,
    Looks like I'm having a problem with a JTable.
    I have a list of items and they are distinguished by 2 colors (so the end-user can differentiate between them). Anyway, the table colors work ok but when using a JScrollbar the table receives an unexpected result � few of the first items (which are not identical) share the same color.
    anyone?
    Example of an output (Gil will be colored Green, Dan Yellow, James Green�and so forth)
    Gil
    Gil
    Gil
    Dan
    Dan
    Dan
    James
    James
    James
    James
    my code looks like this (I'll appritiate if someone can point out where I can have the html tags to display it correctly)
    aTable = new JTable(dataModel)
    public Component prepareRenderer(TableCellRenderer r, int row, int col)
    Component c = super.prepareRenderer(r, row, col);
    Color bg = Color.YELLOW;
    String[] valuesRaw = (String[]) model.elementAt(row);
    if (changeRround)
    name1=valuesRaw[0];
    changeRround=false;
    name2=valuesRaw[0];
    if (!name1.equals(name2))
    this.switchColor(bg,c);
    changeRround=true;
    return c;
    public void switchColor(Color bg, Component c)
    if (colorSwitcher%2==0)
    bg = new Color(221, 250, 207);
    c.setBackground(bg);
    c.setForeground(Color.BLACK);
    else
    bg = new Color(253, 252, 193);
    c.setBackground(bg);
    c.setForeground(Color.BLACK);
    colorSwitcher++;
    }

    I'm getting there...
            aTable = new JTable(dataModel)
                public Component prepareRenderer(TableCellRenderer r, int row, int col)
                     Component c = super.prepareRenderer(r, row, col);
                     Color bg = Color.YELLOW;         
                     String[] valuesRaw = (String[]) model.elementAt(row);         
                     if (changeRround)
                         name1=valuesRaw[0];
                         changeRround=false;
                         name2=valuesRaw[0];
                     if (name1.equals(name2))
                     else
                         this.switchColor(bg,c);                    
                         changeRround=true;
                     return c;
                 public void switchColor(Color bg, Component c)
                    if (colorSwitcher%2==0)
                        bg = new Color(221, 250, 207);
                        c.setBackground(bg);
                        c.setForeground(Color.BLACK);
                    else
                        bg = new Color(253, 252, 193);
                        c.setBackground(bg);
                        c.setForeground(Color.BLACK);
                    colorSwitcher++;
                }

  • Unexpected results getting data from two fact tables through conformed dim

    Hi all,
    We are getting an unexpected behaviour in our OBIEE 10.1.3.3.3. We have this scenario:
    We have {color:#0000ff}2 fact tables{color}{color:#000000} called F1 and F2. F1 has one measure, f1m1 and F2 has another one, f2m1.
    We have {color:#0000ff}4 conformed dimensions{color}, called D1, D2, D3, Date.
    When we are requesting for individual fact tables, we are getting:
    date d1 d2 d3 f1m1
    dt1 - x - y - z - m1
    dt1 - x - y - z' - m2
    date d1 d2 d3 f2m1
    dt1 - x - y - z - m3
    dt1 - x - y - z'' - m4
    But, trying to obtain a compare scenario, we are getting
    date d1 d2 d3 f1m1 f2m1
    dt1 x y z m1 m4
    Instead of
    date d1 d2 d3 f1m1 f2m1
    dt1 x y z m1 m3
    Looking at query log, we have catched the reason. That's why BI Server is using to solve this request using ROW_COUNT() to join SAWITH0 and SAWITH1 in SAWITH2 result set. So, the order may not be the same in the results sets in every fact table. More or less, generated query is like:
    WITH
    SAWITH0 AS
    (select ....
    from F1),
    SAWITH1 AS
    (select ...
    from F2),
    SAWITH2 AS
    select from (select ...
    ROW_NUMBER() OVER PARTITION (....) c10
    from SAWITH0.d1 full outer join SAWITH1.d1 ....) D1
    {color:#ff0000}where (D1.c10 = 1){color}
    select SAWITH2. ....
    from SAWITH2
    order by c1..c10
    The problems seems to be that BI server is ordering the result sets SAWITH0 and SAWITH1 and getting row number to join this results sets, but this is not getting the correct result.
    Any ideas?
    TIA
    Javier
    {color}
    Edited by: jirazazábal on Mar 13, 2009 2:46 PM

    I have done a logical fact table with two fact table source on it.
    The Sql performed against the database was this one.
    -------------------- Sending query to database named PRODS_AIX (id: <<153418>>):
    WITH
    SAWITH0 AS (select sum(T21296.CONSUMERS_SALES_EURO) as c1,
         T21309.DIVISION_CODE as c2
    from
         DIVISION T21309,
         C_CONSUMERS_SALES T21296
    where  ( T21296.DIVISION = T21309.DIMENSION_KEY )
    group by T21309.DIVISION_CODE),
    SAWITH1 AS (select sum(T21356.ORDER_VALUE) as c1,
         T21309.DIVISION_CODE as c2
    from
         DIVISION T21309,
         DWH_SALES_ORDER_OVERVIEW T21356
    where  ( T21309.DIMENSION_KEY = T21356.DIVISION_KEY )
    group by T21309.DIVISION_CODE)
    select distinct case  when SAWITH0.c2 is not null then SAWITH0.c2 when SAWITH1.c2 is not null then SAWITH1.c2 end  as c1,
         SAWITH0.c1 as c2,
         SAWITH1.c1 as c3
    from
         SAWITH0 full outer join SAWITH1 On nvl(SAWITH0.c2 , 'q') = nvl(SAWITH1.c2 , 'q') and nvl(SAWITH0.c2 , 'z') = nvl(SAWITH1.c2 , 'z')
    order by c1As you can see one select (SAWITH0) for the first fact table C_CONSUMERS_SALES and one select for the second fact table DWH_SALES_ORDER_OVERVIEW (SAWITH1 ) and the two statement are joined with a full outer join.
    I ask me why you have the three select (SAWITH0,SAWITH1 and SAWITH2). Can you please paste the complete SQL performed ?
    Can you tell us also which SQL is performed if you select only the columns from one fact table and not for the other ?
    Regards
    Nico
    http://gerardnico.com

  • Currency Translation. Unexpected result with currency transl indicator 1

    Dear Experts,
    Durring currency translation we get the following result:
    Company  ConsProfitC  PostL     Item         MovType  TransIndLocCur  ValueTransCur       ValueLocCur           ValueGroupCur
    C0803     DUMMY        00          100001     600              USD            100.000,00-            100.000,00-             75.930,14-
    C0803     DUMMY        00     100001     600     1       USD            0,00                         0,00                       1.586,17-
    The first line shows the value translated by accumulated currency translation key, closing rate which is equal 1,317. The second line with the currency translation indicator 1 in completely unexpected.
    Do you have any ideas why we get the second line?
    Thanks.
    Sorry, I've already found the solution. Currency translation indicator 1 is the translation delta between specific value and reference value.
    Edited by: Barrie Roche on Sep 2, 2008 10:45 PM

    The translation indicator 1 is for translation where the translation rate type is different from the reference rate type. Could this item be in the translation method twice with different rate types?

  • Using coldfusion variables in sql queries, some unexpected results.

    I've come across a somewhat perplexing problem. I'd be
    interested to see if the following works for other people:
    <cfset sql_var = "'something','something else'">
    <cfquery name="test" datasource="db">
    select id from table where somename in (#sql_var#)
    </cfquery>
    As it is this produces a sql error - coldfusion tries to run
    the query as
    select id from table where somename in
    (''something'',''something else'')
    That's with double single quotes around each of the strings,
    even though this wasn't specified in the variable sql_var.
    So I tried this:
    <cfset sql_var = "something','something else">
    <cfquery name="test" datasource="db">
    select id from table where somename in ('#sql_var#')
    </cfquery>
    Where variable sql_var only has single quotes in between the
    two strings, and I've added single quotes to the select statement.
    This produces no error, but no results either. The sql being run is
    select id from table where somename in
    ('something','something else')
    Which is exactly as it should be. I copy and paste the exact
    same query into the database and it produces results - but when
    coldfusion runs the query it doesn't. Running the query with no
    quotes produces a sql error, which is what I wopuld expect.
    Which leaves me somewhat at a loss. Anyone got any ideas?
    Running CF 6.1 (I think) using a MySQL database, if that
    makes any difference to anything.

    That's with double single quotes around each of the strings,
    even though this wasn't specified in the variable sql_var.
    In Coldfusion, 'something' and "something" are the same
    thing. You should expect that Coldfusion could switch from one to
    the other.
    Where variable sql_var only has single quotes in between the two
    strings, and I've added single quotes to the select statement. This
    produces no error, but no results either. The sql being run is
    select id from table where somename in
    ('something','something else')
    I don't think that is the query being run. Before passing the
    string, "something','something else", to the query Coldfusion will
    automatically escape the single-quotes on either side of the comma.
    That is the default behaviour. The resulting query is
    select id from table where somename in
    ('something'',''something else')
    To avoid these complications, use the function
    PreserveSingleQuotes(). Thus,
    <cfset sql_var = "'something','something else'">
    <cfquery name="test" datasource="db">
    select id from table where somename in
    (#preservesinglequotes(sql_var)#)
    </cfquery>

  • Changing Text property of TextObject at runtime has unexpected results

    I'm using the version of Crystal Reports that ships with VS 2008.
    At runtime, I'm replacing the text of a TextObject with new text. This works fine when the TextObject contains only literal information, but when the TextObject contains a formula field it does not work as expected.
    If I have the following in the designer:
    Text1 with text of "Number: {@FormulaX}"
    And in the runtime code (in the InitReport method):
    Text1.Text = "N.: {@FormulaX}"
    The observed output is: N.: {@ForumlaX}
    Instead of the expected output of: N.: 5
    I even tried the following in the runtime code:
    string foo = Text1.Text;
    Text1.Text = foo;
    And it produced similar results.
    Any ideas on what's going on, or how to get the results I'm expecting?

    The Text property doesn't interpret the formula syntax. You'll need to use a RAS TextObject to accomplish this.
    Note: This inproc RAS code will only work with Crystal Reports XI R2 SP2 and Crystal Reports 2008.
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.ReportAppServer.ClientDoc;
    using CrystalDecisions.ReportAppServer.DataDefModel;
    public partial class _Default : System.Web.UI.Page
        protected ReportDocument boReportDocument;
        protected void Page_Load(object sender, EventArgs e)
            if (!this.IsPostBack)
                ConfigureCrystalReports();
            CrystalReportViewer1.ReportSource = Session["Report"];
        protected void ConfigureCrystalReports()
            ISCDReportClientDocument boReportClientDocument;       
            CrystalDecisions.ReportAppServer.Controllers.ReportObjectController boReportObjectController;
            CrystalDecisions.ReportAppServer.ReportDefModel.TextObject boOldTextObject, boNewTextObject;
            CrystalDecisions.ReportAppServer.ReportDefModel.Paragraph boParagraph;
            CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphFieldElement boParagraphFieldElement;
            CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphTextElement boParagraphTextElement;
            boReportDocument = new ReportDocument();
            boReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
            boReportClientDocument = boReportDocument.ReportClientDocument;       
            boReportObjectController = boReportClientDocument.ReportDefController.ReportObjectController;
            // Get a handle on the ReportObjectController so we can manipulate the TextObject       
            foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject boReportObject in boReportObjectController.GetAllReportObjects())
                if (boReportObject.Kind == CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindText)
                    boOldTextObject = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)boReportObject;
                    boNewTextObject = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)boOldTextObject.Clone(true);
                    // Clear out all paragraphs from the current text object
                    boNewTextObject.Paragraphs.RemoveAll();
                    // Create a new Paragraph to add to our TextObject
                    boParagraph = new CrystalDecisions.ReportAppServer.ReportDefModel.Paragraph();
                    // Create a new ParagraphTextElement to be added to our paragraph
                    boParagraphTextElement = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphTextElement();               
                    boParagraphTextElement.Text = "The value of my parameter is: ";
                    boParagraph.ParagraphElements.Add(boParagraphTextElement);               
                    // Create a new ParagraphFieldElement (our parameter field) to be added to our paragraph               
                    boParagraphFieldElement = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphFieldElement();
                    boParagraphFieldElement.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindField;
                    boParagraphFieldElement.DataSource = "{?Currency}";               
                    boParagraph.ParagraphElements.Add(boParagraphFieldElement);
                    boNewTextObject.Paragraphs.Add(boParagraph);
                    boReportObjectController.Modify(boOldTextObject, boNewTextObject);
                    break;
            Session.Add("Report", boReportDocument);

  • Unexpected results, when creating a pdf from Illustrator (cs3)

    A customer has supplied a 'print ready' pdf, created in Illustrator [cs3]. The file contains grey text [20% black], but when they have printed to pdf [using acrobat 8], the breakdown of the 'grey' changes in colour to a cmyk value [45,36,35,1) instead of 0,0,0,20 as originally created in Illustrator.
    I've replicated the customers error from scratch, and have found that, when you save [save-as] the file as a pdf [using acrobat 8 settings] and resulting pdf is correct = 20% black.
    These errors where generated using a pc platform. We also tried to reproduce the error on our Mac's, but the Mac system didn't generate any issues.
    Does anyone know why illustrator would produce [using the same native file] two different results when producing pdf's? We've check all colour management, etc. and still can't figure out why this is happening.

    I have heard of this issue, but trying to remember is an issue by itself. lol. Seams to me there is an option for true blacks 0,0,0,? and cmy blacks ?,?,?,0. I am almost positive there are a few threads on this forum about this.

  • Problem with sdo_relate returning unexpected results

    I am having a problem with an oracle spatial query not returning what I feel is an appropriate result.
    I have a bounding box that has 6 points from a table that should be inside it. There are several hundred points total in this table. I perform the following query and oracle returns only 4 points, well 5 but we will get to that later, within the area of the search.
    SQL> Select feature_id
    From city_points A
    where (MDSYS.SDO_RELATE(A.GEOM, mdsys.sdo_geometry(2003, 8307, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array(-101.8417,-52.8083,-23.8417,-52.8083,-23.8417,-13.8083,-101.8417,-13.8083,101.8417,-52.8083)), 'mask=ANYINTERACT querytype=join') = 'TRUE');
    I used a different application to perform the same type of query. The difference is that the application does the spatial query, not oracle. Further the application gets all of the points and performs this query on the client. What the application returns is correct both visually and spatially.
    Two of the points not returned in the oracle spatial query are 300km inside the bounding box. This far exceeds the .5 m tolerance used in our decimal degrees data set (SRID 8307).
    I have experienced this problem on 9.2.0.1. I then patched that instance to 9.2.0.7 and duplicated the problem. I then exported the data and imported into a 10g release 1 database and again duplicated the problem. I have tried to re-index the data to no avail.
    I have also tried different querytypes also yielding less than expected results.
    The data looks like this:
    243
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-58.45, -34.6, NULL),NULL, NULL)
    254
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-56.18333, -34.883334, NULL), NULL, NULL)
    377
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-70.666671, -33.449999, NULL), NULL, NULL)
    385
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-68.149999, -16.5, NULL), NULL, NULL)
    388
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-47.916667, -15.783333, NULL), NULL, NULL)
    427
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-57.640066, -25.270295, NULL), NULL, NULL)
    The number is the id field, the rest is the geometry.
    The oracle spatial query above only returns id #s 359, 377,243,254,427
    There are five returned records. The extra value is outside the bounding area. So it should not have been returned at all. It is all too strange.
    I have seen this with different geometry types (points lines and area) as well.
    If anyone has suggestions, I would appreciate your comments.
    Thanks,
    John

    John,,
    What you are seeing is the behavior you should expect in the geodetic space.
    When you have a very long line connecting from longitude -101 to -23, that line
    does not follow the same latitude value.
    Since these points are in southern hemisphere, the line connecting them
    will curve downward (this is the great circle line).
    If you really want a line connecting with constant latitude, you should
    use the MBR type for the window geometry which densifies the
    lines along constant latitude before passing it into relate.
    SDO_GEOMETRY(2003, 8307, NULL,
    sdo_elem_info_array(1,1003,3),
    sdo_ordinate_array(-101.8417,-52.8083, 23.8417,-13.8083))
    siva

  • VPD column-masking: unexpected results using masked column in WHERE?

    Hi everyone..
    We are considering implementing VPD column-masking (to hide sensitive columns from unauthorized users), but I am concerned that queries will return incorrect results if an unauthorized user submits a query using a masked column in a WHERE clause - particularly in a JOIN operation.
    Our initial experiment confirms my concern:
    - We have a VPD policy on TABLE_X.COLUMN_Y:
    DBMS_RLS.ADD_POLICY(
    object_schema => 'xxxx',
    object_name => 'TABLE_X',
    policy_name => 'policy_x',
    function_schema => 'xxxx',
    policy_function => 'function_x',
    sec_relevant_cols =>'COLUMN_Y',
    sec_relevant_cols_opt => dbms_rls.ALL_ROWS)
    - The VPD function determines whether the user is authorized (1=1) or not (1=0)
    - COLUMN_Y contains various values, including NULL
    - when an "authorized" user submits the query "SELECT COUNT(*) FROM TABLE_X WHERE COLUMN_Y IS NULL", COUNT=correct number of rows containing NULL
    - when an "unauthorized" user submits the same query, COUNT=the total number of rows in the table -- presumably because the WHERE clause was modified to WHERE NULL=NULL
    In my opinion, the unauthorized user's query should return an error, because any other result is either wrong (i.e. COUNT=all rows, or returns a null result set) or something the user is not permitted to know (i.e. COUNT=correct number of rows)
    Am I missing some feature/setting of VPD that could let me force an error? I hope there is something out there, since I don't see any discussion or warnings about this pitfall.
    We are currently using Oracle 10.2.0.4 but upgrading to 11.1 soon.
    Thanks!
    Betty
    p.s. I originally incorrectly posted this question on the Technologies / Security forum.

    Thanks - yes, we have a function that checks whether the user id is authorized or not.
    The column-masking works, that is, authorized users can see the data; unauthorized users cannot. The issue is what happens when unauthorized users use the masked column in a WHERE predicate.

  • Full outer join unexpected results

    Warning, long message - I've searched the forums and found nothing similar. I've cut out as much as possible. We have been given the following schema to work with:
    CREATE TABLE CALLS (
    TRUNKIN VARCHAR2 (10),
    TRUNKOUT VARCHAR2 (10),
    DURATION FLOAT)
    Here is some test data:
    insert into calls values(null, 'a', 3);
    insert into calls values(null, 'a', 2);
    insert into calls values('a', null, 1);
    insert into calls values(null, 'a', 0);
    insert into calls values(null, 'a', 0);
    insert into calls values(null, 'a', 7);
    insert into calls values(null, null, 0);
    This is horribly unnormalized, but basically this table represent phone calls. trunkin and trunkout represent the two ends, and duration is length of a call. While obviously every call has two ends, the nulls above represent ends we don't care about in this example.
    The goal is to end up with data that looks like this. In English, we want the in and out summary statistics for each trunk to be summarized into a single row. (Sorry, these are supposed to be columns, but they got wrapped, so I reposted them as rows):
    TRUNKIN a
    IN_CALLS_ATTEMPTED 1
    IN_CALLS_COMPLETED 1
    IN_AVERAGE_DURATION 1
    TRUNKOUT a
    OUT_CALLS_ATTEMPTED 5
    OUT_CALLS_COMPLETED 3
    OUT_AVERAGE_DURATION 4
    Indeed, with the data given above, these are the results returned with the query at the end of this message. However, when I changed the one non-null trunkin value to null, I got very strange results. First, I independently ran the two subqueries. The first of course returns no rows, the second returns 1 with the same out values above; this is exactly what I would expect. However, when I run the full query, I get **5** rows back, each with just the trunkout column set to "a" and **all** other columns set to null. This makes no sense to me. The 5 rows are obviously the 5 rows from the original data set where trunkout = "a", but I'm not full outer joining those; I'm full outer joining the result of the group by, which only has 1 row. But even given that I'm getting 5 rows back, shouldn't all five of those have the remaining out columns filled in with the values above?
    Here is the query:
    select
    from
    SELECT
    trunkin as trunk,
    COUNT(*) AS in_calls_attempted,
    SUM
    CASE
    WHEN duration > 0 THEN 1
    ELSE 0
    END
    ) AS in_calls_completed,
    SUM(duration)/
    SUM
    CASE
    WHEN duration > 0 THEN 1
    ELSE 0
    END
    ) AS in_average_duration
    FROM CALLS
    WHERE trunkin IS NOT NULL
    GROUP BY trunkin
    ) callsin
    full outer join
    SELECT
    trunkout as trunk,
    COUNT(*) AS out_calls_attempted,
    SUM
    CASE
    WHEN duration > 0 THEN 1
    ELSE 0
    END
    ) AS out_calls_completed,
    SUM(duration)/
    SUM
    CASE
    WHEN duration > 0 THEN 1
    ELSE 0
    END
    ) AS out_average_duration
    FROM CALLS
    WHERE trunkout IS NOT NULL
    GROUP BY trunkout
    ) callsout
    on callsin.trunk = callsout.trunk;

    I am not entirely sure why you are getting the results you are, but I strongly suspect that it is a result of outer joining on null columns. I would write the query as follows to avoid the outer join problem. The CASE statements in the outer query around the average duration calulations avoid the divide by zero error that would occur when some trunk has only in or out calls.
    SELECT trunk,SUM(in_calls_attempted) in_calls_attempted,
           SUM(in_calls_completed) in_calls_completed,
           CASE WHEN SUM(in_calls_completed) <> 0 THEN
                SUM(in_duration)/SUM(in_calls_completed)
                ELSE 0 END ave_in_duration,
           SUM(out_calls_attempted) out_calls_attempted,
           SUM(out_calls_completed) out_calls_completed,
           CASE WHEN SUM(out_calls_completed) <> 0 THEN
                SUM(out_duration)/SUM(out_calls_completed)
                ELSE 0 END ave_out_duration
    FROM (
       SELECT trunkin trunk,COUNT(*) in_calls_attempted,
              SUM(CASE WHEN duration > 0 THEN 1 ELSE 0 END) in_calls_completed,
              SUM(duration) in_duration,0 out_calls_attempted,
              0 out_calls_completed,0 out_duration
       FROM calls
       GROUP BY trunkin
       UNION ALL
       SELECT trunkout trunk,0 in_calls_attempted,0 in_calls_completed,
              0 in_duration,COUNT(*) out_calls_attempted,
              SUM(CASE WHEN duration > 0 THEN 1 ELSE 0 END) out_calls_completed,
              SUM(duration) out_duration
       FROM calls
       GROUP BY trunkout)
    GROUP BY trunkTTFN
    John

  • My first real analytic function... any unexpected results?

    Hello all. I have a table that contains transactions from bank accounts. The columns I am concerned with (I think) are the account number and the status date.
    The status date has the date that the transaction cleared through the bank. I would like a query that returns all rows for an account that have cleared since the last reconciliation of that account. (the reconciliation will occur monthly)
    This will produce some test data that replicates what we'll have in this table.
    DROP TABLE dave_test;
    DROP TABLE dave_test succeeded.
    CREATE TABLE dave_test AS
    SELECT level id, ROUND(TO_NUMBER(level), -1) account, TO_DATE('2007-08-01','YYYY-MM-DD') test_date
    FROM DUAL
    CONNECT BY LEVEL < 20 UNION ALL
    SELECT 21, 10, TO_DATE('2007-07-01','YYYY-MM-DD') FROM DUAL UNION ALL
    SELECT 22, 10, TO_DATE('2007-06-01','YYYY-MM-DD') FROM DUAL UNION ALL
    SELECT 23, 0, TO_DATE('2007-09-01', 'YYYY-MM-DD') FROM DUAL;
    CREATE TABLE succeeded.
    SELECT * FROM dave_test ORDER BY id;
    ID ACCOUNT TEST_DATE
    1 0 01-AUG-07
    2 0 01-AUG-07
    3 0 01-AUG-07
    4 0 01-AUG-07
    5 10 01-AUG-07
    6 10 01-AUG-07
    7 10 01-AUG-07
    8 10 01-AUG-07
    9 10 01-AUG-07
    10 10 01-AUG-07
    11 10 01-AUG-07
    12 10 01-AUG-07
    13 10 01-AUG-07
    14 10 01-AUG-07
    15 20 01-AUG-07
    16 20 01-AUG-07
    17 20 01-AUG-07
    18 20 01-AUG-07
    19 20 01-AUG-07
    21 10 01-JUL-07
    22 10 01-JUN-07
    23 0 01-SEP-07
    22 rows selected
    I have developed a query that returns accurate results for my test data. My request is this:
    Will you look over this query and see if there is a better way of doing things? This is my first real attempt with an analytic function, so I would appreciate some input on anything that looks like it could be improved. Also, perhaps some test cases that might produce results I haven't thought of.
    Thank you for your time.
    SELECT
      id
      ,account
      ,test_date
      ,max(date_sort)
    FROM
      SELECT
        id            id
        ,account      account
        ,test_date    test_date
        ,CASE DENSE_RANK() OVER(PARTITION BY account ORDER BY TRUNC(test_date, 'DD') DESC)
          WHEN 1 THEN TO_DATE('1', 'J')
          WHEN 2 THEN test_date
          ELSE NULL
        END           date_sort
       FROM
        dave_test
    WHERE
      account = &account_number
    HAVING
      test_date > MAX(date_sort)
    GROUP BY
      id
      ,account
      ,test_date
    ORDER BY
      idRun with 0 as account number:
    ID                     ACCOUNT                TEST_DATE                 MAX(DATE_SORT)           
    23                     0                      01-SEP-07                 01-JAN-13                
    1 rows selectedRun with 10 as account number
    ID                     ACCOUNT                TEST_DATE                 MAX(DATE_SORT)           
    5                      10                     01-AUG-07                 01-JAN-13                
    6                      10                     01-AUG-07                 01-JAN-13                
    7                      10                     01-AUG-07                 01-JAN-13                
    8                      10                     01-AUG-07                 01-JAN-13                
    9                      10                     01-AUG-07                 01-JAN-13                
    10                     10                     01-AUG-07                 01-JAN-13                
    11                     10                     01-AUG-07                 01-JAN-13                
    12                     10                     01-AUG-07                 01-JAN-13                
    13                     10                     01-AUG-07                 01-JAN-13                
    14                     10                     01-AUG-07                 01-JAN-13                
    10 rows selectedRun with 20 as account_number
    ID                     ACCOUNT                TEST_DATE                 MAX(DATE_SORT)           
    15                     20                     01-AUG-07                 01-JAN-13                
    16                     20                     01-AUG-07                 01-JAN-13                
    17                     20                     01-AUG-07                 01-JAN-13                
    18                     20                     01-AUG-07                 01-JAN-13                
    19                     20                     01-AUG-07                 01-JAN-13                
    5 rows selectedLet me know if I need to clarify anything.

    Sorry, Volder, for being unclear.
    Here is the table the query is based on.
    desc bank_account_transactions
    Name                           Null     Type         
    ID                             NOT NULL NUMBER(28)   
    BKA_ID                         NOT NULL NUMBER(28)   
    BKATC_ID                       NOT NULL NUMBER(28)   
    ST_TABLE_SHORT_NAME                     VARCHAR2(10) 
    KEY_VALUE                               NUMBER(28)   
    EDF_ID                                  NUMBER(28)   
    GLFS_ID                        NOT NULL NUMBER(28)   
    GLTT_ID                                 NUMBER(28)   
    AMOUNT                         NOT NULL NUMBER(11,2) 
    PAYMENT_NUMBER                          NUMBER(9)    
    BANK_SERIAL_NUMBER                      NUMBER(15)   
    PAYEE_NAME                              VARCHAR2(60) 
    STATUS                         NOT NULL VARCHAR2(1)  
    STATUS_DATE                             DATE         
    EFFECTIVE_DATE                 NOT NULL DATE         
    POSITIVE_PAY_DATE                       DATE         
    DATA_SOURCE                    NOT NULL VARCHAR2(1)  
    REPORTED_TO_ACCOUNT_OWNER      NOT NULL VARCHAR2(1)  
    PAYEE_BANK_ACCOUNT_NUMBER               NUMBER(30)   
    PAYEE_BANK_ABA_NUMBER                   NUMBER(9)    
    DESCRIPTION                             VARCHAR2(4000)
    DATE_CREATED                   NOT NULL DATE         
    CREATED_BY                     NOT NULL VARCHAR2(30) 
    DATE_MODIFIED                           DATE         
    MODIFIED_BY                             VARCHAR2(30) 
    25 rows selectedThe bka_id is the account number, status is 'C' for cleared checks and the status_date is the date the check cleared.
    When I reconcile, I set the status to 'C' and set the status_date to SYSDATE. So the "last reconciliation date" is stored in status_date.
    Like so
    ID    Account_No  status_date   
    1     10          05-04-07
    2     10          05-04-07
    3     10          05-04-07
    4     20          05-04-07
    5     20          05-04-07
    6     10          06-03-07
    7     10          06-03-07
    8     20          06-03-07
    9     10          07-05-07
    10    10          07-05-07In this example, account 10 was reconciled on May 5, June 3, and July 5. So the previous reconciliation date would be 06-03-07, and my report would return the transactions from 07-05-07.
    For account 20, it was reconciled on May 5 and June 3. The previous reconciliation date would be 05-04-07, and the transactions from 06-03-07 would be reported.
    Does this help?
    I appreciate your time.

  • Calling PL/SQL Procedure In Another Schema Gives Unexpected Result

    I have a SQL Script that does this:
    conn pnr/<password for user pnr>;
    set serveroutput on;
    exec vms.disable_all_fk_constraints;
    SELECT owner, constraint_name, status FROM user_constraints WHERE constraint_type = 'R';
    and the disable_all_fk_constraints procedure that is owned by user 'vms' is defined as:
    create or replace
    procedure disable_all_fk_constraints is
    v_sql   VARCHAR2(4000);
    begin
    dbms_output.put_line('Disabling all referential integrity constraints.');
    for rec in (SELECT table_name, constraint_name FROM user_constraints WHERE constraint_type='R') loop
    dbms_output.put_line('Disabling constraint ' || rec.constraint_name || ' from ' || rec.table_name || '.');
    v_sql := 'ALTER TABLE ' || rec.table_name || ' DISABLE CONSTRAINT ' || rec.constraint_name;
    execute immediate(v_sql);
    end loop;
    end;
    When I run the SQL script, the call to vms.disable_all_fk_constraints disables the FK constrains in the 'vms' schema, whereas I wanted it to disable the FK constraints in the 'pnr' schema (the invoker of the procedure). I know that I could make this work by copying the disable_all_fk_constraints procedure to the 'pnr' schema and calling it as "+exec disable_all_fk_constraints;+" from within the SQL script but I want to avoid having to duplicate the PL/SQL procedure in each schema that uses it.
    What can I do?
    Thank you

    You have two issues to solve.
    First you need to write a packaged procedure that works with INVOKER rights. The default is DEFINER rights.
    The difference is excatly what you need. Usually the package has the rights from the schema where it is defined (=Definer rights). In your case schema VMS. Whereas you need the privileges from the user that calls the package (PNR).
    => Check out the documentation for INVOKER rights
    The second problem is that the view "user_constraints" will not give the results you expect when called from inside a procedure in another schema. An alternative could be to use the view DBA_CONSTRAINTS with a filter on the owner (where owner = 'PNR'). Not sure if there are other working possibilities. Well you could create a list of constraint names that you want to disable, instead of creating the list dynamically.
    And you could have another potential disaster creeping up upon you. If you run this thing, then at this moment you don't have any referential integrity anymore. You can't be sure that you can create the FKs again after this action. This is EXTREMLY DANGEROUS. I would never ever do this in any kind of production or test database. I would be very careful when I do it on a development database.

Maybe you are looking for