How to write this query procedure of ina

IF ((drapeau = ' n ') OR (flag = 'F') OR (FLAG =' WAS))
) THEN
SELECT CUSTOMER_ID, BUSINESS_PASSCODE, LOG ON TO V_CUSTOMER_ID, V_BUSINESS_PASSCODE, V_LOG OF THE CUSTOMER
WHERE V_BUSINESS_PASSCODE AND V_CUSTOMER_ID = & ID = & CODE AND
V_LOG IN('Y')
SO I HAVE TO RETURN THE ISP (OF TYPE VARCHAR) CAN YOU TELL HOW DO

Make values flag, id, code as a parameter and an output parameter. You can have any number f settings if you want to return the results of the query.

as
create procedure (identification number, varchar2, varcahr2, out returnvalue flag code varchar2)
as
Start
-your code

---

--
IF ((drapeau = ' n ') OR (flag = 'F') OR (FLAG =' WAS))
) THEN
SELECT CUSTOMER_ID, BUSINESS_PASSCODE, LOG ON TO V_CUSTOMER_ID, V_BUSINESS_PASSCODE, V_LOG OF THE CUSTOMER
WHERE V_CUSTOMER_ID = ID AND CODE = V_BUSINESS_PASSCODE AND
V_LOG IN('Y');
returnValue =;

Tags: Database

Similar Questions

  • No idea how to write this query

    Hi, My Data is as below

    DocNum doc_date type of amount
    1154 15 November 11 232501.5 invoice
    200206 4 November 11 - 243672.64 credit memo
    Note flow 111 5 November 555.22 11

    Output must be

    DocNum doc_date amount Type AmountDR AmountCR
    1154 232501.5 15 November 11 Bill 232501.5
    Note credit 200206 4 November 11 - 243672.64 - 243672.64
    Note flow 111 5 November 555.22 11 555.22

    If the amount is > 0, then it must be displayed in the value of the amount to be AmountDR
    If amount < 0 then it must be displayed in the value of the sum amount CR



    Can help how to write this query
    with sample_table as (
                          select 1154 Docnum,date '2011-11-15' doc_date,232501.5 Amount,'Invoice' type from dual union all
                          select 200206,date '2011-11-04',-243672.64,'Credit Memo' from dual union all
                          select 111,date '2011-11-05',555.22,'Debit Memo' from dual
                         )
    select  Docnum,
            doc_date,
            Amount,
            type,
            case
              when Amount >= 0 then Amount
            end AmountDR,
            case
              when Amount < 0 then Amount
            end AmountCR
      from  sample_table
    /
    
        DOCNUM DOC_DATE      AMOUNT TYPE          AMOUNTDR   AMOUNTCR
    ---------- --------- ---------- ----------- ---------- ----------
          1154 15-NOV-11   232501.5 Invoice       232501.5
        200206 04-NOV-11 -243672.64 Credit Memo            -243672.64
           111 05-NOV-11     555.22 Debit Memo      555.22
    
    SQL> 
    

    SY.

  • How to write this query in the hierarchy

    Hi gurus,

    Really need your help on this query.  Thank you very much in advance.

    SELECT
      t1.key as root_key ,
    (SELECT
          t2.unit_id AS unit_id 
          level-1 AS level ,
          t2.name,
          t2.creator
        FROM
          tab t2
          START WITH t2.unit_id       =   t1.unit_id            -----check each node as root
          CONNECT BY prior t2.unit_id = t2.parent_unit_id
    
      )
       t1.name as parent_unit_name
    FROM
      tab t1
    

    I'll write a query of the hierarchy as above, and that EACH line (node, totally more than 10200) is checked as root node to see how many sheets are accessible for her... It must be implemented in a single query.

    I know inline query should NOT return multiple rows or multiple columns, but the inline elements are necessary and can certainly be made in a correct solution.

    (env):

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

    PL/SQL Release 12.1.0.2.0

    )

    Test data:

    select 1 as unit_id, null as parent_organization_unit_id, 'U1' as name from dual
    union all
    select 2, 1, 'U2' FROM DUAL
    UNION ALL
    SELECT 3, NULL, 'U3' FROM DUAL
    UNION ALL
    SELECT 4, 3, 'U4' FROM DUAL
    UNION ALL
    SELECT 5, 2, 'U5' FROM DUAL
    UNION ALL
    SELECT 6, 5, 'U6' FROM DUAL
    UNION ALL
    SELECT 7, 6, 'U7' FROM DUAL
    UNION ALL
    SELECT 8, 5, 'U8' FROM DUAL
    UNION ALL
    SELECT 9, 5, 'U9' FROM DUAL;
    

    Final result should be like this

    key unit_id,    level,   name, parent_name
    1    1    0    u1      u1
    1    2    1    u2       u1
    1    5    2     u5      u1
    1    6    3     u6      u1
    1    7    4    u7       u1
    1    8    3    u8       u1
    1    9    3     u9      u1
    2    2    0     u2       u2
    2    5    1      u5       u2
    2    6    2     u6       u2
    2    7    3      u7      u2
    2    8    2      u8       u2
    2    9    2      u9       u2
    
    

    Don't know how get you your output, it does not match your data...

    with tab as)

    Select 1 as unit_id, null as parent_organization_unit_id 'U1' as the name of double

    Union of all the

    Select 2, 1, 'U2' FROM DUAL

    UNION ALL

    SELECT 3, NULL, 'U3' FROM DUAL

    UNION ALL

    SELECT 4, 3, 'U4' FROM DUAL

    UNION ALL

    SELECT 5, 2, 'U5' OF THE DOUBLE

    UNION ALL

    SELECT 6, 5, 'U6' OF THE DOUBLE

    UNION ALL

    SELECT 7, 6, "U7" OF THE DOUBLE

    UNION ALL

    SELECT 8, 5, 'U8' FROM DUAL

    UNION ALL

    9. SELECT, 5, 'U9' FROM DUAL

    )

    Select dense_rank() key (order by connect_by_root unit_id), unit_id, level - 1 as 'LEVEL', connect_by_root name root_parent_name

    t tab

    Start with parent_organization_unit_id is null

    Connect prior unit_id = parent_organization_unit_id

    KEY UNIT_ID LEVEL ROOT_PARENT_NAME
    1 1 0 "U1".
    1 2 1 "U1".
    1 5 2 "U1".
    1 6 3 "U1".
    1 7 4 "U1".
    1 8 3 "U1".
    1 9 3 "U1".
    2 3 0 "U3".
    2 4 1 "U3".
  • How to write this query?

    Hi people,

    I need to get a query in which a set of records, I get ONLY those which previous registry has a field with a value to this topic. Other values, the field can contain are not necessary.

    I know that sounds easy but... I can't get it.

    So, for Oracle 10 g 2... Here's my query:

    SELECT a.person_id, a.person_status, a.message_id, a.order_id

    OF t_HR one

    WHERE a.person_status = "rejected".

    AND a.id >

    (SELECT max (b.id)

    OF t_HR b

    WHERE b.person_id = a.person_id

    and b.order_id = a.order_id

    AND b.person_status! "revised =".

    B.ID AND < a.id)

    ORDER BY desc a.id

    Let me explain:

    1 - HR table is a table of people. These people has serveral STATUS.

    2 - ID is a sequential (each www.voyages-sncf.com has a different identification number).

    3 - the application must get THAT all people "rejected".

    4. - However, (subquery) I need ONLY those that previous register (the second register) holds a status of "OK". If the person holds a "revised" status he's not, he should be the next register (the third)

    5.-L' ORDER ID DESC, so is the first register must have a STATUS = "rejected" and the second a 'OK '.  IF the second register = "revised", then the third register must be 'OK '. And I need this query.

    HOW DO?

    My problem: the subquery gives you previous register of the same guy, but... it does not give you the value of the State, I need, which is 'OK '.

    I tried to add to the subquery...

    SELECT max (b.id)

    OF mod_human_resource b

    WHERE b.person_id = a.person_id

    and b.order_id = a.order_id

    AND b.person_status = 'OK '.

    AND b.id < a.id

    ... but if I have 5 records of that person, the first is "rejected", the second is "accepted", the third is 'new' and the fourth is 'OK'... the subquery gives you the 4th register and which is not correct for me, it must be only the second one (prior to the first State registry).

    I need to be a query, because I need to use it on a MERGER for a DWH.

    If there is another way (function, or even a procedure) to make the MERGER rather than with a request, which would be ok too. I am poor DWH knowledge.

    Thanks in advance.

    Hello

    So, you need to know if a line is the 'first' line, and you should also know what is the 'next' status, (even the 'first' and 'next' are already defined).  This sounds like a job for analytical functions.  ROW_NUMBER can tell you if a line is first or not, and LEAD can tell you what a value on the next row.

    Since you post CREATE TABLE and INSERT statements for your own table, I'll use the table scott.emp to illustrate.

    Consider these data from scott.emp:

    SELECT DeptNo

    ename

    work

    FROM scott.emp

    ORDER BY deptno

    ename DESC

    ;

    Output:

    DEPTNO ENAME JOB

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

    10 MILLER CLERK

    PRESIDENT OF KING 10

    MANAGER 10 CLARK

    20 SMITH CLERK

    ANALYST SCOTT 20

    20 JONES MANAGER

    20 FORD ANALYST

    20 ADAMS CLERK

    30 WARD SALESMAN

    SELLER OF 30 TURNER

    30 MARTIN SALESMAN

    30 JAMES CLERK

    MANAGER BLAKE 30

    30 ALLEN SALESMAN

    Now, let's say we want only who know the departments where the forefront (in order descending ename) a job = 'CLERK', and the following line (also in descending by ename order) = "ANALYST" job, and we want to know the ename of the first row.  In other words, the correct output is:

    DEPTNO ENAME

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

    20 SMITH

    Note that deptno = 10 is not included, even if the first task is to "CLERK." that was because the second job in deptno = 10 is the "PRESIDENT", not "ANALYST."

    Here's a way to get these results:

    WITH got_analytics AS

    (

    SELECT ename, deptno, job

    ROW_NUMBER () OVER (PARTITION BY deptno

    ORDER BY ename DESC

    ) AS r_num

    LEAD (employment) OVER (PARTITION BY deptno

    ORDER BY ename DESC

    ) AS next_job

    FROM scott.emp

    )

    SELECT deptno, ename

    OF got_analytics

    WHERE r_num = 1

    AND job = 'CLERK '.

    AND next_job = 'ANALYST '.

    ;

    I hope that answers your question.

    If this isn't the case, then, as Dan (and the FAQ forum) said, post CREATE TABLE and INSERT statements for some sample data and the exact results you want from these data.

    Post your query, based on the one I have posted more top and ponit out where he gets results.

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

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    I have a table whose columns with values such as

    MINNEAŸPOLIS and ¿VV ¿A

    Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.

    Please help to write a SQL SELECT with Regexp_like query or any other option.

    Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.

    SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;

  • How to write the query option in expdp

    Hi Please someone help me how to write the query option in expdp... .in expdp using the query option...

    where AM columnname between 5 May 12 02:57:00.000' and ' 02:59:59.999 6 May 12: ';


    Please do what is necessary...

    Pavan Kumar says:
    QUERY = (columnname scott.test: "where between 5 May 12 02:57:00.000 h ' and ' 6 May 12 AM 02:59:59.999'")

    Who will fail in databases, because you assume nls_date_format. How it is difficult to put to_date() surround channels? Rather than play with quotation marks, using one parfile thusly.

    query=table_owner.table_1:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_2:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    query=table_owner.table_3:"where business_date between to_date('20120505025700 am','yyyymmddhhmiss am') and to_date('20120505025959 am','yyyymmddhhmiss am')"
    

    You do not have to have all the clauses in a single line, as they are side by side parfile, which would be enough. For this reason parfile is better than the command line in order to avoid all the back-citing dance.

  • How to write a query for the data exchange between two columns?

    How to write a query for the data exchange between two columns?

    I tried a request, does NOT work.
    update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
    Thank you.

    Published by: user533361 on October 23, 2009 14:04

    Just plain and simple:

    update tmp t1
     set t1.m1=t1.m2,
         t1.m2=t1.m1
    /
    

    SY.

  • How ot do this query

    some of you that it won't be easy, but for a rookie plsql is not form. Can U help?

    want to find out who has max (salary) and record that information in a variable

    Table: used
    id  salary
    1    2000
    2    2500
    3    1800
    Select max (salary) in employee == > back 2500
    But how to write this in a plsql and find the id is 3 and save it in a variable


    my incomplete statement:

    Select max (salary), in myvar to employee where id =?

    can you help me?

    Oh and save it in a variable plsql:

    declare my_var emp.empno%TYPE;
    begin
      select e1.empno into my_var
      from emp e1
      where e1.sal = (select max(e2.sal) from emp e2)
        and rownum = 1;
    end;
    /
    
  • How to write a query to join and right join

    Hello

    With the help of 10 gr 2:

    I have a scenario where generate us a report by joining a few tables.

    same goes for ex:

    Select col1, col2, col5, col10 col22...

    from tableA, tableB.

    where tableA.col1 = tableB.col1 etc.

    I have a requirement where choose a flag in the front-end server must be a right join.  so, if the flag is N, I need to return the data returned by the join; but, if the flag is there I need to make a right join and returns all the data corresponding to table A and table B, as well as the data in table B.

    (I did mention only two tables, as they are, they main engines, there are very many other tables joined in this request)

    It is possible to write a query, so that the two scenarios can be addressed based on the flag?

    Thanks in advance

    Hello

    user565033 wrote:

    ... When Oracle treats of the WHERE clause that starts from the bottom or the top?  So it's best to put filters that reject the unnecessary lines at the beginning of the place where clause or end?  Is how important it? ...

    No, it does not matter.

    The optimizer evaluates what condition will be faster and/or more selective (that is, will eliminate the most lines) and make the first condition.

    If the optimzer cannot decide on what terms will be faster or more selective, it can arbitrarily don't close at the end of the WHERE clause first, but, even if you already knew for sure, this is exactly the kind of thing that is likely to change from one version to the other, or platform to another.

    The optimizer (in recent versions, at least) is very good.  If the optimizer can not say what conditions should apply first, then, chances are, there is really no significant difference, so it would be not serious of which one was made first.

    If you read something that indicates the order is important, it is very outdated.  Long ago (version 6), there was no cost-based optimizer and the order of the conditions in the WHERE clause was important.  The cost-based optimizer was introduced in Oracle 7 (1992) and has been greatly improved by Oracle 8.1 (1998).  Also later Oracle 10, the older optimizer ("regulated") was available for those who really want to continue to use it.

  • How to write the query

    Hello

    How to write the sql query

    I have three type of table as

    1 table emp

    EMP_ID FIRST_NAME DEPT_ID

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

    1 kumar 10

    2 sam                          20

    3 30 damu

    2 table dept

    EMP_ID SALE_ID DEPT_ID

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

    1 101 10

    2 102 20

    3 103 30

    3. table sale

    EMP_ID SALE_ID SALE_AMT

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

    1 101 7

    2 102 8

    3 103 9

    I want the result as

    EMP_ID DEPT_ID SALE_AMT

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

    1                10                  7

    Thank you

    Are you looking for this?

    SELECT T1. EMP_ID,

    T1. DEPT_ID,

    W3M SALE_AMT

    FROM EMP T1,

    SALE T3

    WHERE T1. EMP_ID = T3. EMP_ID;

    OUTPUT:

    EMP_ID DEPT_ID SALE_AMT

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

    1         10          7

    2         20          8

    3         30          9

    If this is not the case, after the actual output, you need. Because that gives you the amount of sales deptwise

  • How to write conditional query?

    I have a use case-

    on the basis of the value of the entry, I need to run the query.

    for example

    Select * from employees where em em. empId =? and em.firstname =? and em.jobid =?
    Select * from employees where em em. empId =? and em.firstname =?

    I need to write a query that is used internally this time condition and return records

    Select * from employees where em
    If (EM.) JobID is nothing)
    {
    Select * from employees where em em. empId =? and em.firstname =?
    }
    on the other
    {
    Select * from employees where em em. empId =? and em.firstname =? and em.jobid =?
    }


    How could I write this problem in sql?

    Hello

    You can try the following:
    Select * from employees where em em. empId =? and em.firstname =? and (em.jobid =? or em.jobid is null).

    Kind regards
    Rommel Pino
    http://soadev.blogspot.com

  • best way to write this query

    Hello

    I have a problem and I realized a simplified version of it:

     
    
    create table deals (id_prsn number, id_deal number, fragment number); 
    create table deal_values (id_prsn number, id_deal number, value_ number, date_ date); 
    
    insert into deals values(1,1,50); 
    insert into deals values(2,2,40); 
    insert into deals values(1,3,50); 
    insert into deals values(2,4,80); 
    insert into deals values(1,5,20); 
    insert into deals values(2,6,80); 
    
    insert into deal_values values(1,1,10 ,sysdate - 3); 
    insert into deal_values values(2,2,208, sysdate - 3); 
    insert into deal_values values(2,4,984, sysdate - 3); 
    insert into deal_values values(1,null,134,sysdate - 3); 
    insert into deal_values values(1,1,13, sysdate - 2); 
    insert into deal_values values(2,2,118, sysdate - 2); 
    insert into deal_values values(2,4,776, sysdate - 1); 
    insert into deal_values values(1,null,205,sysdate - 1); 
    insert into deal_values values(2,null,-5,sysdate - 1); 
    The id of the requirement to join these two tables based on:

    1.) ID_PRSN and ID_DEAL
    2.) max DATE_ grouped per person and deal
    (3.) in the case that ID_DEAL is defined in the AGREEMENTS, but not defined in the DEAL_VALUES table, I have to join this records to DEAL_VALUES based on the person where id_Deal is null.

    Number 3 gives me headache. I realized the following query:
     
    
    select *from ( 
    select a.id_prsn, 
           a.id_deal, 
           a.fragment, 
           b.value_, 
           b.date_, 
           max(b.date_) over (partition by b.id_prsn, b.id_deal) max_date 
      from deals a 
    inner join deal_values b 
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    ) 
    where date_ = max_Date; 
    It returns the correct result of he,


    ID_PRSN ID_DEAL FRAGMENT VALUE_ DATE_ MAX_DATE
    1 1 50 13 16.10.2012 09:59:48 16.10.2012 09:59:48
    1 3 50 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    1 5 20 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    2 2 40 118 16.10.2012 09:59:48 16.10.2012 09:59:48
    2 4 80 776 17.10.2012 09:59:48 17.10.2012 09:59:48
    2 6 80-5 17.10.2012 09:59:48 17.10.2012 09:59:48 OK



    but the join clause:
     
    
    
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    in fact the query much slower.

    I was wondering is there a different way to write this join and manage the logic.

    Thanks in advance

    Here's a different approach:

    select * from (
      select a.id_prsn, a.id_deal, a.fragment, B.value_, b.date_,
      ROW_NUMBER() over(
        partition by a.ID_PRSN, a.ID_DEAL
        order by B.ID_DEAL nulls last, B.DATE_ desc
      ) RN
      from DEALS a
      join DEAL_VALUES B
      on a.ID_PRSN = B.ID_PRSN and a.ID_DEAL = NVL(B.ID_DEAL, a.ID_DEAL)
    )
    where rn = 1
    order by 1, 2;
    

    "nulls last" is the default sort order; I just put that for clarity.

    Published by: stew Ashton on October 18, 2012 12:58

  • How to write a query for the given scenario?

    Hi all

    I have two tables EMP, DEPT with data below.
    EMP TABLE: -.
    SAL DEPID EMPLOYMENT ENAME EID
    111 RAM 1500 10 MANAGER
    222 SAM ASST MANAGER 2000 20
    KALA 333 2500 10 REGISTRAR
    444. BIMA 20 3000 MANAGER
    CHALA 555 MANAGER 3500 30
    RANI 666 ASST MANAGER 4000 10
    777 KAMAL MANAGER 2400 10

    DEPT TABLE: -.

    DEPID DNAME
    XX 10
    AA 20
    30 ZZ

    Q1: I want the sum of the salary of each Department and for the particular job. Here, in each Department manager, Assistant Manager, clerk positions are there.
    I want to display the result as below...
    10-20-30 JOBS
    --------------------------------------------------------------------------
    MANAGER OF 3900 3000 3500
    ASST MANAGER 4000 2000 NULL
    THE CLERK 2500 NULL NULL

    Please tell me how to write a sql query?

    Thank you
    SAI
    SQL> SELECT job,
      2         MAX(DECODE(deptno, 10, sum_sal)) "10",
      3         MAX(DECODE(deptno, 20, sum_sal)) "20",
      4         MAX(DECODE(deptno, 30, sum_sal)) "30"
      5  FROM (SELECT deptno, job, SUM(sal) sum_sal FROM emp GROUP BY deptno, job)
      6   GROUP BY job;
    
    JOB               10         20         30
    --------- ---------- ---------- ----------
    CLERK           1300       1900        950
    SALESMAN                              5600
    PRESIDENT       5000
    MANAGER         2450       2975       2850
    ANALYST                    6000
    
    SQL> 
    
  • How to optimize this query?

    Hello

    I have a query like this:

    Merge into the table st1

    using (select * from (select pk, value, diff_value, m_date, row_number () over (PARTITION pk ORDER BY diff_value) rnk)

    from (select distinct / * + Full (t1) full (t2) * / t1.pk, t2.m_date)

    , Case when (t1.m_date = t2.m_date) then "CORRESPONDENCE".

    When (t2.m_date BETWEEN t1.m_date-1 and t1.m_date + 1) then ' MATCHED WITH +/-1gg.

    When (t2.m_date BETWEEN t1.m_date-2 and t1.m_date + 2) then "MATCHED WITH +/-2 days.

    else "

    end value_match

    Case when (t1.m_date = t2.m_date) then 0

    Where (t2.m_date BETWEEN t1.m_date + 1 and t1.m_date - 1) then 1

    Where (t2.m_date BETWEEN t1.m_date + 1 and t1.m_date - 1) then 2

    else "

    end diff_value

    of table t2, t1 table

    where t1.value is null

    and t1.id = t2.id)

    where value_match is not null)

    where rnk = 1) s

    on (st1.pk = s.pk)

    WHEN MATCHED THEN

    Update set st1.value = s.value_match, st1.diff_value = s.diff_value, st1.up_date = s.m_date

    where st1.value is null.

    Explain the plan:

    EXPLAIN_PLAN1.jpg

    Table1 a record 3Million and table 2 has 1 million records.

    I used gather stats before you run this query and 'Full' trick, even in this case, he is running for 45 minutes.

    Please suggest the best solution to optimize this query.

    Thanks in advance.

    Remove the tips.

    No need for the separate.

    Get the diff by ceil (abs(t2.m_date-t1.m_date)) and the filter for that where value_diff<>

    Assing the statement ".. MATCHED" lately in the update clause.

    Maybe give exactly to your needs with a small example may be the query may be getting more simplified or not what you want it to do.

  • How to get this working procedure to analyze the value of the list?

    I have the following data in the table t1

    ID DRUG_ID


    DB00523 564; DB00926; DB03873

    DB00893 566; DB01294; DB05260

    the desired output is as the following table t2

    ID DRUGID
    DB00926 564
    DB03873 564
    566 DB01294
    566 DB05260

    I am trying to write a stored procedure to achieve the goal, since the actual list is very long. but it returns the error on the select part of the lower.

    Any suggestion will be appreciated.

    CREATE OR REPLACE PROCEDURE checklist IS

    number of Oneid;
    TYPE BBType IS REF CURSOR;
    BBType BB;
    onerecord Q1% ROWTYPE;


    BEGIN

    For oneid in (select id from t1) LOOP

    FOR I IN 1.2 LOOP
    Open BB for ' select id, substr (drug_id, instr(drug_id,';',1,i) + 1, instr(drug_id,';',1,i+1)-instr(drug_id,';',1,i)-1) from t1
    loop
    Retrieves BB in onerecord;
    INSERT INTO t2 (ID, drugID) VALUES (onerecord.id, onerecord.drugid);
    end loop;
    close the BB;

    ENDLOOP;

    ENDLOOP;

    END;

    Frank,

    Thank you very much for your help. It works very well!

    Jane.

Maybe you are looking for