return specific values of table

I have a set of code that returns an array of two values. The next step in my code is to choose only a single value based on a set of rules:

If the two objects are equal, or other return values.

If exactly one point is equal to 12, return the residual value (12 may be in first or second place)

Otherwise, always returns the highest value.

I can trace this in my head and it sounds simple enough, but when I try to turn it into code, it becomes more complicated.

I enclose my attempt. Am I overthinking this?

Thanks for any help.

First, use the table Max & Min to get the greatest value.  Coincidentally, if they are equal, the Max and Min will have the same value.  In order to find the Max will suffice for cases 1 and 3.  So, really, we just need to know if one of them is 12.  Compare table 12.  This will give you an array of Boolean.  Now use the Boolean chart number for a number and the number of wire to a structure of matter.  If the number is 1, then the first stood at 12 and you must return the second value.  If the number is 2, then the second stood at 12 and you must return the first value.  If the number is something else, return the table max.

Tags: NI Software

Similar Questions

  • How do you define a table of drop-down list to a specific value boxes?

    I have a table of drop-down list boxes that I want to put a specific value. When I say my program to put them to affect only the drop-down list box which just recently I changed and none of the others.

    I have attached a small vi presents the problem.

    Thank you

    -Ben

    It would be the value - property

  • Return multiple values from a table

    Hi there I'm working on a bit of sql that returns values when they exist in a table.
    The code I have returns the correct value when there is an entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it does display no line at all: (.)

    Can someone tell how to return multiple values?

                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    Thanks in advance!

    Ashleigh

    Try this:

    select modulename
    from tbl_modulefeedback
    where 1 <= (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 <= (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    

    When you ask questions, please enter CREATE TABLE and INSERT some commands to make it easier to help you.

  • Filter for a specific value object type

    I would like to know if the documents loaded on an object type can be interrogated for a specific value. For ex, I wanted to fetch all the records of the emp and load it into an object. I wanted to ask the object out of the loop to query for a specific deptno. I understand a query simpe SQL would be much faster in the scenario below, but the report itself used in our system uses several tables and some of them have millions of records from different sources as accounts suppliers, accounts receivable, accounting, etc. and they are treated differently for each source before that the result will be published the report. I took the table emp for example and wanted to know if the type of object can be queried for a specific column outside the loop.

    DECLARE

    CURSOR cur_emp IS SELECT * FROM EMP;

    TYPE emp_obj IS TABLE OF cur_emp % ROWTYPE INDEX BY PLS_INTEGER;

    l_emp_tab emp_obj;

    BEGIN

    OPEN cur_emp.

    LOOP

    Get the cur_emp COLLECT LOOSE l_emp_tab LIMIT 1000;

    EXIT WHEN l_emp_tab.count = 0;

    BECAUSE me IN 1.l_emp_tab.count

    Loop

    dbms_output.put_line (' Ename:' | l_emp_tab (i) .ename |', Deptno:' | .deptno l_emp_tab (i));

    END LOOP;

    END LOOP;

    -Can I ask specific employee to a deptno outside the loop FOR without using a temporary table

    -something like "SELECT * FROM TABLE (type_name) WHERE DEPTNO = x_Deptno.

    END;

    /

    In a collection of table selection is not effective, there are better ways to do it.

    Why not create a view?

    create view...

    Select * from source1 Union all the

    Select * from source2 Union all the

    Select * from source3

    -or-

    Using ref cursor return... clause, so you can make conditional cursors

    If somecondition then

    Open the NEWS for

    Select * source1;

    on the other

    Open the NEWS for

    Select * from source2.

    end if;

    -or-

    Dynamics based SQL ref cursor

    DECLARE

    TYPE EmpCurTyp IS REF CURSOR;

    v_emp_cursor EmpCurTyp;

    employees emp_record % ROWTYPE;

    v_stmt_str VARCHAR2 (200);

    v_e_job employees.job%TYPE;

    BEGIN

    -Dynamic SQL statement with placeholder:

    v_stmt_str: = ' SELECT * FROM employees WHERE job_id =: I;

    -Open the cursor & specify bind argument in the USING clause:

    V_emp_cursor OPEN FOR v_stmt_str with the HELP of 'MANAGER ';

    -Extraction of the lines of result set one at a time:

    LOOP

    SEEK v_emp_cursor INTO emp_record;

    EXIT WHEN v_emp_cursor % NOTFOUND;

    END LOOP;

    -Close the cursor:

    CLOSE V_emp_cursor;

    END;

    /

    -or-


    Load in an intermediate table (as a temporary table)

  • Returns the value of column line

    Greetings!  I currently have a request we will tell

    SELECT value, period FROM MAS_CFUS_KEYACM_CONTROLDATA ORDER BY cf_keyword_ID

    RESULTS

    Period value

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

    100.0002 1 JANUARY 14

    -35.68 1 DECEMBER 14

    -1943.67 NOVEMBER 1, 14

    678.0013 OCTOBER 1, 14

    This continues for about 15 results by cf_keyword_ID.

    I'm looking to return the VALUE first in a new column called PREV1, the second value of PREV2, third in PREV3 and so on.  The same goes for the dates.  And all this for only the first 10 values of each cf_keyword_ID.  Can anyone suggest the best way to achieve this?

    Thank you!!

    Hello

    This is called pivoting.  Because I don't have a copy of your table test, I'll use scott.emp to illustrate.

    This shows the first 3 employees for each job, in order by hiredate, along with their hiredates:

    WITH relevant_data AS

    (

    SELECT ename, job, hiredate

    row_number () taken OVER (PARTITION OF work

    ORDER BY hiredate

    ) AS r_num

    FROM scott.emp

    )

    SELECT *.

    OF relevant_data

    PIVOT (MIN (ename) AS ename

    MIN (hiredate) AS hiredate

    FOR r_num (1, 2, 3)

    )

    ORDER BY job

    ;

    Output:

    WORK 1_ENAME 1_HIREDATE 2_ENAME 2_HIREDATE 3_ENAME 3_HIREDATE

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

    ANALYST FORD 3 December 1981 SCOTT April 19, 1987

    The CLERK SMITH December 17, 1980, 3 December 1981 JAMES MILLER January 23, 1982

    MANAGER JONES 2 April 1981 BLAKE 1 May 1981 CLARK June 9, 1981

    PRESIDENT KING November 17, 1981

    SELLER ALLEN 20 February 1981 WARD 22 February 1981 TURNER 08-Sep-1981

    There are actually more than 3 SECRETARIES and SALESMEN.  Which does not cause an error; the only first 3 are shown.

    As you can see, having less of 3 does not cause any errors, either.

    For more info on pivots, see the FAQ of the Forum:

    Re: 4. How can I convert rows to columns?

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    Explain, using specific examples, how you get these results from these data.

    If yod post rather a problem using scott.emp, then you need not display the sample data; just results and explanations.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum:

    Re: 2. How can I ask a question in the forums?

  • Get rid of BarChart legend and create a horizontal line to a specific value

    Hey,.
    I work with barregraphes.
    1st screen: I want to disable the legend of my Barchart.
    http://imgur.com/wMo6Tfv, DRiNA9C
    Second screen: I want to create a line in my Barchart on a specific value 700 as seen on the screen.
    http://imgur.com/wMo6Tfv, DRiNA9C #1
    Is this Possible? Also: what object to set the ID to change the color bar. I tried

    Chart histogram;
    barchart.setId ("Chart");

    CSS:
    #barchart
    {
    -fx-background-color: red;
    }
    But it did not work. Thank you!

    No, you do not miss anything. I had a temporary brain freeze. You can add nodes directly to an arbitrary region.

    If this makes it a little harder. You need to add the line to the container in which your chart is maintained, and of course this means that you understand the coordinates of the line relative to this container. To simplify a bit, axis has a scale property of conversion of units of the axis to display units, and also according to the docs of css, the table has a child with the css class "table-horizontal-zero line." So one possible strategy is to enter this line and figure the change in the coordinates needed him. There is still work to do to find the correct coordinates relative to the container, and if you want it to run with things move (for example, when the user resizes the window), you need to do a lot of link.

    This seems to work:

    import java.util.Arrays;
    import java.util.List;
    
    import javafx.application.Application;
    import javafx.beans.binding.DoubleBinding;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.chart.CategoryAxis;
    import javafx.scene.chart.LineChart;
    import javafx.scene.chart.NumberAxis;
    import javafx.scene.chart.XYChart;
    import javafx.scene.control.Button;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.Region;
    import javafx.scene.shape.Line;
    import javafx.stage.Stage;
    import javafx.util.StringConverter;
    
    public class LineChartSample extends Application {
    
      @Override
      public void start(Stage stage) {
        stage.setTitle("Line Chart Sample");
        final CategoryAxis xAxis = new CategoryAxis();
        final NumberAxis yAxis = new NumberAxis();
        yAxis.setTickLabelFormatter(new StringConverter() {
    
          @Override
          public Number fromString(String string) {
            return Double.parseDouble(string);
          }
    
          @Override
          public String toString(Number value) {
            return String.format("%2.2f", value);
          }
    
        });
        xAxis.setLabel("Month");
    
        final LineChart lineChart = new LineChart(
            xAxis, yAxis);
    
        lineChart.setTitle("Stock Monitoring, 2010");
        lineChart.setAnimated(false);
    
        final XYChart.Series series = new XYChart.Series<>();
        series.setName("My portfolio");
    
        final List> data = Arrays.asList(
    
        new XYChart.Data("Jan", 23),
            new XYChart.Data("Feb", 14),
            new XYChart.Data("Mar", 15),
            new XYChart.Data("Apr", 24),
            new XYChart.Data("May", 34),
            new XYChart.Data("Jun", 36),
            new XYChart.Data("Jul", 22),
            new XYChart.Data("Aug", 45),
            new XYChart.Data("Sep", 43),
            new XYChart.Data("Oct", 17),
            new XYChart.Data("Nov", 29),
            new XYChart.Data("Dec", 25));
    
        series.getData().addAll(data);
    
        final AnchorPane chartContainer = new AnchorPane();
        AnchorPane.setTopAnchor(lineChart, 0.0);
        AnchorPane.setBottomAnchor(lineChart, 0.0);
        AnchorPane.setLeftAnchor(lineChart, 0.0);
        AnchorPane.setRightAnchor(lineChart, 0.0);
        chartContainer.getChildren().add(lineChart);
    
        Button button = new Button("Show line");
        button.setOnAction(new EventHandler() {
    
          @Override
          public void handle(ActionEvent event) {
    
            final double lineLevel = 35;
    
            final Region chartRegion = (Region) lineChart
                .lookup(".chart-plot-background");
    
            final Line zeroLine = (Line) lineChart
                .lookup(".chart-horizontal-zero-line");
    
            final DoubleProperty startX = new SimpleDoubleProperty(0);
            final DoubleProperty endX = new SimpleDoubleProperty(0);
            final DoubleProperty y = new SimpleDoubleProperty(0);
    
            startX.bind(new DoubleBinding() {
              {
                super.bind(chartRegion.boundsInParentProperty());
              }
    
              @Override
              protected double computeValue() {
                double x = chartRegion.getBoundsInParent().getMinX();
                for (Node n = zeroLine.getParent().getParent(); n != chartContainer && n.getParent() != null; n = n.getParent()) {
                  x += n.getBoundsInParent().getMinX();
                }
                return x;
              }
            });
    
            endX.bind(new DoubleBinding() {
              {
                super.bind(chartRegion.boundsInParentProperty());
              }
    
              @Override
              protected double computeValue() {
                double x = chartRegion.getBoundsInParent().getMaxX();
                for (Node n = zeroLine.getParent().getParent(); n != chartContainer && n.getParent() != null; n = n.getParent()) {
                  x += n.getBoundsInParent().getMinX();
                }
                return x;
              }
            });
    
            y.bind(new DoubleBinding() {
              {
                super.bind(chartRegion.boundsInParentProperty(),
                    yAxis.scaleProperty(), zeroLine.startYProperty());
              }
    
              @Override
              protected double computeValue() {
                double y = zeroLine.getStartY() + lineLevel * yAxis.getScale();
                for (Node n = zeroLine.getParent().getParent(); n != chartContainer && n.getParent() != null; n = n.getParent()) {
                  y += n.getBoundsInParent().getMinY();
                }
                return y;
              }
            });
    
            Line line = new Line();
            line.startXProperty().bind(startX);
            line.endXProperty().bind(endX);
            line.startYProperty().bind(y);
            line.endYProperty().bind(y);
    
            chartContainer.getChildren().add(line);
          }
    
        });
    
        BorderPane root = new BorderPane();
        root.setCenter(chartContainer);
        root.setTop(button);
    
        Scene scene = new Scene(root, 800, 600);
        lineChart.getData().add(series);
    
        stage.setScene(scene);
        stage.show();
    
      }
    
      public static void main(String[] args) {
        launch(args);
      }
    }
    
  • How to take specific values of a 2d array

    Hi all

    I have a 10 X 10 reasult 2d chart. for example:

    1 2 3 4

    5 6 7 8

    9 10 11 12

    and I want a specific values in the table / say 1,3,7 and 10 (there is no reason given to work with..)

    I used the IndexArray, but because it's about 20 values, it is hell to change and to debug the hell...

    Is there a more elegant way to do it?

    Thank you!

    (this is a great forum, this is my first time ask your question, but I followed you for a while!)

    You can drag the array index down function, by creating something that looks like this:

    That will allow you at the exit of the multiple elements of the same array, putting in each other simultaneously prepare for clues. If you want to make it easier to debug, make the index entries, name them effectively and group them in x, y pairs.

    You can also do an array of Boolean and can select the indices you want. It makes more sense if your clues must be selected graphically.

  • Function return undefined values

    My function returns undefined values. It seems that the return of the function statement is executed before the database is queried and values are assigned to variables. If I do an alert within the loop for () I get the correct values from the database, but these values are not affected before excecuting the return statement function. How can I do this differently?

    function getColumnNames(table){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                                    alert(rs1); //correct value is returned here
                }
            });
        });
        return [rs1, rs2, rs3, rs4, rs5];
    }
    

    Hey Fabian,.

    You are quite correct that the return statement is executed before the database returns the results. There are ongoing asynchronous calls. You can set breakpoints in JavaScript code to see what is happening. You can correct the problem by using function callbacks. I edited your code below to use the callback functions - there might be a few typos, but the general approach should be wooded.

    function getColumnNames(table, callback){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                        alert(rs5); //correct values are being returned
                    callback([rs1, rs2, rs3, rs4, rs5]);
                }
            });
        });
    }
    
    // example of how to call getColumnNames with callback
    getColumnNames('importantTable', function (result)
    {
        console.log(result);
    });
    
    // alternative version
    function onCallback(result)
    {
        console.log(result);
    }
    
    getColumnNames('importantTable', onCallback);
    

    I hope this helps.

    See you soon,.

    James

  • Cannot return a value in LOV

    Dear all,

    I have create a LOV in my code field that is a primary key at my table. And I can't return the value from the lov,

    I get the below error.

    oracle.jbo.InvalidOperException: Houston-29114 ADFContext is not configured to process this exception messages. Use the code of exception stack trace and error to investigate the root cause of this exception. Root cause error code is Houston-34014. Error messages settings are {0 = oracle.jbo.Key [null A9], 1 = root}

    Please note that am I 1 primary key with 2 field in my table.

    And note that use jdev 12.1.3

    Another solution...!

    There is always another solution:

    -' they' can remain on Oracle Forms and forget ADF

    -' they' can refine their requirements to equip the technical constraints of the ADF

    -' they' can use some other technologies instead of the ADF

    Dario

  • Manually created SelectManyChoice survey error when certain specific values are selected.

    Hello

    I manually set the values for the component selected choice a lot of a view object.

    The list is retrieved correctly on the UI, but when I select some specific values it gives an error - error: the value is not in the correct format. Enter a value for this type: {2}

    I put the Auto Submit - True and I have a valueChangeListener hung for this component.

    All can help me in this regard

    Here's the code,

    < af:selectManyChoice value = "#{backingBeanScope.AllocationQuickCreateBean.warehouseList} '"

    label = "#{publicuiviewcontrollerBundle.Warehouse}" id = 'smc1' "

    Binding = "#{backingBeanScope.AllocationQuickCreateBean.warehouseSelectMany} '"

    partialTriggers = "it1 soc1" autoSubmit = 'true '.

    valueChangeListener = "#{backingBeanScope.AllocationQuickCreateBean.warehouseValChanged} '"

    Disabled = "#{backingBeanScope.AllocQuickCreateAccessibilityBean.Disabled ['Warehouse']}" "

    valuePassThru = "true" >

    < f: selectItems value = "#{bindings." AllocationQCWarehouseVO1.items}"id ="si3"/ >

    < / af:selectManyChoice >

    Similar mail was returned?

    Incorrect in error message

  • Plugin to point that returns multiple values

    When you create an APEX element that can return multiple values, such as a checkbox, APEX uses the settings of varchar2 p_v01 - p_v200 instead of the p_t01 table settings - p_t200.

    I would like to create a plugin item type that can return multiple values in the same way, so that the session recorded for the item state contains a delimited string of values.  I realize, I could achieve with Javascript and a hidden item, but I really want to a non-Javascript solution.  Is this possible?  If this isn't the case, it would be a nice improvement!

    Hi Tony,.

    Take a look at the level of the parameter p_is_multi_value of the APEX_PLUGIN. GET_INPUT_NAME_FOR_PAGE_ITEM api (http://docs.oracle.com/cd/E37097_01/doc.42/e35127/apex_plugin.htm#AEAPI1254). If you set it to TRUE, you will get one of the p_v01 - p_v200 table settings. It's the same what our box element type calls.

    Concerning

    Patrick

    Member of the APEX development team

    My Blog: http://www.inside-oracle-apex.com

    APEX Plug-Ins: http://apex.oracle.com/plugins

    Twitter: http://www.twitter.com/patrickwolf

  • get specific values of several

    This is probably a stupid question, but I can't seem to understand. I have a similar chart to below. There are project files in it, several recordings by project. Im trying to get a separate list of projects that do not have a specific value.

    create table test_project)

    number of project_record

    Varchar2 (50) project.

    project_status varchar2 (50)

    );

    -Select * from test_project

    insert into test_project (project_record, project, project_status) values (1, '123abc', 'active');

    insert into test_project (project_record, project, project_status) values (2, '123abc', 'active');

    Insert into test_project (Project_Record, project, Project_Status) values (3, '123abc', 'active');

    Insert Into test_project (Project_Record, project, Project_Status) Values (4, '123abc', 'total');

    insert into test_project (project_record, project, project_status) values (1, "123cba", "started");

    insert into test_project (project_record, project, project_status) values (2, '123cba', 'active');

    Insert into test_project (Project_Record, project, Project_Status) values (3, '123cba', 'active');

    insert into test_project (project_record, project, project_status) values (4, '123cba', 'guarantee');

    insert into test_project (project_record, project, project_status) values (1, '321abc', 'active');

    insert into test_project (project_record, project, project_status) values (2, '321abc', 'active');

    Insert Into test_project (Project_Record, project, Project_Status) Values (3, '321abc', 'complete');

    insert into test_project (project_record, project, project_status) values (4, '321abc', 'guarantee');

    insert into test_project (project_record, project, project_status) values (1, '555abc', 'active');

    insert into test_project (project_record, project, project_status) values (2, '555abc', 'active');

    Insert into test_project (Project_Record, project, Project_Status) values (3, '555abc', 'active');

    insert into test_project (project_record, project, project_status) values (4, '555abc', 'active');

    I want to choose project_record and project where none of the project files have 'full' in it.

    So if a project is complete in this document, regardlesss of the place where it should not go up.

    Hello

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

    Don't forget to post the exact results you want from this data, as well as an explanation of why.  It may be obvious to you is as a 'project', but not everyone who wants to help is also familiar with your application you are.  Is all separate project_record project, each distinct project or all the distinct combinations of these 2?

    Here are the results you want?

    PROJECT_RECORD PROJECT

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

    1 123cba

    1 555abc

    2 123cba

    2 555abc

    3 123cba

    3 555abc

    4 123cba

    4 555abc

    ?  Otherwise, each separate project is a project and the results include all the lines with project = '123abc' or '321abc', because these project_ids have a rank with project_status = "Finish."

    If so, one way is:

    WITH got_complete_cnt AS

    (

    SELECT project_record, project

    , COUNTY (CASE

    WHEN project_status = "Finish."

    THEN 'X '.

    END

    ) OVER (PARTITION BY project) AS complete_cnt

    OF test_project

    )

    SELECT project_record, project

    OF got_complete_cnt

    WHERE complete_cnt = 0

    ORDER BY project_record, project

    ;

    Include other ways to achieve the same results

    • NOT EXISTS subquery
    • NOT IN subquery
    • Semi Join
  • RETURN type of function table

    Hello

    I read conflicting information about the return type that has a table function must or may use.

    First, I am a student of a book that says:

    Function in pipeline returns the data types:

    The main constraint for the pipeline functions, it is the return type must be a collection type autonomous which can be used in SQL - i.e. a VARRAY or table nested.

    and then in the next sentence...

    More precisely a pipeline function can return the following:

    A stand-alone nested table or VARRAY, defined at the schema level.

    A nested table or VARRAY that has been declared in a package type.

    This seems to go against the first quoted sentence.

    Now, before reading the above text I had done just my own test to see if a packed type would work because I thought I had read somewhere that it would not, and he does not (the test code and this output is at the end of this question). When I arrived in the text above, after my test, so I was naturally confused.

    So, I'm going to PL/SQL reference that says:

    RETURN data type

    The data type of the value returned by a function table in pipeline must be a type collection defined either at the level of schema or within a package (therefore, it cannot be a type of associative array).

    I tried to call a function that returns a collection of VARRAY type packaged in both SQL and PL/SQL (of course below is SQL all in any case) and no work.

    Now I'm wondering what is a TABLE function must use a schema type and a function table in pipeline can use a packaged type?  I see that I created and called a function table but examples of Oracle see the creation and use of a function table in pipeline.

    Edit: I should add that I read the following sentence in the SF book on p609 in * table functions: "this type of nested table must be defined as an element of level diagram, because the SQL engine must be able to resolve a reference to a collection of this kind."

    So that it begins to resemble table functions should return a schema type and pipelined table functions, perhaps because that they don't in fact return a collection, rather they return (RowSource) content, can use the schema types or types of packages. Is this correct?

    Can someone clarify this for me please?

    Thank you in advance,

    J

    CREATE OR REPLACE PACKAGE PKGP28M

    VAT-type is varray (5) number;

    END;

    /

    DISPLAY ERRORS

    create or replace type VAT is varray (5) number;

    /

    display errors

    create or replace function tabfunc1 return pkgp28m.vat as

    numtab pkgp28m.vat:=pkgp28m.vat();

    Start

    numtab.extend (5);

    because loop me in 1.5

    numtab (i): = trunc (dbms_random. Value (1.5));

    end loop;

    Return numtab;

    end;

    /

    display errors

    create or replace function tabfunc2 as return VAT

    numtab vat:=vat().

    Start

    numtab.extend (5);

    because loop me in 1.5

    numtab (i): = trunc (dbms_random. Value (1.5));

    end loop;

    Return numtab;

    end;

    /

    display errors

    exec dbms_output.put_line (' call tabfunc1 (returns the packaged type) :');)

    Select * from table (tabfunc1)

    /

    exec dbms_output.put_line (' call tabfunc2 (returns the type of schema) :');)

    Select * from table (tabfunc2)

    /

    declare

    RC sys_refcursor;

    number of v;

    Start

    dbms_output.put_line (' in anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type) :');)

    Open rc to select table column_value (tabfunc1);

    loop

    extract the rc in v;

    When the output rc % notfound;

    dbms_output.put_line (' > ' | to_char (v));

    end loop;

    close the rc;

    end;

    /

    declare

    RC sys_refcursor;

    number of v;

    Start

    dbms_output.put_line (' in anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema) :');)

    Open rc to select table column_value (tabfunc2);

    loop

    extract the rc in v;

    When the output rc % notfound;

    dbms_output.put_line (' > ' | to_char (v));

    end loop;

    close the rc;

    end;

    /

    Scott@ORCL > @C:\Users\J\Documents\SQL\test29.sql

    Package created.

    No errors.

    Type of creation.

    No errors.

    The function is created.

    No errors.

    The function is created.

    No errors.

    the call of tabfunc1 (returns the packaged type):

    PL/SQL procedure successfully completed.

    Select * from table (tabfunc1)

    *

    ERROR on line 1:

    ORA-00902: invalid data type

    the call of tabfunc2 (returns the type of schema):

    PL/SQL procedure successfully completed.

    COLUMN_VALUE

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

    1

    4

    1

    1

    3

    In anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type):

    declare

    *

    ERROR on line 1:

    ORA-00902: invalid data type

    ORA-06512: at line 6

    In anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema):

    > 1

    > 2

    > 4

    > 2

    > 3

    PL/SQL procedure successfully completed.

    Post edited by: Jason_942375

    But the compilation of the PIPELINED WILL CREATE the schematic function types automatically. And the TABLE function, applied to the PIPELINED function, use these types of hidden patterns.

  • return a value on an input

    Hello

    I'm trying to get the value of a column on a correction of data which are not mentioned in the table.
    For example, I have this db:
    Data name taxable
    02/01/12 John Y
    05/01/12 John Y
    09/01/12 John N
    15/01/12 John Y
    20/01/12 John N
    28/01/12 John Y

    I need to create a function that will return the value of "taxable" on a date introduced considering also the value after this date!

    For example if I want to know the value of "taxable" for data, 21/01/2012, it should return 'n'.
    I then work, but it does not work properly :(

    Create the taxable service
    (p_data as
    )
    Start
    Start
    Select max (data)
    in w_data
    table
    where w_data < p_data
    and p_data < data
    and taxable = 'Y '.
    and (taxable) count < = 1;

    Back to 'Y '.

    exception
    while others then
    back 'n';
    taxable purpose;

    Basically, I want to know what is the taxable value to a date that I did not in the table, but I know it is the same with the value to the last date inserted into the table.
    21/01/2012 to return me the taxable value on 20/01/2012.

    Can someone tell me what is the syntax of the correct function?

    Thank you!

    Hi Mario,.

    The solution is not really what I need... for example, function he wrote you will return 'Y' for 21/01/2012 even if the last value that must be returned is ' n the value of 20/01/2012!

    Can't see that it returns "Y".

    SQL> create table taxes as (
       select to_date('01/02/12', 'mm/dd/yy)') Data, 'John' Name, 'Y' taxable from dual union all
       select to_date('01/05/12', 'mm/dd/yy)') Data, 'John' Name, 'Y' taxable from dual union all
       select to_date('01/09/12', 'mm/dd/yy)') Data, 'John' Name, 'N' taxable from dual union all
       select to_date('01/15/12', 'mm/dd/yy)') Data, 'John' Name, 'Y' taxable from dual union all
       select to_date('01/20/12', 'mm/dd/yy)') Data, 'John' Name, 'N' taxable from dual union all
       select to_date('01/28/12', 'mm/dd/yy)') Data, 'John' Name, 'Y' taxable from dual)
    /
    Table created.
    SQL> select max(ta.taxable) keep (dense_rank last order by data) is_taxable
       from   taxes ta
       where  ta.data <= date '2012-01-21'
       and    ta.name = 'John'
    /
    IS_TAXABLE
    ----------
    N
    1 row selected.
    

    On line generator, is not a solution, I have some information for 10 years, and for 5,000 students, I can't use a generator of line!

    I wouldn't count on that, and at least it depends on what you're trying to answer.

    The solution is what I thought to count the values in column "Taxable" until the data entered and if is smaller than 1, then it should return 'Y' otherwise it should return "n"
    and also, it must check the max (data) and if between max (data) - p_data, "taxable" corresponds to 'Y' it must return the previous value, otherwise it should return ' n '...

    The description is quite convoluted. Isn't it just as the last record Y or N, is valid until a new record is entered?
    (Still think that's what suggests the service done)

    Create the taxable service
    (p_data as
    )
    Start
    Start
    Select max (data)
    in w_data
    table
    where w_data<>
    and p_data<>
    and taxable = 'Y '.
    and count (taxable)<=>
    Back to 'Y '.

    exception
    while others then
    back 'n';
    taxable purpose;

    What is w_data - you never mentioned that.

    And please delete then others.

    So what I need is just the data already in the db, nothing else generated extra as I explained.

    No, you have not explained. And your subject even has "introduced".

    But true, maybe that might be too advanced. I'm starting to feel it's school work. If this is the case, it would be good to mention in your original post. The kind of help that you receive could be very different.

    Concerning
    Peter

  • XML - ORA-19025: EXTRACTVALUE returns the value of a single node

    Hello

    I'm new to XML DB. Can someone help me with the below XML

    I use the following XML... (I pasted a part only of it coz I need data only up to this article)

    XML
    --------------------

    <? XML version = "1.0" encoding = "UTF-8"? > < SOAP - ENV:Envelope xmlns:SOAP - ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-."
    example"container ="http://www.w3.org/2001/XMLSchema"> < SOAP - ENV:Body >
    < ns:PicklistWS_GetPicklistValues_Output xmlns:ns = "urn: crmondemand/ws/list dropdown /" >
    < ListOfParentPicklistValue xmlns = "urn: / xml/crmondemand/list of choices" >
    < ParentPicklistValue >
    < language > ENU < / language >
    < ParentFieldName > plProduct_Team < / ParentFieldName >
    < ParentDisplayValue > Marketing On Demand < / ParentDisplayValue >
    < ParentCode > Marketing On Demand < / ParentCode >
    < Disabled > N < / disabled >
    < ListOfPicklistValue >
    < PicklistValue >
    Escalation of OCP/SME < code > < code >
    Escalation of OCP/SME < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >
    < PicklistValue >
    Ask fusion < code > < code >
    Merge request < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >



    Code
    ---------




    SELECT distinct
    EXTRACTVALUE (value (SR), ' / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code ','xmlns = "urn: / crmondemand/xml/list of choices"') AS display.
    Return EXTRACTVALUE (value (SR),'/ ParentPicklistValue/ListOfPicklistValue/PicklistValue/DisplayValue ',' xmlns = "urn: / crmondemand/XML/picklist"'),.
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentDisplayValue','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_display,
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentCode','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_return
    TABLE (XMLSEQUENCE ((EXCERPT)
    WEB_SERVICE (' <? xml version = "1.0" encoding = "UTF - 8" standalone = "no"? > < envelope soap: xmlns:soap = "http://schemas.xmlsoap.org/soap/envelope/")
    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" >
    < soap: Body >
    < PicklistWS_GetPicklistValues_Input xmlns = "urn: crmondemand/ws/list dropdown /" >
    Type < FieldName > < / FieldName >
    Service request < RecordType > < / RecordType >
    < / PicklistWS_GetPicklistValues_Input >
    < / soap: Body >
    "< / envelope soap: >.
    (' document / urn: crmondemand/ws/list dropdown /: ' GetPicklistValues, Id_de_la_session).
    "/: soap envelope / soap: Body / * / * / * ',' xmlns:soap ="(http://schemas.xmlsoap.org/soap/envelope/'))) SR "


    ERROR
    ---------

    ORA-19025: EXTRACTVALUE returns the value of a single node


    UNDERSTANDING
    ---------------------------

    As my Xpath only points until the node - ParentPicklistValue and not the child nodes under it. That's why, when I try to interview the child nodes - / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code, I get the error mentioned above.

    REQUIREMENT
    -----------------------

    Can someone help me to receive the values of the mother and child values based on xml and query above.

    Hello

    It's a classic ;)

    You need a second XMLSequence who shreds the collection of PicklistValue in relational lines:

    select extractvalue(value(sr2), '/PicklistValue/Code', 'xmlns="urn:/crmondemand/xml/picklist"') AS Display
         , extractvalue(value(sr2), '/PicklistValue/DisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS Return
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentDisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_display
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentCode', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_return
    from table(
           xmlsequence(
             extract( WEB_SERVICE( ... )
                    , '/soap:Envelope/soap:Body/ns:PicklistWS_GetPicklistValues_Output/ListOfParentPicklistValue/ParentPicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"
                       xmlns:ns="urn:crmondemand/ws/picklist/"
                       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' )
           )
         ) sr1
       , table(
           xmlsequence(
             extract( value(sr1)
                    , '/ParentPicklistValue/ListOfPicklistValue/PicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"' )
           )
         ) sr2
    ;
    

    What is your version of the database BTW?
    10.2 and upward, you can use the XMLTable.

Maybe you are looking for