How to pass parameter in the function using the select statement?

Hello

I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?

For example,.
Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.

but

Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.

Thank you for trying to help him. Thank you.

Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">

Try like this

select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')

Just make sure that your subquery returns only 1 row.

Tags: Database

Similar Questions

  • SHOW_LOV need to pass a parameter for the select statement

    Hello

    I have a requirement that there is only a drop down list but the display of the list should be based on the certern parameter.

    I have a table (id, type, description). The select statement for dropdown I need is

    SELECT id, description of the table where type = & input_param.

    Can someone help please!

    create a field and create value in the list select id, description from table1 where col =: block1.item

  • Optional parameter in the Select statement.

    Hello

    Could you let me know on below, I want to make the optional parameter, the user could pass a value or not.

    Select *.

    of dovur_ert

    where model_line_number =: model

    and item = nvl (:, 1 );

    Thank you

    Select *.

    of dovur_ert

    where model_line_number =: model

    and item = nvl (:, point);

  • How to pass parameter in the function extract (for XMLTYPE)

    I have a table with XMLTYPE field xml_column PROBLEMXML. In this column, there are many deffinitions for the problem. There is no amount deffinitions max and there can be no definition at all. I need to return all the definitions of all the problems a string wirh separate definitions by '; '.

    Query
    SELECT extract (prob. Def,'/definitions/definition[1]/@var'). ';'|| excerpt (prob. Def,'/definitions/definition[2]/@var')
    OF PROBLEMXML j.
    XMLTABLE)
    "/ problem.
    PASSAGE j.xml_column
    Probid VARCHAR COLUMNS (31) PATH ' / problem/@id',
    Prob def XMLTYPE PATH ' / problem/definitions ")
    where PROBLEM_ID = 1;
    Returns exactly what I want one; m.
    But
    declare
    my_variable varchar2 (2000): = null;
    number of N1;
    number of N2;
    Start
    N1: = 1;
    N2: = 2;
    SELECT extract (prob. Def,'/definitions/definition[N1]/@var'). '|'|| excerpt (prob. Def,'/definitions/definition[N2]/@var') in my_variable
    OF ETL_PROBLEMXML_STG_T j.
    XMLTABLE)
    "/ problem.
    PASSAGE j.xml_column
    Probid VARCHAR COLUMNS (31) PATH ' / problem/@id',
    Prob def XMLTYPE PATH ' / problem/definitions ")
    where PROBLEM_ID = 1;
    dbms_output.put_line ($my_var);
    end;
    Returns null.
    Is there a way to switch the setting to extract the function?

    You have string literal death of n1 and n2. Note the change to select it.

    DECLARE
      my_var VARCHAR2(2000) := NULL;
      n1     NUMBER;
      n2     NUMBER;
    BEGIN
      n1 := 1;
      n2 := 2;
      SELECT extract(prob.def, '/Definitions/Definition[' || n1 || ']/@var') || '|' ||
             extract(prob.def, '/Definitions/Definition[' || n2 || ']/@var')
        INTO my_var
        FROM etl_problemxml_stg_t j,
             xmltable('/problem' passing j.xml_column columns probid VARCHAR(31) path '/problem/@id',
                      def xmltype path '/problem/Definitions') prob
       WHERE problem_id = 1;
      dbms_output.put_line(my_var);
    END;
    

    Published by: RPuttagunta on December 13, 2010 09:18

  • Table query result using prepared as a parameter in the prepared statement later

    Hi all

    Very new to PHP. A series of 3 prepared statements (see code below), I'm trying to sink.  This page is triggered from a link on a page that lists the individual and all candidates which works well.  Prepared statement 1 works and displays the data in the columns line wanted specific, bottom access so I would call it record and areas, but I think it is called line and columns here.  Prepared Statement 2 which hands on a table of cross references (we have a many-to-many relationship between candidates and positions, therefore for the table of cross references) works and I can say the $selected_positions charges table, because I can see position_id data in the < body > of the file using this:

    <? PHP

    foreach ($selected_positions as $item) {}

    echo $item. "< br / > ';

    }

    ? >

    Can't take this $selected_positions table and use it as parameter in the prepared statement 3, at least not how I try to do.  So obviously he manages not prepared statement 3 no way is a table that I called $the_positions which is supposed to contain the ID of the post, position of securities and to position the position_id numbers that are in the array $selected_positions.  I can say that 3 of prepared statement is a failure because there is no indication in this table that is in the < body > of the file:

    < table class = "stripes table" >

    < b >

    Identification of the Position < /th > < th >

    < /Th > < th > post number

    Title < th > < /th >

    < /tr >

    <? PHP while ($stmt-> fetch()) {? >}

    < b >

    < td > <? = $position_id;? > < table >

    < td > <? = $position_number;? > < table >

    < td > <? = $title;? > < table >

    < /tr >

    <? PHP}? >

    < /table >

    Here is the PHP script:

    <? PHP

    require_once '... /includes/session_timeout_db.php';

    ? >

    <? PHP

    require_once '... /includes/Connection.php';

    initialize the flag

    $OK = false;

    $conn = dbConnect ('read');

    initialize statement

    $stmt = $conn-> stmt_init();

    If (isset($_GET['candidate_id'])) {}

    $sql = ' SELECT candidate_id, last_name, first_name, society, mas_number, last_modified, notes

    CANDIDATES WHERE candidate_id =?'; }

    If ($stmt-> {prepared ($sql))}

    bind the query parameter

    $stmt-> bind_param ('i', $_GET ['candidate_id']);

    run the query and fetch the result

    $OK = $stmt-> execute();

    bind the results to variables

    $stmt-> bind_result ($candidate_id, $last_name, $first_name, $company, $mas_number, $last_modified, $notes);

    $stmt-> fetch();

    free resources for the second query database

    $stmt-> free_result();

    }

    get the associated positions candidate

    $sql = 'SELECT position_id FROM pos2cands WHERE candidate_id =?';

    If ($stmt-> {prepared ($sql))}

    bind the query parameter

    $stmt-> bind_param ('i', $_GET ['candidate_id']);

    run the query and fetch the result

    $OK = $stmt-> execute();

    $stmt-> bind_result ($position_id);

    Browse the results to store in a table

    $selected_positions = [];

    While ($stmt-> fetch() {)}

    [] $selected_positions = $position_id;

    }

    }

    find data on the position of the table

    $sql = ' SELECT position_id, position_number, title

    FROM place WHERE position_id =?';

    If ($stmt-> {prepared ($sql))}

    bind the query parameter

    $stmt-> bind_param ('i', $_GET [$position_id]);

    run the query and fetch the result

    $OK = $stmt-> execute();

    bind the results to variables

    $stmt-> bind_result ($position_id, $position_number, $title);

    Browse the results to store in a table

    $the_positions = [];

    While ($stmt-> fetch() {)}

    [] $the_positions = $position_id;

    }

    }

    Get the error message if the request fails

    If (isset ($stmt) & &! $OK) {}

    $error = $stmt-> error;

    }

    If (! $stmt) {}

    $error = $conn-> error;

    } else {}

    $numRows = $stmt-> num_rows;

    }

    ? >

    Thank you in advancel

    You want to use the value of request 1 or query2 as a parameter in the query 3, right? Rather than build a table, you can simply use the value returned by each line that the query returns. I use PDO, no MySQLi, so I can't knock out quickly the MySQLi example for you.

    While ($result = $sql-> fetch (PDP::FETCH_ASSOC)) {}
    $field = $result ['domain'];

    Now we can use the value of $field as parameter for the next query.

    The brace that closes the while loop is placed after the last query

    so no need to fill an array with values

    }

    Your approach is doable with a few changes to the way in which you go through the table, but it is unnecessarily complicated.

    You might be able to use a single query to get all the data if you use left joins. With this approach, you start with the table that SHOULD return a result or which requires no dependencies to other tables. The structure is like this:

    SELECT field1, Field2, field3 FROM (SELECT * FROM table1 WHERE field3 = param1) has

    LEFT JOIN (SELECT * FROM table2 WHERE A.field4 = table2.field4) B

    LEFT JOIN table3 ON table3.field5 = B.field5 ORDER BY Field1

    A and B above are aliases for subsets of the table. You can image a (tacit) sign = equal A

  • I have a CC to individuals on the annual plan paid monthly membership. How to pass it to the CC for the teams plan so that I can add my first certificate of employee?

    I have a CC to individuals on the annual plan paid monthly membership. How to pass it to the CC for the teams plan so that I can add my first certificate of employee?

    Hi Alexalloy,

    This should help. Cancel your subscription or membership. Cloud Creative

    See you soon!

    ~ David

  • How to use the select statement in loop for

    Hi all

    My question is can I use a select statement in for loop like as follows.

    for the key in the selection of one_table key.

    When I use this am getting an error as found select invalid I ID

    How to select a statement use in loop for

    Please suggest me.

    Thank you
    Sree

    Hello

    You can use code below

    For key in (select button from table_a)
    loop
    If key.key = 1 then
    -insert statement
    on the other
    -Select statement
    end loop;

    Thank you
    Naveen.

  • Marshall plan: how to pass data between the main field and sub-application

    Hello

    I'm trying to load a Flex 3.5 application in Flex 4. In the process, I need to move a strong local typed object from main application to the loaded swf file. And I also have to pass a rope and a bitmap of application sub to the main application. Have an example to show how to pass data in the application domain?

    Thank you

    SW

    Define scaleContent = true, set a breakpoint on SWFLoader.as:doScaleContent and

    see if he thinks there's a swfBridge.

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • How to use the variable instead of the table name in the select statement of procedure

    I have a procedure with a select statement with dynamic from clause. How can I use instead of the name of the table variable.

    create or replace procedure scc_chemical_analysis
    is
    v_table_name varchar2 (100);
    Start

    declare
    cursor c1 is select * from v_table_name; -This is the variable name. How can I use it in the select statement.
    .
    .
    .
    .



    end;

    Hello

    something like that.

      1  declare
      2     vSQLString      VARCHAR2(32000);
      3  pTableName varchar2(1000):='EMP';
      4  BEGIN
      5     vSQLSTRING :=
      6  'SELECT ''x'' FROM ' || DBMS_ASSERT.sql_object_name(pTableName) || ' WHERE rownum<=1 ';
      7     EXECUTE IMMEDIATE vSQLSTRING;
      8* END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
  • Update using a function in the select statement

    Hello

    Is it possible to do the follwing.

    I tabele and a custom function, the custome service will update the column (amount) of the table based on the value of going through the function of the select statement.

    SELECT id, stock, where an id = get_update (id);

    Now


    Get_update function will return the same id I'm passing and update the column amount to a value in the
    table a.

    When I run the satament selection I have the updated data in the column amount in my first executtion, but if execute the same statement, again, I see the changes reflected. is it possible to get data updates to the first performance himself.

    the function is of type PRAGMA AUTONOMOUS_TRANSACTION

    Concerning

    Indeed a strange requirement and probably not the way to go in a production environment. But anyway is a way to achieve your goal

    SQL> create table a
    as
       select   12 id, 500 amount from dual
       union all
       select   13 id, 600 amount from dual
    /
    Table created.
    
    SQL> create or replace type a_typ as object (id number, amount number)
    /
    Type created.
    
    SQL> create or replace function get_id (pid number)
       return a_typ
    is
       pragma autonomous_transaction;
       l_a_typ   a_typ := a_typ (null, null);
    begin
          update   a
             set   amount = 800
           where   id = pid
       returning   id, amount      into   l_a_typ.id, l_a_typ.amount;
    
       commit;
    
       return l_a_typ;
    end get_id;
    /
    Function created.
    
    SQL> select   id, d.a_typ.amount amount
      from   a, (select get_id (13) a_typ from dual) d
     where   id = d.a_typ.id
    /
            ID     AMOUNT
    ---------- ----------
            13        800
    1 row selected.
    
  • Why I can't use the procedure in the select statement

    Why I can't use the procedure in the select statement

    And you may not usa a SQL function if it has out parameters

    SQL> create function myfun(p1 in out number) return number is
      2  begin
      3  p1:=1;
      4  return 2;
      5  end;
      6  /
    
    SQL> select myfun(5) from dual;
    select myfun(5) from dual
           *
    ERRORE alla riga 1:
    ORA-06572: Function MYFUN has out arguments
    

    In fact, the problem is that an output parameter is passed 'ref' and not 'val '...

    Max

  • function() nested in the select statement

    Oracle 11g. Try to nest a function within the select statement.  Goal: get the average customer rating for each of the qualified user.

    Select user_name, f_get_avg_cust_rating() "Notation.

    of u, OTHER_TABLES o TAB_USER

    where u.id = o.id and another condition matched;

    How Oracle would deal with the sql.  Is it

    (1) first of all display records based on the where clause, then call the f_get_avg_cust_rating() for each of the selected records OR

    (2) for the analysis in tables, the f_get_avg_cust_rating() will be called for each record met?

    Thank you

    Scott

    Words of Frank, I created two functions with dbms_output and used a function in where clause in select another function. See the bottom of the unit tests. Everyone says, where first clause then select...

    -Where function clause

    SQL > CREATE or REPLACE FUNCTION ret_empno

    2 RETURN NUMBER

    3 AS

    4 BEGIN

    5 DBMS_OUTPUT. Put_line (' where Clause Function');

    6 RETURN 7839;

    7 END;

    8.

    The function is created.

    -Select the function

    SQL > CREATE or REPLACE FUNCTION ret_1

    2 RETURN NUMBER

    3 AS

    4 BEGIN

    5 DBMS_OUTPUT. Put_line ('Select function');

    6 RETURN 1;

    7 END;

    8.

    The function is created.

    SQL > SELECT empno, ename,ret_1

    2 FROM emp

    3. WHERE empno = ret_empno;

    EMPNO, ENAME RET_1

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

    7839 KING 1

    Where the function Clause

    Select the function

  • passing parameters to the select query in DB link to call him...

    I have a DB link that executes the select query based on user specified parameter.

    Now, I created an invoke activity and specified input [which must be passed to the query] and output parameters [it is the result of the query]. That invoke link activity DB calls in which a parameter was created to be used in the select query. So my question is, DB link partner take the input parameter of call activity automatically or do we need to specify a mapping for this?

    When you create a partnerlink db the setting that you create for your chosen matches the entry and when you create the variable entry in the invoke for this partnerlink is created with the type of the parameter.

    Create an assignment before your invoke and assign a value to the input variable that you created in the invoke. This value will be passed and used as a parameter in the selection.

    Heidi.

  • Pass variable in the SELECT... WHERE... (&lt; VAR &gt;) have problems.

    Hi all

    I'm using Oracle 11 g R2 and Linux.

    I'm working on a code in which I need to dynamically pass values to 'IN' clause in a select statement.

    A short demonstration of my question is as below: -.

    Set serveroutput on

    /

    declare

    NUM varchar2 (100): = 1, 2';

    number of v_inst_id;


    Start


    dbms_output.put_line (' value of num before :-'||) (NB);

    Select INST_ID select

    in v_inst_id

    GV $ session

    where username = 'SYS '.

    and to_char (inst_id) in (num) - 1, 2

    order of INST_ID select;


    exception

    while others then

    dbms_output.put_line (SQLERRM);


    end;

    /

    anonymous block filled

    Before value of num:-1, 2

    ORA-01403: no data found

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

    Select INST_ID select

    -by v_inst_id

    GV $ session

    where username = 'SYS '.

    and to_char (inst_id) in (1,2)

    order of INST_ID select;

    INST_ID SELECT

    ----------

    1

    1

    1

    2

    2

    2


    Please let me know why my request does not work in plsql but works perfectly in sql.


    Thanks in advance.

    VJ4 wrote:

    Hello

    Thanks for your reply.

    Can you please give a brief explanation on the example you showed?

    with this request

    SELECT to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) p_id

    OF THE DOUBLE

    WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    CONNECTION BY INSTR (num, ',', 1, LEVEL - 1) > 0

    I shared your (digital) channel of n number of rows in the table

    SQL > set serveroutput on;

    SQL >

    SQL >-created the 11.06.2014 by RAMIN. H

    SQL > declare

    2 num varchar2 (100): = '1.2'.

    3. start

    4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

    5 DOUBLE

    6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

    8 dbms_output.put_line (r.p_id);

    9 end of the loop;

    10 end;

    11.

    1

    2

    PL/SQL procedure successfully completed

    SQL >

    SQL >-created the 11.06.2014 by RAMIN. H

    SQL > declare

    2 num varchar2 (100): = "1,2,3,4,5,6";

    3. start

    4 r in (SELECT to_number (REGEXP_SUBSTR (num, ' [^,] +', 1, ROWNUM)) p_id)

    5 DOUBLE

    6. WHERE to_number (REGEXP_SUBSTR (num ' [^,] +', 1, ROWNUM)) IS NOT NULL

    7 CONNECT BY INSTR (num, ',', 1, LEVEL - 1) > 0) loop

    8 dbms_output.put_line (r.p_id);

    9 end of the loop;

    10 end;

    11.

    1

    2

    3

    4

    5

    6

    PL/SQL procedure successfully completed

    SQL >

    SQL >

    SQL > SELECT to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) p_id

    2 FROM TWO

    3. WHERE to_number (REGEXP_SUBSTR ('& num', ' [^,] +', 1, ROWNUM)) IS NOT NULL

    4 CONNECT BY INSTR ("& num', ',', 1, LEVEL - 1") > 0

    5.

    P_ID

    ----------

    1

    2

    3

    4

    5

    6

    SQL >

    ----

    Ramin Hashimzade

Maybe you are looking for