Generic function to display a specific row from any table

Hi all,
I need some help to write a function in PL/SQL or Dynamic SQL (or both), to write a function that would take in parameters only the unique ID of the row to display and the name of the table to display (that could be any table with any format).
Actually we don't know in advance which table will be accessed, so we don't know the columns and their types until the function is called.
Once I get the row, I want to return a small table with a size of only one line containing the details of the row I looked for.
So the signature of the function would be something like: CREATE function displayDetailedRowFromAnyTable(uniqId in varchar2(25), tableName in varchar2(25)).
Hope the description is clear. I found in some forums some details about this kind of problems; however, the structure of the tables (ie. the columns name and their types) is always known in advance. In my case, I don't know those details until run time.
Any help would be greatly appreciated.

There is a built in "function" to do this. It's called "SELECT" and it's available through the SQL engine. You give it the table name and the ID you want and it can return you all the columns from that table...
e.g.
SELECT *
FROM <table_name>
WHERE id = <required_id>If you truly want a generic dynamic SQL then you'll have to code it as an ANYTYPE (as already mentioned above). Although this will make your code very complex and difficult to maintain.
e.g. of defining your own dynamic pipelined function using anytype ...
create or replace type NColPipe as object
  l_parm varchar2(10),   -- The parameter given to the table function
  rows_requested number, -- The parameter given to the table function
  ret_type anytype,      -- The return type of the table function
  rows_returned number,  -- The number of rows currently returned by the table function
  static function ODCITableDescribe( rtype out anytype, p_parm in varchar2, p_rows_req in number := 1 )
  return number,
  static function ODCITablePrepare( sctx out NColPipe, ti in sys.ODCITabFuncInfo, p_parm in varchar2, p_rows_req in number := 1 )
  return number,
  static function ODCITableStart( sctx in out NColPipe, p_parm in varchar2, p_rows_req in number := 1 )
  return number,
  member function ODCITableFetch( self in out NColPipe, nrows in number, outset out anydataset )
  return number,
  member function ODCITableClose( self in NColPipe )
  return number,
  static function show( p_parm in varchar2, p_rows_req in number := 1 )
  return anydataset pipelined using NColPipe
create or replace type body NColPipe as
  static function ODCITableDescribe( rtype out anytype, p_parm in varchar2, p_rows_req in number := 1 )
  return number
  is
    atyp anytype;
  begin
    anytype.begincreate( dbms_types.typecode_object, atyp );
    atyp.addattr( to_char(to_date(p_parm,'MONYYYY'),'MONYY')
                , dbms_types.typecode_varchar2
                , null
                , null
                , 10
                , null
                , null
    atyp.endcreate;
    anytype.begincreate( dbms_types.typecode_table, rtype );
    rtype.SetInfo( null, null, null, null, null, atyp, dbms_types.typecode_object, 0 );
    rtype.endcreate();
    return odciconst.success;
  exception
    when others then
      return odciconst.error;
  end;  
  static function ODCITablePrepare( sctx out NColPipe, ti in sys.ODCITabFuncInfo, p_parm in varchar2, p_rows_req in number := 1 )
  return number
  is
    elem_typ sys.anytype;
    prec pls_integer;
    scale pls_integer;
    len pls_integer;
    csid pls_integer;
    csfrm pls_integer;
    tc pls_integer;
    aname varchar2(30);
  begin
    tc := ti.RetType.GetAttrElemInfo( 1, prec, scale, len, csid, csfrm, elem_typ, aname );
    sctx := NColPipe( p_parm, p_rows_req, elem_typ, 0 );
    return odciconst.success;
  end;
  static function ODCITableStart( sctx in out NColPipe, p_parm in varchar2, p_rows_req in number := 1 )
  return number
  is
  begin
    return odciconst.success;
  end;
  member function ODCITableFetch( self in out NColPipe, nrows in number, outset out anydataset )
  return number
  is
  begin
    anydataset.begincreate( dbms_types.typecode_object, self.ret_type, outset );
    for i in self.rows_returned + 1 .. self.rows_requested
    loop
      outset.addinstance;
      outset.piecewise();
      outset.setvarchar2( self.l_parm );
      self.rows_returned := self.rows_returned + 1;
    end loop;
    outset.endcreate;
    return odciconst.success;
  end;
  member function ODCITableClose( self in NColPipe )
  return number
  is
  begin
    return odciconst.success;
  end;
end;
And to use it
SQL> select * from table( NColPipe.show( 'JAN2008' ) );
JAN08
JAN2008

Similar Messages

  • Retrieving Odd numbered rows from a table.

    In one recent interview I have been asked to write a SQL query to retreive Odd numbered rows from any table. At first I am confused on how to say whther a perticular row is odd or even. If it is based on rownum then rownum is not dynamic and every time the rownum changes for a perticular row. I finally used rowid for this puprpose, as you all of you know rowid is alphanumeric its not worked.
    Can you please posta query to retrive odd numbered rows if its possible.

    Mallik wrote:
    In one recent interview I have been asked to write a SQL query to retreive Odd numbered rows from any table. At first I am confused on how to say whther a perticular row is odd or even. If it is based on rownum then rownum is not dynamic and every time the rownum changes for a perticular row. I finally used rowid for this puprpose, as you all of you know rowid is alphanumeric its not worked.
    Can you please posta query to retrive odd numbered rows if its possible.As you say, if there's nothing in the data itself to offer a distinction as to what is "odd" and "even" then the closest thing is the rownum.
    SQL> select * from (select rownum rn, emp.* from emp) where mod(rn,2) = 1;
            RN      EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
             1       7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
             3       7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
             5       7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
             7       7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
             9       7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
            11       7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
            13       7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
    7 rows selected.Anything else is making an assumption as to what is "odd" and "even". If it were me, the answer would be to do the above and also explain that, without any definition of what constitutes "odd" and "even" this is the closest possible, but not an accurate science as there is no guarantee as to the order of the records.

  • Display distinct rows from Oracle table without using "DISTINCT" keyword.

    How to retrieve distinct rows from oracle table without using 'DISTINCT' keyword in SQL?
    Thanks in advance.
    Mihir

    Welcome to the forum.
    Besides GROUP BY you can use UNIQUE instead of DISTINCT as well, but that's probably not wanted here ;) , and the ROW_NUMBER() analytic:
    SQL> create table t as
      2  select 1 col1 from dual union all
      3  select 1 from dual union all
      4  select 2 from dual union all
      5  select 3 from dual union all
      6  select 4 from dual union all
      7  select 4 from dual;
    Table created
    SQL> select col1 from t;
          COL1
             1
             1
             2
             3
             4
             4
    6 rows selected
    SQL> select distinct col1 from t;
          COL1
             1
             2
             3
             4
    SQL> select unique col1 from t;
          COL1
             1
             2
             3
             4
    SQL> select col1 from t group by col1;
          COL1
             1
             2
             3
             4
    SQL> select col1
      2  from ( select col1
      3         ,      row_number() over (partition by col1 order by col1) rn
      4         from   t
      5       )
      6  where rn=1;
          COL1
             1
             2
             3
             4

  • Deleting Multiple Rows From Multiple Tables As an APEX Process

    Hi There,
    I'm interesting in hearing best practice approaches for deleting multiple rows from multiple tables from a single button click in an APEX application. I'm using 3.0.1.008
    On my APEX page I have a Select list displaying all the Payments made and a user can view individual payments by selecting a Payment from the Select List (individual items are displayed below using Text Field (Disabled, saves state) items with a source of Database Column).
    A Payment is to be deleted by selecting a custom image (Delete Payments Button) displayed in a Vertical Images List on the same page. The Target is set as the same page and I gave the Request a name of DELETEPAY.
    What I tried to implement was creating a Conditional Process On Submit - After Computations and Validations that has a source of a PL/SQL anonymous block as follows:
    BEGIN
    UPDATE tblDebitNotes d
    SET d.Paid = 0
    WHERE 1=1
    AND d.DebitNoteID = :P7_DEBITNOTEID;
    INSERT INTO tblDeletedPayments
    ( PaymentID,
    DebitNoteID,
    Amount,
    Date_A,
    SupplierRef,
    Description
    VALUES
    ( :P7_PAYMENTID,
    :P7_DEBITNOTEID,
    :P7_PAID,
    SYSDATE,
    :P7_SUPPLIERREF,
    :P7_DESCRIPTION
    DELETE FROM tblPayments
    WHERE 1=1
    AND PaymentID = :P7_PAYMENTID;
    END;
    The Condition Type used was Request = Expression 1 where Expression 1 had a value of DELETEPAY
    However this process is not doing anything!! Any insights greatly appreciated.
    Many thanks,
    Gary.

    ...the "button" is using a page level Target,...
    I'm not sure what that means. If the target is specified in the definition of a list item, then clicking on the image will simply redirect to that URL. You must cause the page to be submitted instead, perhaps by making the URL a reference to the javaScript doSubmit function that is part of the standard library shipped with Application Express. Take a look at a Standard Tab on a sample application and see how it submits the page using doSubmit() and emulate that.
    Scott

  • Deleting Rows From A Table After Running a Report

    I've created a report that inserts rows into a table on the asp page then calls a BI Publisher report to display the data. After running the report in BI Publisher I need to delete the rows from the table that had just been inserted. How is the best way to go about this in BI Publisher?

    The best way I know of would be to use an "afterReport trigger".
    An afterReport trigger fires after the XML output has been generated.
    Thanks,
    Bipuser

  • Deleting a row from a table containing CLOB as one of the columns

    When i delete a row from a table which contains a CLOB (internal clob) i.e. CLOB or BLOB column, Will the CLOB data will also be deleted ? I understand that what exactly stored in the CLOB column is the clob locator which points to the actual data.
    So, when I delete this row, the clob locator will be deleted, but will the actual data what this locator is pointing to is also deleted ??? if not what is the process to delete the data the locator is pointing to when the row containing the locator is deleted ? If this is not happening then the actual data might become an orphan data which nobody has access to, will automatic garbage cleaning occurs on a frequent intravels to delete unaddressed data residing on the database server ?
    Thanks in advance for the help, can email me at [email protected] alternatively.
    Regards,
    Srinivasa C.

    Michael,
    Thanks very much for your inputs, here are the results i got when i tried the way you explained in your answer, the TRUNCATE command made the actual size back to normal, but the delete is not the same, so, how can i delete the data that a particular clob locator may point to ?
    truncate would delete all the rows of the table, which might not serve my purpose, i would like to delete a row and also it's associated clob data from the database! is there anyway to do this ?
    is there any limitation on the ool_sample size? i am basically a c++ programmer, i am looking for some function like FREE which would free the allocated memory to the clob once the locator is deleted.
    your help is greatly appreciated - Thanks!
    :-) Srini.
    ==========================
    My Results:
    ==========================
    SQL> create table sample (
    2 id integer primary key,
    3 the_data CLOB default empty_clob() )
    4 lob (the_data) store as ool_sample;
    Table created.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    20K
    SAMPLE
    10K
    SQL> select count(*) from sample;
    COUNT(*)
    0
    SQL> begin
    2 for i in 1..1000
    3 loop
    4 insert into sample values (i, RPAD('some data', 4000) );
    5 end loop;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> delete sample;
    1000 rows deleted.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> commit;
    Commit complete.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    6420K
    SAMPLE
    70K
    SQL> begin
    2 for i in 1..1000
    3 loop
    4 insert into sample values (i, rpad('some data', 4000));
    5 end loop;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    9616K
    SAMPLE
    70K
    SQL> truncate table sample;
    Table truncated.
    SQL> select segment_name, round(sum(bytes)/1024, 2) || 'K' as sotrage_consumed
    2 from user_segments
    3 where segment_name in ('SAMPLE', 'OOL_SAMPLE')
    4 group by segment_name;
    SEGMENT_NAME
    SOTRAGE_CONSUMED
    OOL_SAMPLE
    20K
    SAMPLE
    10K

  • Issue while deleting a row from a table

    Dear friends,
    i am getting an issue while deleting a row from a table, pls check screen shots , the first screen shot is my table contents
    when i delete 2 row , the second row is deleting properly like below screen shot
    but i want like below screen shot , Col1 contents should be like pic 1 . could any one pls let me know how to solve this issue.
    Thanks
    Vijaya

    Hi vijaya,
    please try this code, it will help you.
    DATA : it_rows  TYPE wdr_context_element_set,
              wa_rows LIKE LINE OF it_rows.
       DATA lo_nd_table TYPE REF TO if_wd_context_node.
        DATA lt_table TYPE wd_this->elements_table.
       DATA lo_el_table TYPE REF TO if_wd_context_element.
       DATA ls_vbap TYPE wd_this->element_table.
    DATA: ld_index TYPE i.
    data value TYPE sy-index.
    * navigate from <CONTEXT> to <table> via lead selection
       lo_nd_table= wd_context->get_child_node( name = wd_this->wdctx_table ).
    * @TODO handle non existant child
    * IF lo_nd_table IS INITIAL.
    * ENDIF.
    * get element via lead selection
    * alternative access  via index
    * lo_el_table = lo_nd_table->get_element( index = 1 ).
    * @TODO handle not set lead selection
       IF lo_el_table IS INITIAL.
       ENDIF.
    * navigate from <CONTEXT> to <table> via lead selection
       lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
    * @TODO handle non existant child
    * IF lo_nd_table IS INITIAL.
    * ENDIF.
       lo_nd_table->get_static_attributes_table( IMPORTING table = lt_table ).
    * @TODO handle non existant child
    * IF lo_nd_table IS INITIAL.
    * ENDIF.
    ** @TODO compute values
    ** e.g. call a model function
    * navigate from <CONTEXT> to <table> via lead selection
       lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
    * @TODO handle non existant child
    * IF lo_nd_table IS INITIAL.
    * ENDIF.
    ** @TODO compute values
    ** e.g. call a model function
    it_rows  =  lo_nd_table>get_selected_elements( ).
       CALL METHOD lo_nd_table->GET_LEAD_SELECTION_INDEX
       RECEIVING
         INDEX  = value .
      LOOP AT it_rows INTO wa_rows.
         CALL METHOD wa_rows->get_static_attributes
           IMPORTING
                  static_attributes = ls_table.
         READ TABLE lt_table INTO ls_table WITH KEY col1 = ls_table-col1.
          ld_index = value.
              ENDLOOP.
       CLEAR : ls_table-col2,
             ls_table-col2.
       MODIFY lt_table INDEX ld_index FROM ls_table.
      lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).

  • How NOT to restrict no of rows from two tables

    I have two identical tables Invoice and Payment. The only difference is Invoice_id,Invoice_Amt and Payment_id,Payment_Amt columns that shows different ids and amounts. The bank_ids, names, account_types are same. Invoice table has 3 rows and Payment has 2. Simply meaning that there were 3 invoices generated but the bank received 2 payments. I want to show Invoice_Amt and Payment_Amt using sql query. But its giving me total 6 rows. Whereas, I want 3 from Invoice and 2 rows from Payment table to show side-by-side.
    CREATE TABLE invoice
    ( invoice_id NUMBER
    bank_id NUMBER,
    bank_name VARCHAR2(256),
    invoice_amount NUMBER);
    ----Invoice table has 3 rows showing 3 Invoice Amts
    CREATE TABLE payment
    ( payment_id NUMBER
    bank_id NUMBER,
    bank_name VARCHAR2(256),
    payment_amount NUMBER);
    ----Payment table has 2 rows showing 2 Payments
    After executing this sql statement below, I get 6 rows:
    select inv.invoice_amount,pymt.payment_amount from invoice inv,payment pymt where inv.bank_id=pymt.bank_id;
    How can I show 3 rows for Invoice and 2 for Payment..?
    Thank you.

    Hi,
    So you want
    the 1st invoice to appear side-by-side with the 1st payment,
    the 2nd invoice to appear side-by-side with the 2nd payment,
    the nth invoice to appear side-by-side with the nth payment.
    But, if there are an uneqaul numner of payments and invoices, all the payments and all the invoices must still be shown, alone on a row if necessary.
    That sounds like a job for FULL OUTER JOIN.
    Use the analytic ROW_NUMBER fucntion to determine which is the 1st, 2nd, ..., nth row in each table, for each bank.
    WITH     invoice_plus_r_num     AS
         SELECT     bank_id, bank_name
         ,      invoice_amount
         ,     ROW_NUMBER () OVER ( PARTITION BY  bank_id, bank_name
                                   ORDER BY          invoice_id
                           )         AS r_num
         FROM    invoice
    ,     payment_plus_r_num     AS
         SELECT     bank_id, bank_name
         ,      payment_amount
         ,     ROW_NUMBER () OVER ( PARTITION BY  bank_id, bank_name
                                   ORDER BY          payment_id
                           )         AS r_num
         FROM    payment
    SELECT       NVL (i.bank_id,   p.bank_id)          AS bank_id
    ,       NVL (i.bank_name, p.bank_name)     AS bank_name
    ,       i.invoice_amount
    ,       p.payment_amount
    FROM          invoice_plus_r_num     i
    FULL OUTER JOIN     payment_plus_r_num     p  ON   i.bank_id     = p.bank_id
                                        AND     i.bank_name     = p.bank_name
                                AND     i.r_num          = p.r_num
    ORDER BY  bank_id     -- you can use column aliases here
    ,       bank_name
    ,       NVL (i.r_num, p.r_num)
    ;You mentioned something about accounts, but didn't include that in the CREATE TABLE statements. You'll probably want to add that wherever I used bank_id and bank_name, above.
    Are invoce and payment actually views, rather than tables? If not, you should have a separate bank table, and only include the bank_id in the other tables.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on Feb 3, 2011 12:32 PM

  • Easy Question:Select many rows from a table and execute BAPI for these rows

    Hi Experts,
    I have created one WD project. The WD project fetches some records of backend using BAPI and displays in a table. I have to select some rows from the table and then execute BAPI for selected rows.
    How I can select multiple records from the table and then execute another BAPI for selected rows.
    Regards,
    Gary

    Hi,
    In the Node which you binded to the table create one more attribute of type boolean.
    For example your node is as below:
    //Table Node
    TableNode
    > Att1
    > Att2
    > isSelected(boolean) - Newly created attribute for this requirement.
    //Result Node contains the elements selected in TableNode
    ResultNode
    >Att1
    >Att2
    Now in the table create one more Column with Checkbox as tablecell editor. Now bind this boolean attribute to that check box.
    Now in the code you can get the selected rows by user as below:
    for(int i=0;i<TableNode().size();i++)
      if(wdContext.nodeTableNode().getTableNodeElementAt(i).getIsSelected()==true)
        IPrivateTestView.IResultNode element=wdContext.createResultNodeElement();
        element.setAtt1(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt1());
        element.setAtt2(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt2());
       wdContext.nodeResultNode().addElement(element);
    Regards,
    Charan

  • How to identify one specific row in the table STPO?

    Hi!
    How can I identify one specific row in the table STOP? As an input for my ABAP function I have MatNr, Plant, Alternative, BomUsage and Bom Position (0010, 0020...). With these values I can ask the table MAST to get the STLNR. But how can I get all needed values to specify an entry in the table STPO then?
    Thanks,
    Konrad

    Here is a actual working code that we used here.
    *-- get the bom details
      li_mast-mandt = sy-mandt.
      li_mast-matnr = material.
      li_mast-werks = '6000'.
      li_mast-stlan = '1'.
      call function 'GET_MAST'
           exporting
                all             = 'X'
                no_buffer       = 'X'
                set             = 'X'
           tables
                wa              = li_mast
           exceptions
                call_invalid    = 1
                end_of_table    = 2
                get_without_set = 3
                key_incomplete  = 4
                key_invalid     = 5
                no_record_found = 6
                others          = 7.
      if sy-subrc <> 0.
        clear: kdf_material,
               kdf_material_desc.
        exit.
      endif.
      loop at li_mast.
    *-- get the valid headers
        move-corresponding li_mast to li_stko.
        li_stko-stlty = 'M'.
        call function 'GET_STKO'
             exporting
                  all             = 'X'
                  datub           = l_valid_date
                  datuv           = l_valid_date
                  del             = ' '
                  no_buffer       = 'X'
                  set             = 'X'
                  valid           = 'X'
             tables
                  wa              = li_stko
             exceptions
                  call_invalid    = 1
                  end_of_table    = 2
                  get_without_set = 3
                  key_incomplete  = 4
                  key_invalid     = 5
                  no_record_found = 6
                  others          = 7.
        if sy-subrc <> 0.
          continue.
        endif.
        loop at li_stko.
          move-corresponding li_stko to li_stpo.
          call function 'GET_STPO'
           exporting
             all                    = 'X'
             alter                  = li_stko-stlal
             datub                  = l_valid_date
             datuv                  = l_valid_date
             no_buffer              = 'X'
             set                    = 'X'
             valid                  = 'X'
    *        VIEWNAME               =
           tables
             add_wa                 = li_cszalt
             wa                     = li_stpo
           exceptions
             call_invalid           = 1
             end_of_table           = 2
             get_without_set        = 3
             key_incomplete         = 4
             key_invalid            = 5
             no_record_found        = 6
             viewname_invalid       = 7
             others                 = 8.
          if sy-subrc <> 0.
            continue.
          else.
            exit.
          endif.
        endloop.
        if not li_stpo[] is initial.
          exit.
        endif.
      endloop.

  • Display all the rows in the table with Varray

    I created two Varrays
    CREATE TYPE phone_varray AS VARRAY(3) OF NUMBER(10);
    CREATE TYPE email_varray AS VARRAY(3) OF varchar2(30);
    CREATE TABLE ee
    (id number(2),
    phone phone_varray);
    now i inserted some rows into ee table and displayed it as:
    SELECT e1.id,e2.COLUMN_VALUE"PHONE NO" FROM ee e1,TABLE(e1.phone) e2;
    ID PHONE NO
    1 1111111111
    1 2222222222
    1 3333333333
    1 1111111111
    1 2222222222
    1 4444444444
    4 1111
    4 2222
    4 33334
    5 1111
    5 2222
    5 33334
    Then i altered the table with email_varray
    desc ee;
    Name Null? Type
    ID NUMBER(2)
    PHONE PHONE_VARRAY
    EMAIL EMAIL_VARRAY
    I updated some rows:
    update ee e1 set email=email_varray('aasda') where id=4;
    and when i try to display the table data by:
    SELECT id,e2.*,e3.* from ee e1,TABLE(e1.phone) e2,TABLE(e1.email) e3;
    it only displays the rows that contain all the details like
    ID COLUMN_VALUE COLUMN_VALUE
    4 1111 aasda
    4 2222 aasda
    4 33334 aasda
    and not all the rows that are in the table which have id and phone and email as NULL
    need help to display all the rows in the table.

    will this work for you ?
    SELECT e1.id,e2.COLUMN_VALUE as PHONE_NO, null as email FROM ee e1,TABLE(e1.phone) e2
    union
    SELECT e1.id,null,e3.column_value as email from ee e1, TABLE(e1.email) e3;

  • To color a specific row in a Table UI element

    Hello Experts,
    We have a requirement to highlight (with distinguish color) a specific row of a table UI based on column data.
    Suppose we have a table with 5 column and 10 row, now if the data on 5th column greater than some XYZ value then we need to highlight the specific row with a different color.
    Can anyone please help me to achieve this requirement?
    Thanks & Regards,
    Sambaran Chakraborty

    Hi,
    In your outline, I am missing quite a few prerequisites which I mentioned (not sure if you have implemented them already)
    your sub node, does it have singleton=false, cardinality 1..1 and selection cardinality 1..1?
    The attribute of type TableCellDesign in that sub node, does it have the calculated property to true?
    If you've bound each table column's cellDesign property to this calculated attribute, you just put some code in the generated generated get<SubNode><CalcAttribute> method to set the color
    For instance by just entering the line
    return WDTableCellDesign.CRITICALVALUE_LIGHT
    in that method will render each linked cell to that color
    Not sure what else I can say to explain this, there's not much to code...

  • Deleting rows from a table

    COuld anyone tell me how to delete rows from a table which has millions of rows.
    TIA,
    Oracle user

    if you are deleting all the rows, use "truncate table" in sql*plus.
    or if you are deleting all but a handful of rows, then copy the rows you still want to a spare table, drop the original table, and rename the spare table back to the original table's name.
    hope this helps

  • Copying table rows from one table to another table form

    Hi
    I have a problem about Copying table rows from one table to another table form.On jsf pages if you enter command button go anather jsf page and it copy one row to another table row. But when i execute this process for table FORM it doesn't copy I wrote a code under "createRowFromResultSet - overridden for custom java data source support." Code block is:
    ViewRowImpl value = super.createRowFromResultSet(qc, resultSet);
    try{
    AdfFacesContext fct = AdfFacesContext.getCurrentInstance();
    Number abc = (Number)fct.getProcessScope().get("___");
    value.setAttribute("___",abc);
    }catch(Exception ex){System.out.println(ex);  }
    return value;

    Table may be copied with the
    expdp and impdp utilities.
    http://www.oracle.com/technology/products/database/utilities/index.html

  • Deleting a row from parent table

    Dear Guru's
    I am having two table with parent - child relationship. My problem is when I am deleting a row from parent table the curresponding child row from child table also should be deleted.
    My Primary table 'Employee, EMPID Primary key
    Child table 'Privilage' inthis EMPID referencing the EMPID of Employee table
    My need is when I am deleting a row from parent table the curresponding child row from child table also should be deleted
    I issued the SQL query like,
    delete from employee where empid='12345' cascade constraints;
    Then it showing me error like,
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    Please resolve my issue , Its Top urgent
    Thanks & Cheers
    Antony

    Choosing How Foreign Keys Enforce Referential Integrity
    Oracle Database allows different types of referential integrity actions to be enforced, as specified with the definition of a FOREIGN KEY constraint:
    Prevent Delete or Update of Parent Key The default setting prevents the deletion or update of a parent key if there is a row in the child table that references the key. For example:
    CREATE TABLE Emp_tab ( 
    FOREIGN KEY (Deptno) REFERENCES Dept_tab);Delete Child Rows When Parent Key Deleted The ON DELETE CASCADE action allows parent key data that is referenced from the child table to be deleted, but not updated. When data in the parent key is deleted, all rows in the child table that depend on the deleted parent key values are also deleted. To specify this referential action, include the ON DELETE CASCADE option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE CASCADE); Set Foreign Keys to Null When Parent Key Deleted The ON DELETE SET NULL action allows data that references the parent key to be deleted, but not updated. When referenced data in the parent key is deleted, all rows in the child table that depend on those parent key values have their foreign keys set to null. To specify this referential action, include the ON DELETE SET NULL option in the definition of the FOREIGN KEY constraint. For example:
    CREATE TABLE Emp_tab (
        FOREIGN KEY (Deptno) REFERENCES Dept_tab 
            ON DELETE SET NULL);
    SQL> conn scott/tiger
    Connected.
    SQL> create table ppk ( no number primary key);
    Table created.
    SQL> begin for inn in 1..10 loop insert into ppk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> create table ffk ( no number references ppk(no));
    Table created.
    SQL> begin for inn in 1..10 loop insert into ffk values (inn); end loop; end;
    PL/SQL procedure successfully completed.
    SQL> drop table ppk cascade constraints;
    Table dropped.Message was edited by:
    user52
    Message was edited by:
    user52
    Message was edited by:
    user52

Maybe you are looking for

  • How to Deploy all mappings in a module using OMB+

    Hi, I am using OMB+ to deploy project from DEV to QA , i used a OMB+ script to do the export and one import script to do the import/deployment both Export and Import are working fine , the problem is in the Deploy part of Import script, in this scrip

  • Using HP f4500 on Windows 8.1

    Hi, I have just replaced my old laptop which ran on Windows 7 with a new laptop running Windows 8.1. Previously my Deskjet All in One F4500 allow me to scan and print wirelessly. I have managed to get the new laptop to print via the USB, but I want t

  • Preview: problems viewing icons in sidebar

    I have some PDFs that I have OCRed. When I view them in Preview, in the sidebar, I don't get icons of the pages, but a garbled table of contents view instead. It looks like somewhere in the OCR process, a table of contents was created, but it is fill

  • Forwarding attachements in emails

    hi,just got my Lumia 920. Have set up both yahoo and gmail accounts, but every time I try to forward an email with an attachment, the email arrives without attachment. any help? how do I solve this issue?

  • Bapi or FM to create a downpayment document(F-47)

    Hi, Need an FM/BAPI to create an down payment document similar to F-47 Document type : KA Spl G/L Acc Indicator : A Account = Vendor No Regards Shiva