Best way to compare column values of 2 different records

Hi,
In my PL/SQL cursor, I want to store the column values of the first record and compare it with the column values of the next record to compare if they have duplicate column values. Should I store the results of the first record with an array and the second item using the cursor? Can you provide me the best practices? Thanks.
DECLARE
CURSOR cs IS
SELECT
A,
B
FROM TABLE;
BEGIN
for rec in cs
loop
-- this is where I would like to store the column values of the first record and
-- then compare it with the column values of the 2nd record.
end loop;
END;

The best practice I can recommend would be to not use PL/SQL at all. Cursor FOR LOOPs are one of the slowest forms of processing.
You should investigate analytical functions such as LAG and LEAD at http://tahiti.oracle.com
It is always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Best way to extract XML value wiith an xpath

    Hello,
    I wonder what is the best way to extract text value from XmlType with an xpath.
    I need to insert a row inside a table where the row's data come from xpath extractions of an XmlType. I do a lot of (approximative 20) :
    EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elem1').
    EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elemI').
    EXTRACTVALUE(var.myxmltype , '/an/xpath/to/extract/elem20').
    inside the insert statement
    Is this way is the best or is there a more optimal way ?
    For example extracting the node '/an/xpath/to/extract/' and sarting from this node extracting "elem1", ... , "elemI", "elemN" children.
    Thanks for your help,
    Regards,
    Nicolas

    Hi Nicolas,
    The answer depends on your actual storage method (binary, OR, CLOB?), and db version.
    You can try XMLTable, it might be better in this case :
    SELECT x.elem1, x.elem2, ... , x.elem20
    FROM your_table t
       , XMLTable(
          '/an/xpath/to/extract'
          passing t.myxmltype
          columns elem1  varchar2(30) path 'elem1'
                , elem2  varchar2(30) path 'elem2'
                , elem20 varchar2(30) path 'elem20'
         ) x
    ;

  • Best way to compare data of 2 tables present on 2 different servers

    Hi,
    We are doing data migration and I wil like to compare data between 2 tables which are present on 2 different server. I know to find the difference i can go for minus or full outer join and by creating the database link.
    But my problem is the volume of the data. The tables under consideration has approximately 40-60 columns and number of rows in each tables are around 60-70 million. Also both the tables are on 2 diffferent servers.
    I would like to know
    1] What will be the best way to compare the data and print the difference from performance perepective? I know that if I am going for DB links then its will definitely impact the performance as the tables are across 2 different servers.
    2] Is it advisable to go for using SQL - PL/SQL for this kind of senario or dump the data in flat files and use C or C++ code to find the difference.
    Regards,
    Amol

    Check this at asktom.oracle.com. Search for "Marco Stefanetti" and follow the few posts between Marco and Tom. As far as your tables being on separate servers, you could consider dumping the data to file and using external table or using CTAS ( create table as select ) to get both tables locally.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2151582681236

  • Best way to get the values of local variables

    What is currently the best way to get the values of local variables. I know it is not currently possible to set watchpoints on local variables, but what are the best workarounds?

    You have to use StackFrame methods, eg, visibleVariables and getValues. To get a StackFrame for a thread, that thread has to be suspended, eg, by a BreakpointEvent.

  • Best way to change TreeMap value?

    Hello,
    I am wondering what is the best way to change a value in a TreeMap? I have retrieved a value by .get on the key i.e.
    String aString = (TreeMap) aTreeMap.get(aKey);but would now like to change aString and ?.put? it back into the map?
    How would I do this?
    Thank you,
    Poot.

    but would now like to change aString and ?.put? it
    back into the map?Do I just have to keep a note on the (key,value) - especially key - change the value and then .put(key,value) back in? Though I'll need to remove the initial pairing if I do this since TreeMap won't allow duplicate keys!
    There must be an easier way as this.
    Thank you for your reply,
    Regards,
    Poot.

  • Better approach for checking column values between two different rows

    My requirement is to find best Approach to find difference between column values of two different rows.Below I've mentioned two different
    approaches I'm thinking of,but I'd like to know is there any other better approach.
    version details
    SQL> SELECT *
      2  FROM V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionTable creation script
    CREATE TABLE R_DUMMY
       (CA_ID VARCHAR2(16) NOT NULL ENABLE,
         CA_VER_NUM NUMBER(4,2) NOT NULL ENABLE,
         BRWR_SHORT_NAME VARCHAR2(25 CHAR),
         sic_code     number,
         FAC_ID VARCHAR2(10) NOT NULL ENABLE
    / insert script
    insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
    values ('CA2001/11/0002', 2.00, 'Nandu',1234, 'FA000008');
    insert into r_dummy (CA_ID, CA_VER_NUM, BRWR_SHORT_NAME, sic_code, FAC_ID)
    values ('CA2001/11/0002', 3.00, 'SHIJU',456, 'FA000008');Desired O/P :
    ca_id               fac_id          column_name          previous name          after_modification
    CA2001/11/0002          FA000008     BRWR_SHORT_NAME          Nandu               SHIJU
    CA2001/11/0002          FA000008     sic_code          1234               456My approach
    select      ca_id,fac_id,column_name,
         decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
         decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
    from
         select
                   case
                        when ld_brwr != lg_brwr then
                        'BRWR_SHORT_NAME'
                        when ld_brwr != lg_brwr then
                        'sic_code'
                   end
              ) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
         from     (
              select ca_id,fac_id,lag_brwr,ld_brwr,ld_sic,lag_sic
              from
                        Select      lead(brwr_short_name,1) over(partition by ca_id,fac_id) ld_brwr,
                             lag(brwr_short_name,1) over(partition by ca_id,fac_id) lg_brwr,
                             lead(sic_code,1) over(partition by ca_id,fac_id) ld_sic,
                             lag(sic_code,1) over(partition by ca_id,fac_id) lg_sic,
                             ca_id,fac_id
                        from r_dummy
              where (ld_brwr != lg_brwr or ld_sic != lg_sic)
    )2nd Approach :
    =============
    select      ca_id,fac_id,column_name,
         decode(column_name,'BRWR_SHORT_NAME',lg_brwr,lg_sic) previous_name ,
         decode(column_name,'BRWR_SHORT_NAME',ld_brwr,ld_sic) after_modification
    from
         select
                   case
                        when ld_brwr != lg_brwr then
                        'BRWR_SHORT_NAME'
                        when ld_brwr != lg_brwr then
                        'sic_code'
                   end
              ) column_name,ca_id,fac_id,lg_brwr,ld_brwr,ld_sic,lg_sic
         from     (
              select ca_id,fac_id,brwr_short_name,sic_code
              from
                        Select      ca_id,fac_id,brwr_short_name lg_brwr,sic_code lg_sic
                        from     r_dummy
                        where     ca_ver_num = '2.00'
                   )o,(
                        Select      ca_id,fac_id,brwr_short_name ld_brwr,sic_code ld_sic
                        from     r_dummy
                        where     ca_ver_num = '3.00'
                              )n
              where      0.ca_id = n.ca_id
                   and 0.fac_id = n.fac_id
                   and (ld_brwr != lg_brwr or ld_sic != lg_sic)
    )Hi Experts,
         I've provided sample data where I'm checking for just two columns viz brwr_short_name ,sic_code,but in real time
    I've to check for 8 more columns so please suggest me with a better approach.
    I appreciate your precious suggestions.

    Hi,
    Thanks for posting the CREATE TABLE and INSERT statements; that really helps!
    Here's one wa. Like your 2nd approach, this uses a self-join:
    WITH     got_r_num     AS
         SELECT  ca_id
         ,     ROW_NUMBER () OVER ( PARTITION BY  ca_id
                                   ,                    fac_id
                             ORDER BY        ca_ver_num
                                 )    AS r_num
         ,     brwr_short_name
         ,     TO_CHAR (sic_code)     AS sic_code
         ,     fac_id
    --     ,     ...     -- Other columns (using TO_CHAR if needed)
         FROM     r_dummy
    ,     unpivoted_data     AS
         SELECT     *
         FROM     got_r_num
         UNPIVOT     INCLUDE NULLS
              (    txt
              FOR  column_name IN ( brwr_short_name          AS 'BRWR_SHORT_NAME'
                            , sic_code               AS 'SIC_CODE'
    --                        , ...     -- Other columns
    SELECT       p.ca_id
    ,       p.fac_id
    ,       p.column_name
    ,       p.txt          AS previous_name
    ,       a.txt          AS after_modification
    FROM       unpivoted_data   p
    JOIN       unpivoted_data   a  ON  p.ca_id     = a.ca_id
                           AND p.fac_id     = a.fac_id
                         AND p.column_name     = a.column_name
                         AND p.r_num      = a.r_num - 1
                         AND p.txt || 'X' != a.txt || 'X'
    ORDER BY  a.r_num
    ;To include other columns, add them in the 2 places where I put the comment "Other columns".
    Ca_ver_num can have any values, not just 2.00 and 3.00.
    This will show cases where a value in one of the columns changed to NULL, or where NULL changed to a value.
    There ought to be a way to do this without a separate sub-query like got_r_num. According to the SQL Language manual, you can put expressions in the UPIVOT ... IN list, but when I tried
    ...     UNPIVOT     INCLUDE NULLS
              (    txt
              FOR  column_name IN ( brwr_short_name          AS 'BRWR_SHORT_NAME'
                                 , TO_CHAR (sic_code)     AS 'SIC_CODE'
              )I got the error "ORA_00917: missing comma" right after TO_CHAR. Perhaps someone else can show how to eliminate one of the sub-queries.

  • Best way to select distinct values based on another column?

    I have a table with three columns: id (NUMBER), data_dt (DATE), and data_value (NUMBER).
    There is a primary key on id and data_dt.
    I want to select the record with the latest data_dt for each unique id.
    What is the best way to do this?
    I have three different methods, but there may be something I am missing.
    First:
    SELECT *
    FROM
      SELECT id, data_dt, data_value,
             FIRST_VALUE(data_dt)
             OVER (PARTITION BY id ORDER BY data_dt DESC) AS last_data_dt
      FROM the_table
    WHERE data_dt = last_data_dt;(I use ORDER BY...DESC instead of just ORDER BY so I don't need the ROWS BETWEEN clause)
    Second:
    SELECT t1.*
    FROM the_table t1
    JOIN
      SELECT id, MAX(data_dt) AS last_data_dt
      FROM the_table
      GROUP BY id
    ) t2 ON (t2.id = t1.id AND t2.data_dt = t1.data_dt);Third:
    SELECT t1.*
    FROM the_table t1
    WHERE t1.data_dt =
      SELECT MAX(t2.data_dt)
      FROM the_table t2
      WHERE t2.id = t1.id
    );-- Don

    Hi,
    There are more possible scenario's, for example:
    select t1.*
    from   the_table t1
    where not exists ( select null
                       from   the_table t2
                       and    t2.data_dt > t1.data_dt
    What is the best way to do this?Only you can tell:
    Test all scenario's, check the execution plans, set timing on and pick the best/fastest one ;-)
    If it's not clear, please post the execution plans here.

  • What is the best way to implement default values stored in a DB table?

    [JHeadstart 10.1.3 build 78]
    [JDeveloper 10.1.3 SU4]
    We are struggling on how to best implement default values that are stored in a DB table. What we have is a database table with (CODE_TYPE, TABLE_NAME, COLUMN_NAME, DEFAULT_VALUE) as columns. This way the application administrator can administer default values himself/herself. Now we need to find the best way to set these table supplied default values in new rows. Globally we are aware of two ways:
    - override create() method on VO
    - probably create a View Object on top of the database table with default values (we are capable of transposing the table and return exactly one row with a column for each default value) and use JHeadstarts item property 'Default Value'.
    We prefer the latter, since this is more declarative, however we struggle with the EL expression needed to indicate the default value.
    If we have a VO named "DefaultValues" with a SELECT on a view on top of our database table (transposed) returning exactly one row, let us say:
    SELECT orglanguage, orgtype, orgstatus [...]
    FROM v_default_values
    --> returning exactly one row
    and we want an EL expression on an item that needs the value from orglanguage. What will the EL expression be? Something like:
    #{data.DefaultValuesPageDef.currentrow.orglanguage.inputValue}? We tried several things but they do not work. A static default value works, but every EL expression so far does not. We know that using "data" can be dangerous, but thought JHeadstart takes care of preparing the other Page Definitions, so it might be possible when you use JHeadstart.
    Or is overriding the create() method the preferred way? Or do we have to look at a Managed Bean for our default values that we refer to from EL (let us say MyAppDefaultValuesBean) and in that case: how do you associate a Managed Bean with a VO?
    Any help would be appreciated. Apart from these default values, things are going rather well in this first J2EE/JHS project for us!
    Toine

    Steven,
    Thanks for the reply. Unfortunately whatever we try, we cannot get it to work. We started looking at the second option (since we do need default values also in table lay-out new rows). We created a DefaultValues ViewObject, added it to the Application Module, added an EL expressiona to the Default Display Value property (replacing your ending ")" with a "}" offcourse ;-)), ran the JAG so that a page definition was generated for DefaultValues and we managed to get it prepared when loading for example the Organisation's jspx page. However no default value appears in a new row (not in Form, not in Table layout).
    I then created a quick application on top of the HR schema, added a DefaultValues ViewObject using one calculated attribute (set Salary fixed to 1000), added the EL expression to the Salary Default Display Value property in the Employees Group, made sure the DefaultValuesPageDef is prepared by adding it to the parameter section and I see it getting prepared. I also see a managed Bean is created in the Employees-bean.xml.
    In the Embedded OC4J log we see:
    16:01:01 DEBUG (JhsPageLifecycle) -executing onCreate
    16:01:01 DEBUG (JhsPageLifecycle) -CreateEmployeesDefaultValues bean found, applying default values to new row
    2006-08-02 16:01:01.825 WARNING [ADFc] Warning: No Method onCreateEmployees and no actionBinding CreateEmployees found.
    Is it this warning we should be worried about? Since no default value is created.
    The managed bean (Employees-beans.xml) looks like:
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
    <managed-bean>
    <managed-bean-name>CreateEmployeesDefaultValues</managed-bean-name>
    <managed-bean-class>oracle.jheadstart.controller.jsf.bean.DefaultValuesBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>iteratorBinding</property-name>
    <value>#{bindings.EmployeesIterator}</value>
    </managed-property>
    <managed-property>
    <property-name>defaultValues</property-name>
    <map-entries>
    <map-entry>
    <key>Salary</key>
    <value>#{data.DefaultValuesPageDef.DefaultValuesIterator.currentRow.Salary}</value>
    </map-entry>
    </map-entries>
    </managed-property>
    <managed-property>
    <property-name>actionResult</property-name>
    <value>CreateEmployees</value>
    </managed-property>
    </managed-bean>
    <managed-bean>
    <managed-bean-name>searchEmployees</managed-bean-name>
    <managed-bean-class>oracle.jheadstart.controller.jsf.bean.JhsSearchBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{data.EmployeesPageDef}</value>
    </managed-property>
    <managed-property>
    <property-name>searchBinding</property-name>
    <value>#{data.EmployeesPageDef.advancedSearchEmployees}</value>
    </managed-property>
    <managed-property>
    <property-name>searchAttribute</property-name>
    <value>EmployeeId</value>
    </managed-property>
    <managed-property>
    <property-name>dataCollection</property-name>
    <value>EmployeesView1</value>
    </managed-property>
    <managed-property>
    <property-name>autoquery</property-name>
    <value>true</value>
    </managed-property>
    </managed-bean>
    <managed-bean>
    <managed-bean-name>EmployeesCollectionModel</managed-bean-name>
    <managed-bean-class>oracle.jheadstart.controller.jsf.bean.JhsCollectionModel</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>jhsPageLifecycle</property-name>
    <value>#{jhsPageLifecycle}</value>
    </managed-property>
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{bindings}</value>
    </managed-property>
    <managed-property>
    <property-name>rangeBinding</property-name>
    <value>#{bindings.EmployeesTable}</value>
    </managed-property>
    <managed-property>
    <property-name>defaultValues</property-name>
    <value>#{CreateEmployeesDefaultValues.defaultValues}</value>
    </managed-property>
    </managed-bean>
    </faces-config>
    This is the DefaultValues.xml:
    <?xml version='1.0' encoding='windows-1252' ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <ViewObject
    Name="DefaultValues"
    BindingStyle="OracleName"
    CustomQuery="true"
    ComponentClass="hr.model.DefaultValuesImpl"
    UseGlueCode="false" >
    <DesignTime>
    <Attr Name="_version" Value="10.1.3.36.73" />
    <Attr Name="_codeGenFlag2" Value="Access|Coll|VarAccess" />
    </DesignTime>
    <ViewAttribute
    Name="Salary"
    IsUpdateable="false"
    IsPersistent="false"
    Precision="255"
    Type="java.lang.String"
    ColumnType="VARCHAR2"
    AliasName="SALARY"
    Expression="1000"
    SQLType="VARCHAR" >
    </ViewAttribute>
    </ViewObject>
    The PageDef for Defaultvalues is like:
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
    version="10.1.3.36.73" id="DefaultValuesPageDef"
    Package="hr.view.pagedefs" EnableTokenValidation="false">
    <parameters/>
    <executables>
    <iterator id="DefaultValuesIterator"
    Binds="AppModuleDataControl.DefaultValues1"
    DataControl="AppModuleDataControl" RangeSize="10"/>
    </executables>
    <bindings>
    <attributeValues id="DefaultValuesSalary"
    IterBinding="DefaultValuesIterator">
    <AttrNames>
    <Item Value="Salary"/>
    </AttrNames>
    </attributeValues>
    <table id="DefaultValuesTable" IterBinding="DefaultValuesIterator">
    <AttrNames>
    <Item Value="Salary"/>
    </AttrNames>
    </table>
    <action id="FirstDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="true"
    Action="12"/>
    <action id="PreviousDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="true"
    Action="11"/>
    <action id="NextDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="true"
    Action="10"/>
    <action id="LastDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="true"
    Action="13"/>
    <methodAction RequiresUpdateModel="true" Action="999"
    id="advancedSearchDefaultValues"
    IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl"
    InstanceName="AppModuleDataControl.dataProvider"
    MethodName="advancedSearch"
    ReturnName="AppModuleDataControl.methodResults.AppModuleDataControl_dataProvider_advancedSearch_result"
    IsViewObjectMethod="false">
    <NamedData NDName="viewObjectUsage"
    NDValue="#{searchDefaultValues.dataCollection}"
    NDType="java.lang.String"/>
    <NamedData NDName="arguments" NDValue="#{searchDefaultValues.arguments}"
    NDType="java.util.ArrayList"/>
    <NamedData NDName="allConditionsMet"
    NDValue="#{searchDefaultValues.allConditionsMet}"
    NDType="java.lang.Boolean"/>
    </methodAction>
    <action id="setCurrentRowWithKeyDefaultValues"
    IterBinding="DefaultValuesIterator"
    InstanceName="AppModuleDataControl.DefaultValues1"
    DataControl="AppModuleDataControl" RequiresUpdateModel="false"
    Action="96">
    <NamedData NDName="rowKeyStr" NDValue="#{row.rowKeyStr}"
    NDType="java.lang.String"/>
    </action>
    <action id="CreateDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="true"
    Action="40"/>
    <action id="DeleteDefaultValues" IterBinding="DefaultValuesIterator"
    DataControl="AppModuleDataControl" RequiresUpdateModel="false"
    Action="30"/>
    <action id="Commit" RequiresUpdateModel="true" Action="100"
    DataControl="AppModuleDataControl"/>
    <action id="Rollback" RequiresUpdateModel="false" Action="101"
    DataControl="AppModuleDataControl"/>
    </bindings>
    </pageDefinition>
    We do not understand what is wrong and why the default values do not get created in the new rows (and it is taking us far too much time). Any chance the EL expression is still wrong? It is a shame that any syntax errors in EL expressions are not visible in some logfile. It looks like when EL expressions are wrong, they are ignored instead of raising an error...
    Toine

  • [8i] Best way to replace "similar" values with one value...?

    Below is some sample data:
    Sorry for the large set / complex set of sample data, but there should be no need to go through it in detail =).
    2 things to keep in mind:
    1) This is an 8i db
    2) I cannot create any new tables within this db, though I can create views
    CREATE TABLE     ord_master
    (     part_nbr          CHAR(25)
    ,     ord_nbr          CHAR(10)
    ,     sub_ord_nbr     CHAR(3)
    ,     ord_type          CHAR(2)
    ,     ord_stat          CHAR(2)
    ,     date_closed     DATE
    -- please note, though none of the columns in ord_master are explicitly defined as NOT NULL,
    -- none of them are NULL in the db, and given how things are input into the table, I don't
    -- even think it's possible
    -- a unique order is described by ord_nbr, sub_ord_nbr.  there should only be one record in
    -- this table for a given unique combination of those columns, though they are not the p.k.
    -- NOTE: dates default to 12/31/1900, so in the table above, if an order is still open (thus,
    -- not closed), it's date_closed will be 12/31/1900.  It will only change once the order closes.
    INSERT INTO     ord_master
    VALUES     ('ABC-123','1','1','AA','CL',TO_DATE('05/01/2009','mm/dd/yyyy'));
    INSERT INTO     ord_master
    VALUES     ('ABC-123','1','2','AA','CL',TO_DATE('9/14/2009','mm/dd/yyyy'));
    INSERT INTO     ord_master
    VALUES     ('ABC-123','2','1','AA','CL',TO_DATE('12/03/2009','mm/dd/yyyy'));
    INSERT INTO     ord_master
    VALUES     ('ABC-123','3','1','AA','OP',TO_DATE('12/31/1900','mm/dd/yyyy'));
    INSERT INTO     ord_master
    VALUES     ('ABC-123','4','1','AA','CL',TO_DATE('03/12/2004','mm/dd/yyyy'));
    INSERT INTO     ord_master
    VALUES     ('XYZ-123','5','1','AA','CL',TO_DATE('03/12/2004','mm/dd/yyyy'));
    CREATE TABLE     op_detail
    (     ord_nbr          CHAR(10)
    ,     sub_ord_nbr     CHAR(3)
    ,     major_seq_nbr     CHAR(4)
    ,     wctr_id          CHAR(5)
    ,     oper_stat          CHAR(2)
    ,     plan_su_rsrc     NUMBER(5,2)
    ,     plan_run_rsrc     NUMBER(11,8)
    ,     plan_subc_amt     NUMBER(15,5)
    ,     act_su_rsrc     NUMBER(5,2)
    ,     act_run_rsrc     NUMBER(7,2)
    ,     act_subc_amt     NUMBER(15,2)
    ,     act_start_dt     DATE
    ,     dt_completed     DATE
    ,     qty_planned     NUMBER(13,4)
    ,     qty_recvd          NUMBER(13,4)
    ,     qty_complete     NUMBER(13,4)
    ,     qty_scrap          NUMBER(13,4)
    ,     qty_on_hold     NUMBER(13,4)
    -- similar to ord_master, thought none of the columns are explicitly defined as NOT NULL,
    -- none of the records have NULL values for any of these columns, and I don't think it's
    -- really possible with the way the system is
    INSERT INTO     op_detail
    VALUES     ('1', '1', '0081', 'X516 ', 'CP', 0, 0, 0, 0, .2, 0, TO_DATE('02/03/2010', 'mm/dd/yyyy'), TO_DATE('02/03/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '1', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .87, 0, TO_DATE('04/06/2010', 'mm/dd/yyyy'), TO_DATE('04/06/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 159, TO_DATE('03/05/2010', 'mm/dd/yyyy'), TO_DATE('03/05/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '1', '0130', 'H211 ', 'CP', .5, .1, 0, .08, .63, 0, TO_DATE('02/10/2010', 'mm/dd/yyyy'), TO_DATE('02/10/2010', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '2', '0120', 'H214 ', 'CP', .3, .05, 0, 0, .68, 0, TO_DATE('05/22/2009', 'mm/dd/yyyy'), TO_DATE('05/22/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '2', '0122', 'T203 ', 'CP', 2.5, 1, 0, .67, .3, 0, TO_DATE('05/28/2009', 'mm/dd/yyyy'), TO_DATE('05/28/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '2', '0130', 'H211 ', 'CL', .5, .1, 0, .67, .3, 0, TO_DATE('05/28/2009', 'mm/dd/yyyy'), TO_DATE('05/28/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '2', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 153.12, TO_DATE('06/10/2009', 'mm/dd/yyyy'), TO_DATE('06/10/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('1', '2', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .08, 0, TO_DATE('06/17/2009', 'mm/dd/yyyy'), TO_DATE('06/17/2009', 'mm/dd/yyyy'), 3, 3, 3, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('2', '1', '0081', 'X516 ', 'CL', 0, 0, 0, 0, 0, 0, TO_DATE('07/20/2009', 'mm/dd/yyyy'), TO_DATE('07/20/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('2', '1', '0324', 'Y000 ', 'CL', .1, .2, 0, 0, 3.03, 0, TO_DATE('09/11/2009', 'mm/dd/yyyy'), TO_DATE('09/11/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('2', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 204.16, TO_DATE('08/11/2009', 'mm/dd/yyyy'), TO_DATE('08/11/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('2', '1', '0130', 'H211 ','CP', .5, .1, 0, 1.97, 2.67, 0, TO_DATE('07/28/2009', 'mm/dd/yyyy'), TO_DATE('07/29/2009', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('3', '1', '0170', 'X928 ', 'CP', 0, 0, 9.6, 0, 0, 255.2, TO_DATE('11/06/2009', 'mm/dd/yyyy'), TO_DATE('11/06/2009', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('3', '1', '0130', 'H212 ', 'CP', .5, .1, 0, .6, .03, 0, TO_DATE('10/21/2009', 'mm/dd/yyyy'), TO_DATE('10/21/2009', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('3', '1', '0550', 'R501 ', 'WK', 1, 16, 0, 2.2, 12.4, 0, TO_DATE('05/19/2010', 'mm/dd/yyyy'), TO_DATE('12/31/1900', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('3', '1', '0324', 'Y000 ', 'CL', .1, .2, 0, 0, .07, 0, TO_DATE('02/04/2010', 'mm/dd/yyyy'), TO_DATE('02/04/2010', 'mm/dd/yyyy'), 5, 5, 5, 0, 0);
    INSERT INTO     op_detail
    VALUES     ('4', '1', '0324', 'Y000 ', 'CP', .1, .2, 0, 0, .59, 0, TO_DATE('02/06/2004', 'mm/dd/yyyy'), TO_DATE('02/06/2004', 'mm/dd/yyyy'), 4, 4, 4, 0, 0);This is the query I'm working with right now:
    SELECT     o.part_nbr               
    ,          s.major_seq_nbr          AS op_nbr
    ,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                   WHEN     s.wctr_id     IN ('H211','H212')
                   THEN     'Z211'
                   ELSE     s.wctr_id
              END                         AS wctr
    ,          MIN(s.plan_su_rsrc)          AS min_plan_setup
    ,          AVG(s.plan_su_rsrc)          AS avg_plan_setup
    ,          MAX(s.plan_su_rsrc)          AS max_plan_setup
    ,          STDDEV(s.plan_su_rsrc)     AS sdev_plan_setup
    ,          MIN(s.plan_run_rsrc)     AS min_plan_run
    ,          AVG(s.plan_run_rsrc)     AS avg_plan_run
    ,          MAX(s.plan_run_rsrc)     AS max_plan_run
    ,          STDDEV(s.plan_run_rsrc)     AS sdev_plan_run
    ,          MIN(s.plan_subc_amt)     AS min_plan_subc
    ,          AVG(s.plan_subc_amt)     AS avg_plan_subc
    ,          MAX(s.plan_subc_amt)     AS max_plan_subc
    ,          STDDEV(s.plan_subc_amt)     AS sdev_plan_subc
    ,          MIN(s.act_su_rsrc)          AS min_act_setup
    ,          AVG(s.act_su_rsrc)          AS avg_act_setup
    ,          MAX(s.act_su_rsrc)          AS max_act_setup
    ,          STDDEV(s.act_su_rsrc)     AS sdev_act_setup
    ,          MIN(s.act_run_rsrc)          AS min_act_run
    ,          AVG(s.act_run_rsrc)          AS avg_act_run
    ,          MAX(s.act_run_rsrc)          AS max_act_run
    ,          STDDEV(s.act_run_rsrc)     AS sdev_act_run
    ,          MIN(s.act_subc_amt)          AS min_act_subc
    ,          AVG(s.act_subc_amt)          AS avg_act_subc
    ,          MAX(s.act_subc_amt)          AS max_act_subc
    ,          STDDEV(s.act_subc_amt)     AS sdev_act_subc     
    ,          MIN(s.act_start_dt)          AS min_start
    ,          MAX(s.act_start_dt)          AS max_start
    ,          MIN(s.dt_completed)          AS min_comp
    ,          MAX(s.dt_completed)          AS max_comp
    ,          MIN(s.qty_planned)          AS min_qty_plan
    ,          AVG(s.qty_planned)          AS avg_qty_plan
    ,          MAX(s.qty_planned)          AS max_qty_plan
    ,          STDDEV(s.qty_planned)     AS sdev_qty_plan
    ,          MIN(s.qty_recvd)          AS min_qty_recvd
    ,          AVG(s.qty_recvd)          AS avg_qty_recvd
    ,          MAX(s.qty_recvd)          AS max_qty_recvd
    ,          STDDEV(s.qty_recvd)          AS sdev_qty_recvd
    ,          MIN(s.qty_complete)          AS min_qty_comp
    ,          AVG(s.qty_complete)          AS avg_qty_comp
    ,          MAX(s.qty_complete)          AS max_qty_comp
    ,          STDDEV(s.qty_complete)     AS sdev_qty_comp
    ,          MIN(s.qty_scrap)          AS min_qty_scrap
    ,          AVG(s.qty_scrap)          AS avg_qty_scrap
    ,          MAX(s.qty_scrap)          AS max_qty_scrap
    ,          STDDEV(s.qty_scrap)          AS sdev_qty_scrap
    ,          MIN(s.qty_on_hold)          AS min_qty_hold
    ,          AVG(s.qty_on_hold)          AS avg_qty_hold
    ,          MAX(s.qty_on_hold)          AS max_qty_hold
    ,          STDDEV(s.qty_on_hold)     AS sdev_qty_hold
    ,          COUNT(*)                    AS rec_cnt
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END                         AS time_period
    FROM          ord_master o
    ,          op_detail     s
    ,          (     -- begin in-line view a, to get the min act_start_dt for each order
              SELECT     s1.ord_nbr
              ,          s1.sub_ord_nbr
              ,          MIN     (
                             CASE
                                  WHEN     s1.act_start_dt     > TO_DATE('01/01/2000','mm/dd/yyyy')
                                  THEN     s1.act_start_dt
                             END
                             )          AS ord_min_start
              FROM          op_detail s1
              GROUP BY     s1.ord_nbr
              ,          s1.sub_ord_nbr
              ) a     -- end in-line view a          
    WHERE     o.ord_nbr          = s.ord_nbr
    AND          o.sub_ord_nbr     = s.sub_ord_nbr
    AND          o.ord_nbr          = a.ord_nbr
    AND          o.sub_ord_nbr     = a.sub_ord_nbr
    AND          o.ord_type     = 'AA'
    AND          o.ord_stat     IN ('CL','OP')
    AND          s.oper_stat     IN ('CL','CP')
    GROUP BY     o.part_nbr
    ,          s.major_seq_nbr
    ,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                   WHEN     s.wctr_id     IN ('H211','H212')
                   THEN     'Z211'
                   ELSE     s.wctr_id
              END
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END
    ORDER BY     o.part_nbr
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END
    ,          s.major_seq_nbrThis gives me a bunch of descriptive statistics on some data stored in the database, broken into groups by the time period.
    I have 7 sets of possible values for the column wctr_id that are groups of similar/same work centers, and should be treated as the same, assuming the ord_nbr, sub_ord_nbr, and major_seq_nbr are the same. In my example case statement above, anytime I find 'H211' or 'H212', I am replacing it with 'Z211', which is my new, unique identifier for any wctr in the group ('H211', 'H212'). I have 7 of these sorts of groups that need to be replaced by a new, unique identifier. Is my CASE statement (noted above) the best way to do this, or is there a better way? These groups of similar-to wctr_id's are not listed in a table anywhere.

    Hi,
    As always, thanks for posting the CREATE TABLE and INSERT statements; that's very helpful, and leads to faster, better solutions.
    Another thing that is helpful, and promotes faster, better solutions, is to simplify your problem.
    For example, you have to compute a lot of aggregates, but it looks like you already know how to do that. This problem only involves the CASE expressions, and how they interact with the GROUP BY clause. So just cut out most of the aggregate functions.
    Also, it looks like the intricacies of in-line view a have nothing to do with your current problem. For purposes of posting this problem, pretend that a is a regular view, so it doesn't clutter up the main query.
    I think your problem could be restated like this:
    You already have a query like this:
    CREATE OR REPLACE VIEW a
    AS
              SELECT     s1.ord_nbr
              ,          s1.sub_ord_nbr
              ,          MIN     (
                             CASE
                                  WHEN     s1.act_start_dt     > TO_DATE('01/01/2000','mm/dd/yyyy')
                                  THEN     s1.act_start_dt
                             END
                             )          AS ord_min_start
              FROM          op_detail s1
              GROUP BY     s1.ord_nbr
              ,          s1.sub_ord_nbr
    SELECT     o.part_nbr               
    ,          s.major_seq_nbr          AS op_nbr
    ,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                   WHEN     s.wctr_id     IN ('H211','H212')
                   THEN     'Z211'
                   ELSE     s.wctr_id
              END                         AS wctr
    ,          MIN(s.plan_su_rsrc)          AS min_plan_setup
              -- lots of other agtgregates go here in real query
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END                         AS time_period
    FROM          ord_master o
    ,          op_detail     s
    ,          a          -- in real query, a is an in-line view
    WHERE     o.ord_nbr          = s.ord_nbr
    AND          o.sub_ord_nbr     = s.sub_ord_nbr
    AND          o.ord_nbr          = a.ord_nbr
    AND          o.sub_ord_nbr     = a.sub_ord_nbr
    AND          o.ord_type     = 'AA'
    AND          o.ord_stat     IN ('CL','OP')
    AND          s.oper_stat     IN ('CL','CP')
    GROUP BY     o.part_nbr
    ,          s.major_seq_nbr
    ,          CASE          -- CASE statement to replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                   WHEN     s.wctr_id     IN ('H211','H212')
                   THEN     'Z211'
                   ELSE     s.wctr_id
              END
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END
    ORDER BY     o.part_nbr
    ,          CASE
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                   THEN     '12 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                   THEN     '24 mos. back'
                   WHEN a.ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                   THEN     '36 mos. back'
                   ELSE '37 mos. back +'
              END
    ,          s.major_seq_nbr
    ;that produces this output:
    `                       MIN_
                           PLAN_
    PART_NBR   OP_N WCTR   SETUP TIME_PERIOD
    ABC-123    0081 X516      .0 12 mos. back
    ABC-123    0130 Z211      .5 12 mos. back
    ABC-123    0170 X928      .0 12 mos. back
    ABC-123    0324 Y000      .1 12 mos. back
    ABC-123    0120 H214      .3 24 mos. back
    ABC-123    0122 T203     2.5 24 mos. back
    ABC-123    0130 Z211      .5 24 mos. back
    ABC-123    0170 X928      .0 24 mos. back
    ABC-123    0324 Y000      .1 24 mos. back
    ABC-123    0324 Y000      .1 37 mos. back +The output is correct; the problem is, can we get the same results without 2 copies of the wctr CASE expression, and 3 copies of the time_period CASE expression?
    Is that a fair description of the problem?
    For starters, you can use column aliases in the ORDER BY clause. Unfortunately, that's the only place where you can use column aliases in the same query where they are defined . You can compute them in a sib-query, and then use them in super-queries.
    In other words, wouldn't it be nice if we had a table just like op_detail, but with an additional column called wctr? Make a view: either a regular view (especially if wctr, computed the same way, will be used in several different queries) or an in-line view, as shown below.
    Wouldn't it be great if there was a table that was just like a, except that it had time_period alreay computed? Make a view: either a regular view or an in-line view, as shown below.
    SELECT     o.part_nbr
    ,     s.major_seq_nbr          AS op_nbr
    ,     s.wctr
    ,     MIN(s.plan_su_rsrc)          AS min_plan_setup
         -- lots of other agtgregates go here in real query
    ,     a2.time_period
    FROM     ord_master      o
    ,     (          -- Begin in-line view s, with data from op_detail
                 SELECT  op_detail.*      -- or list all columns needed in main query
              ,     CASE          -- replace similar-to wctr_id's with a single new wctr_id, so we can treat them as the same
                       WHEN     wctr_id        IN ('H211','H212')
                       THEN     'Z211'
                       ELSE     wctr_id
                   END                    AS wctr
              FROM     op_detail
         ) s          -- End in-line view s, with data from op_detail
    ,     (           -- Begin in-line view a2, to compute time_period
              SELECT  a.*
              ,     CASE
                       WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-12)
                           THEN     '12 mos. back'
                           WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-24)
                           THEN     '24 mos. back'
                           WHEN ord_min_start     >     ADD_MONTHS(SYSDATE,-36)
                           THEN     '36 mos. back'
                           ELSE '37 mos. back +'
                   END                         AS time_period
              FROM     a          -- in real query, a is an in-line view
         ) a2          -- End in-line view a2, to compute time_period
    WHERE     o.ord_nbr     = s.ord_nbr
    AND     o.sub_ord_nbr     = s.sub_ord_nbr
    AND     o.ord_nbr     = a2.ord_nbr
    AND     o.sub_ord_nbr     = a2.sub_ord_nbr
    AND     o.ord_type     = 'AA'
    AND     o.ord_stat     IN ('CL','OP')
    AND     s.oper_stat     IN ('CL','CP')
    GROUP BY     o.part_nbr
    ,          s.major_seq_nbr
    ,          s.wctr
    ,          a2.time_period
    ORDER BY     o.part_nbr
    ,          a2.time_period
    ,          s.major_seq_nbr
    ;In your example, wctr is the same as wctr_id except for two values. If it was more complicated (e.g., if there were not just 2 values that need to be mapped to 'Z211', but also 3 values to were equivalent to 'Z987', and 1 that was to be treated like 'A012', and 5 that should appear as 'A666', and ...), then you could code all that in a humongeous CASE expression (a nested CASE expression, if it involves more that 128 branches), but it really belongs in a table, where you have the raw wctr_id (like 'H211') in one column, and its corresponding equivalent (such as 'Z211') in another. I know you said you can't create new tables; I'm just pointing this out so you can tell the people who won't let you create new tables that it's a bad idea, likely to cause errors and certain to waste time in the future.

  • Best way to use return values in a webservices

    Hi all,
    Scenario: We have three web services. What is the best way to do this acitivity or is it possible?
    webservice1
    webservice2
    webservice3
    Call invoke webservice1 & 2 (they need to their work do be done parallely and will return a value eg "string")and call webservices3 with input values as the returned value from webservice 1 & 2.
    Thanks,
    Shashi
    Edited by: Shashi_sr on Sep 17, 2010 1:46 PM

    Hi Shashi,
    The way to achieve your desired functionality is as follows:
    Create a flow activity, and within that flow activity, you will call web services (using an invoke activity) webservice1 and webservice2.
    After the flow activity, you will then use another invoke activity to call the 3rd webservice using the output given by the first 2 webservices.

  • Best way to distribute configuration values to subVIs

    I have a main VI with ~10 subVIs, all of which have a number of default constants embedded. I want to change my architecture so that all the constants are moved to a single ASCII text file which is not changed during program execution. I'm trying to decide the best way to do this:
    - Read the file every time a subvi is opened (this is frequent).
    - Use the "Read Key" function (this may be essentially the same).
    - Read the file once at the beginning of execution, and store the values in a cluster which is passed to each subVI.
    - Read the file once at the beginning of execution, and store the values in several clusters, passing only the needed values to a given subVI.
    - Read the file once at the beginning of execution, and store the values in a functional (LV2) global which is read by each subVI when it is called.
    I think all of these would work, but what would be the most efficient in terms of programming time, execution time, memory usage, and ease of future modification? I'm leaning toward the multiple clusters approach so that I'm not constantly reading a file each time a subVI opens.
    Thanks to all,
    James

    Consider using what I call a "manager" VI. Its purpose is to manage the file for you.
    You call it whever you want to know one of these parameters.
    It knows whether it's read the file yet or not. If not, it does so on first call.
    After that, it simply keeps all your values in its own memory (shift registers).
    When you call it, it simply gives you the value(s) out of its memory, either as a big cluster, or as separated values.
    That way, you only read the file once.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Best way to store 36 values

    Hello,
    I need to store 6 types of values with combination of 6X8 values totally 288 value .
    For Example
    1[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    2[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    3[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    4[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    5[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    6[{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6},{1,2,2,59,7,8,9,6}]
    How can i store these values in c# ?,which is the best way with respect to performance and security.
    And whether i can store these data's in separate class file and access at time of process which is a multi-threading process.
    If i asked any thing wrong sorry as i am new in these things.
    Thanks

    Try this
    List<List<List<int>>> input = new List<List<List<int>>>(){
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}},
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}},
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}},
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}},
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}},
    new List<List<int>>(){
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},
    new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6},new List<int>(){1,2,2,59,7,8,9,6}}
    jdweng

  • Best way to check boolean value

    Hi!
    I have a schema defining an XML element with a boolean attribute. The document related to this schema use true/false literal boolean values, eg:
    <myelement myattribute="false"/>....<myelement myattribute="true"/>
    The data is stored in binary xml storage.
    I query the db on the boolean attribute with an xpath condition like this:
    ..../myelement[@myattribute=false()]
    Querying the db with this method:
    SELECT XMLQuery('....' returning content) from dual
    all works as expected.
    Instead, using:
    SELECT XMLQuery('....' ' PASSING OBJECT_VALUE RETURNING CONTENT)
    FROM "myxmltable"
    WHERE XMLExists('....' PASSING OBJECT_VALUE);
    I get the error: ORA-31038: Invalid hexBinary value: "false"
    To get the second query method working, I have to change the xpath condition, forcing a string comparison:
    ..../myelement[string(@myattribute)="false"]
    Can someone explain me this behaviour? What is the best way to check a boolean value? I'd like to write the same xquery working in both methods!
    Thank you.
    Bye
    Mirko

    Hi Geoff
    here the schema:
    <xs:schema xmlns:tns="http://OracleTest" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" targetNamespace="http://OracleTest" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="MyComplexType">
    <xs:sequence>
    <xs:element minOccurs="0" name="FirstChild">
    <xs:complexType>
    <xs:attribute name="A" type="xs:string" />
    <xs:attribute name="B" type="xs:string" />
    </xs:complexType>
    </xs:element>
    <xs:element minOccurs="0" name="SecondChild">
    <xs:complexType>
    <xs:attribute name="S" type="xs:string" />
    <xs:attribute name="B" type="xs:boolean" />
    <xs:attribute name="I" type="xs:integer" />
    </xs:complexType>
    </xs:element>
    <xs:element minOccurs="0" name="ThirdChild">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" name="ThirdChildA">
    <xs:complexType>
    <xs:attribute name="A" type="xs:string" />
    <xs:attribute name="B" type="xs:string" />
    </xs:complexType>
    </xs:element>
    <xs:element minOccurs="0" name="ThirdChildB">
    <xs:complexType>
    <xs:attribute name="C" type="xs:string" />
    <xs:attribute name="D" type="xs:string" />
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="ID" type="xs:string" />
    </xs:complexType>
    <xs:element xdb:defaultTable="MyElement" name="MyElement" type="tns:MyComplexType" />
    </xs:schema>
    and here two sample XML documents:
    <tns:MyElement ID="ID1" xmlns:tns="http://OracleTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://OracleTest http://OracleTest.xsd">
    <tns:FirstChild A="a" B="b" />
    <tns:SecondChild S="s" B="true" I="1" />
    <tns:ThirdChild>
    <tns:ThirdChildA A="aa" B="bb" />
    <tns:ThirdChildB C="cc" D="dd" />
    </tns:ThirdChild>
    </tns:MyElement>
    <tns:MyElement ID="ID2" xmlns:tns="http://OracleTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://OracleTest http://OracleTest.xsd">
    <tns:FirstChild A="aa" B="bb" />
    <tns:SecondChild S="ss" B="false" I="2" />
    <tns:ThirdChild>
    <tns:ThirdChildA A="aaaa" B="bbbb" />
    <tns:ThirdChildB C="cccc" D="dddd" />
    </tns:ThirdChild>
    </tns:MyElement>
    I registered the schema using Enterprise Manager. The "Show SQL" function returned this script:
    BEGIN
    DBMS_XMLSCHEMA.REGISTERSCHEMA(
    schemaurl => 'http://OracleTest.xsd',
    schemadoc => sys.UriFactory.getUri('/Testing/test.xsd'),
    local => FALSE,
    gentypes => FALSE,
    genbean => FALSE,
    gentables => TRUE,
    force => FALSE,
    owner => 'EMILIAROMAGNABUY',
    OPTIONS => DBMS_XMLSCHEMA.REGISTER_BINARYXML);
    END;
    This is my test script:
    -- This works fine: returns only the requested row.
    SELECT XMLQuery('declare default element namespace "http://OracleTest"; collection("/Testing")/MyElement/SecondChild[@B=true()]' returning content) from dual;
    -- This raises the error = SQL Error: ORA-31038: Invalid hexBinary value: "true"
    select xmlquery('declare default element namespace "http://OracleTest"; /MyElement/SecondChild[@B=true()]' passing object_value returning content).getclobval() from "MyElement";
    -- This doesn't work correctly: returns the requested row and two empty rows ?!? I don't like this cast, anyway.
    select xmlquery('declare default element namespace "http://OracleTest"; /MyElement/SecondChild[string(@B)="true"]' passing object_value returning content).getclobval() from "MyElement";
    Thank you
    Mirko

  • CF9 - Best way to compare LDAP data in .ldf file against database?

    Hello, everyone.
    I am tasked with creating a script that will take LDAP information from a .ldf file and compare each entry to a database, adding names that meet certain criteria.
    What is the best way to do this? I've never worked with LDFs, before.
    Thank you,
    ^_^

    JDBC concerns connecting to the database. I have only worked on Oracle and I am not sure if this function is one of theirs or SQL standard. Basically it works like this:
    The following statement combines results with the MINUS operator, which returns only rows returned by the first query but not by the second:
    SELECT product_id FROM inventories
    MINUS
    SELECT product_id FROM order_items;
    taken from : http://www.cs.ncl.ac.uk/teaching/facilities/swdoc/oracle9i/server.920/a96540/queries5a.htm

  • What's the best way to compare projects?

    Is there a way of comparing two versions of a RH10 project and getting a list of any differences between them?
    I want to be able to provide our translator with an accurate list of what's changed in each new version of help.

    Hi there
    Since this is in house, there is one way you could set up that may help. It depends on how familiar you are with See Also Keywords and See Also Controls.
    What you could do is create a See Also Keyword. Perhaps name it "Attention". Then as you edit or add new content, you would assign the affected topic(s) to the keyword. Then you would have a topic that has a See Also Control that is linked to the keyword. In order to "see" what needs attention, whomever is working with the content would just open that topic and click the See Also Control. All the affected topics would then be listed. Essentially, you are just keeping track as you go along.
    Note that this isn't automated nor is it foolproof. It would require being diligent to assign topics to the keyword. But once everyone has become accustomed to it, it should be easier than running a comparison application and trawling through code.
    Cheers... Rick

Maybe you are looking for