How to select all columns in a trigger?

I add a "before delete" trigger on a table, in order to insert the records to a backup table before they are deleted.
but I cannot write like this : insert into t_backup select * from :old;
The table has more than 30 columns so I don't want to select them one by one, how can I select all columns?

Yes, it is possible by writing something like this :
where col1 = :old.col1; But it is not directly supported. First, we need a package to remember all the OLD records:.... and please see below link for complete code in action :
http://www.dbforums.com/oracle/925729-trigger-back-up-data.html
What I am doing here, just copying the code and replacing "emp" with "test" (The table name on which I am going to apply this using notepad find and replace):
SQL> select * from test_backup;
no rows selected
SQL> select * from test;
         A
         1
         2
         4
         5
SQL> select * from test_backup;
no rows selected
SQL>
create or replace package test_trg_pkg as
  type test_type is table of test%ROWTYPE index by binary_integer;
  test_tab test_type;
end;
create or replace trigger test_bds before delete on test
begin
  test_trg_pkg.test_tab.delete;
end;
create or replace trigger test_adr after delete on test
for each row
declare
  -- To allow us to select the old values
  pragma autonomous_transaction;
begin
  select *
  into   test_trg_pkg.test_tab(test_trg_pkg.test_tab.COUNT+1)
  from   test
  where  a = :old.a;  <----- Here you have to give your column name.
end;
create or replace trigger test_ads after delete on test
begin
  for i in 1..test_trg_pkg.test_tab.COUNT loop
    insert into test_backup values test_trg_pkg.test_tab(i);
  end loop;
end;
SQL> delete from test where a=1;
1 row deleted.
SQL> select * from test_backup;
         A
         1
SQL> delete from test where a=2;
1 row deleted.
SQL> select * from test_backup;
         A
         1
         2
SQL>Regards
Girish Sharma

Similar Messages

  • How to select all the colomns_names from a table, with their datatypes ..

    hi :)
    i would like to know, how to select in SQL all the columns names from a table with their datatypes so that i get something like this :
    Table 1 : table_name
    the column ID has the Datatype NUMBER
    the column name has the Datatype Varchar2
    Table 2 : table_name
    the column check has the Datatype NUMBER
    the column air has the Datatype Varchar2
    and that has to be for all the tables that i own ! ..
    P. S : i m trying to do this with java, so it s would be enough if you just tell me how to select all the tables_names with all their colums_names and with all their datatypes ! ..
    thank you :)
    i ve heard it can be done with USER_TABLES .. but i have no idea how :( ..
    Edited by: user8865125 on 17.05.2011 12:22

    Hi,
    The data dictionary view USER_TAB_COLUMNS has one row for every column in every table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE have all the information you need.
    Another data dictionary view, USER_TABLES, may be useful, too. It has one row pre table.

  • How to SELECT ALL records of a TABLE VIEW in the BSP page

    Hi All,
    In the BSP portal, I am displaying some data(multple records) in the form of a table using the BSP TAG <htmlb:tableView>. I wrote the logic in the 'VIEW' of the BSP application which will be triggered by the controller. I have used the attribute selectionMode = "MULTISELECT" to have a Check Box to select a row.
    My requirement is to have a button/checkbox on the first column of the header of the table view. By clicking on this, it should select/desect all the records of the table. Could someone please help me how to do this? What attribute I should use in the tableview to get the button in the header row of the table and how to select all the records of the table.?
    Please provide your valuable inputs.
    Thanks & Regards,
    Paddu.

    Select all / Deselect all functionality when onRowSelection is there

  • How to select all files in a stack? Control-click doesn't work

    how to select all files in a stack? Control-click doesn't work

    Switch to list or column view. If you must use icon view, instead of Shift-clicking items, click on an empty space near one of them and drag to enclose them.
    (119467)

  • How to return all columns starting with E?

    How to return all columns starting with E in emp table?
    My attempts (below) were unsuccessful.
    SQL> SELECT E* from emp;
    SELECT E* from emp
    ERROR at line 1:
    ORA-00936: missing expression
    SQL> SELECT E.* FROM EMP;
    SELECT E.* FROM EMP
    ERROR at line 1:
    ORA-00904: "E": invalid identifier
    SQL> SELECT EMP.E* FROM EMP;
    SELECT EMP.E* FROM EMP
    ERROR at line 1:
    ORA-00936: missing expression

    You need to do it dynamically:
    SQL>  var cur refcursor
    SQL>  declare
      co varchar2(40);
    begin
      for c in (select column_name from cols where table_name = 'EMP' and column_name like 'E%') loop
        co := co || c.column_name || ',';
      end loop;
      open :cur for 'select '|| rtrim(co,',') || ' from emp';
    end;
    PL/SQL procedure successfully completed.
    SQL>  print cur
         EMPNO ENAME    
          7369 SMITH    
          7499 ALLEN    
          7521 WARD     
          7566 JONES    
          7654 MARTIN   
          7698 BLAKE    
          7782 CLARK    
          7788 SCOTT    
          7839 KING     
          7844 TURNER   
          7876 ADAMS    
          7900 JAMES    
          7902 FORD     
          7934 MILLER   
    14 rows selected.

  • How to print all columns in one page

    Hi,
    Can anybody explain me how to print all columns in one page.we have around 15 to 20 columns for 4 reports and all these reports are build on one multiprovider.we are using BW 3.5.
    Can anyone explain me  how to print ALL COLUMNS IN ONE PAGE  .currently they are getting all columns in 2 to 3 pages. They are using PORTAL to run the reports here.
    Is it possible to do by customizing Webtemplate or by macros in Workbook.Please help me
    Edited by: kotha123 on Oct 11, 2010 5:58 PM

    Hi,
    Your best bet is to use a workbook template or else Excel to pdf option...Thanks

  • How to bring all columns in a single/first page in report painter

    Hi Experts,
    There are 9 columns in a report painter which includes 1 lead column.
    7 columns comes in a first page including lead column and rest 2 columns goes to second page. This report is copied from another report where all columns comes in a first page only. if the original report comes in one page then why not the new report.
    Please suggest how to bring all columns in a single/first page in the new report.
    Please revert if I'm confused anywhere.
    Thanks in advance
    Arabinda

    Hi Rajneesh,
    Thanx for the quick reply. When I change the column width to 10 it comes in one page. But the requirement is to keep the column width to at least 12 or 14 and moreever the original report from where this report is copied having the same no of columns and the column width for original report is 14 and it comes in one page only.
    Do I need to do something more to achieve this. My question is how the original reports data comes in one page where as the current report having issue with same number of columns.
    Pls suggest.
    Thanx,
    Arabinda

  • What is the difference betwwen SELECT ALL Column and Select Speceific Colum

    Hi All,
    If the block size of the database is 8K and average row length is 2K and if we select all column of the table the I/O show that it had read more blocks then compare to
    specific column of the same table. Why is this?
    Secondly if Oracle brings a complete block is the db buffer cache, while reading block from disk, they why there is a difference of block count in two queries.
    This difference reveals to me when I check the EXPLAIN PLAN for two different queries against the same table but one select all columns and the other one select specific column.
    Kindly help me in clearing this confusion.
    Regards,
    Kamran

    user1514587 wrote:
    >
    Usually, indexes are smaller (contain fewer blocks) than the table - ergo, select empno from emp could be satisfied by reading fewer blocks.
    what if there is a composite Index on a table containing 3 to 4 columns and the size of table is in 100 of GB and Index size itself is vey large then I think Oracle will go for FTS and small Index scan will be expensive. Kindly Share your thoughts.
    Regards,
    KamranHandle:     user1514587
    Status Level:     Newbie (5)
    Registered:     May 9, 2011
    Total Posts:     21
    Total Questions:     13 (12 unresolved)
    I think you wastes everyone's time here since you rarely get answer to any posted question

  • 11.5.9 How to select all invoices in Payment batches ??

    Hi Guys,
    We are working on 11.5.9 Payment batches...
    Could anyone help me out on how to select all the Invoices whether due or not in the Payment Batches ?? I see that unchecking only due' doesn't work...is Pay through date is the only option ??
    Rgds,

    SelectManyListBox has a separate ALL checkbox visible. You can use that component
    jdevadf.oracle.com/adf-richclient-demo/faces/components/selectManyListbox.jspx

  • How to remove all columns and cells in numbers

    how to remove all columns and cells in numbers

    Click on the Table's icon in the Sheets list. Press delete.
    Done.
    Regards,
    Barry

  • How to select all files in "user dir" (LastAccessedDirectrory) using applet

    Hi,
    Can anyone tell me " How to select all files in "user dir" (Last Accessed Directrory) using applet"?
    For this which method in applet used?
    Thanks in Advance.

    1) Do you want "user dir" (watever that is) or do you wnat the last accessed directory? Last accessed by what/whom?
    2) Applets can't access the local file sytem, and for good reason, unless they're signed and the client has given permission.

  • How to select all the people that are not in any equipe  ?

    Hi,
    I have a nice SQL expression that gives me as a result all the "AGENTS" (people) that are working in an EQUIPE (a team)
    select a."AGENT_ID",
    a."NOM" || ' ' || a."PRENOM" "Nom",
    c.libelle "Equipe",
    a."DATE_EMBAUCHE" "Date embauche",
    a."DATE_DEBAUCHE" "Date débauche"
    from OBSERVATOIRE."AGENT" a,
    observatoire.equipe_agents b,
    observatoire.equipe c
    where a.agent_id = b.agent_id
    and b.equipe_id = c.equipe_id
    order by nom
    Now, how to select all the agents that are NOT working in any "EQUIPE" (team) ?
    I have tried but could not succeed !
    Thank you for your kind help.
    Christian

    Christian from France wrote:
    It is not working because the table EQUIPE_AGENTS does not contains a row if the agent is not into any equipe.
    CREATE TABLE "OBSERVATOIRE"."EQUIPE_AGENTS"
    (     "EQUIPE_AGENTS_ID" NUMBER NOT NULL ENABLE,
         "EQUIPE_ID" NUMBER NOT NULL ENABLE,
         "AGENT_ID" NUMBER NOT NULL ENABLE)
    CREATE TABLE "OBSERVATOIRE"."AGENT"
    (     "AGENT_ID" NUMBER NOT NULL ENABLE,
         "GRADES_ID" NUMBER NOT NULL ENABLE,
         "NOM" VARCHAR2(50 BYTE) NOT NULL ENABLE,
         "PRENOM" VARCHAR2(50 BYTE),
         "DATE_EMBAUCHE" DATE NOT NULL ENABLE,
         "DATE_DEBAUCHE" DATE)
    The only way to "know" if an agent is not into any equipe (team) is to search into the EQUIPE_AGENTS table, and if we do not find the ID of the agent into this table, then we know that this agent is not into any EQUIPE (team).
    I don't know ho to translate this into SQL.And that's what my query does. It uses an OUTER JOIN so that a result record is returned whether or not there is a record in EQUIPE_AGENTS. And the check for EQUIPE_ID is NULL restricts the result set to those where there IS NOT a record in EQUIPE_AGENTS.
    A more traditional way would be to use NOT IN or NOT EXISTS clauses, but they can prove inefficient.

  • How to select all PERNR from infotype 0000 (Action)

    Hi,
    How to select all PERNR from IT0000 (Action), if an action has been done on IT0000 between reporting START DATE and END DATE. What fields I should consider in IT0000.
    Thanks,
    mini

    You can try:
    data: t_0000 type standard table of pa0000.
    select * from pa0000
       into corresponding fields of table t_0000
      where begda le <your-initial-date> and endda ge <your-final-date>.
    Or use one of options described at last forum.
    Regards!
    Marcello
    Edited by: Marcello Lanzoni on Jul 24, 2008 8:11 PM

  • How to make all columns visible in an interactive report by default

    Hello All,
    I have an interactive report with the first column is visible and the rest are hidden by default. Is there any way that i can make them all visible by default so the users do not have to go into actions to display them in report?
    Thank you
    Sezer

    Login as developer > run the interactive report > actions > select all columns you want
    Now got to actions > save > default > primary > apply
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/ir_using.htm#CHDFDFJA

  • How to select all the text in a JTextArea??

    any1 know how to select all the text in a textarea?? just like when we press ctrl+a?? i use JTextAreaName.selectAll();doesnt work
    helt..

    worked OK for me
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Myprogram extends JFrame
      JTextArea TArea = new JTextArea(10,10);
      public Myprogram()
        JMenu JMenuName= new JMenu("JMenuName");
        JMenuItem  JMenuItemName=new JMenuItem("Select all");
        JMenuName.add(JMenuItemName);
        JMenuItemName.addActionListener(new SelectAllAction());
        getContentPane().add(new JScrollPane(TArea));
        JMenuBar mb = new JMenuBar();
        mb.add(JMenuName);
        setJMenuBar(mb);
        pack();
        setLocationRelativeTo(null);
        setVisible(true);
      class SelectAllAction implements ActionListener
        public void actionPerformed(ActionEvent e)
          TArea.requestFocusInWindow();
          TArea.selectAll();
      public static void main(String[] args){new Myprogram();}
    }

Maybe you are looking for

  • Get back to mac os 10.5.2

    Okay, so I have an iBook G4 12in 1.33 ghz. A few months ago I had installed leopard, but realized that I still needed os 9, so I went back to Tiger (with classic support) a few weeks ago. Today, I no longer needed that app, so looking forward to bein

  • Please help!!! first green screen, now "itunes has stopped working"

    Hi, please, anyone - I need help I have a dell laptop running windows Vista about 2 days ago, all of a sudden itunes refused to play my TV shows (which I have a lot of, probabely about $500 worth!). At first it just displayed either a green screen, o

  • No entries in Define conversion group and external function module setting.

    Hi all, After active bussiness function SAP Oil & Gas, my system have a problem in SPRO. SPRO --> IMG --> Industry solution Oil & Gas (Downstream) --> HPM --> QCI configuration --> Define conversion group and external function module setting. Problem

  • Errror Update the data service Personal Information -- Personal Data

    We have a problem in ESS at the time of updating the data, somebody knows as it can be the cause In the portal --->Personal Information -->Personal Data com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCExecuteException: Screen output without con

  • Portal not picking up changes from query view in analyzer

    Hello All, If I change a query view in analyzer, the changes are not being picked up in the portal unless i restart the portal, therefore clearing the cache.  Is there away of clearing the portal cache without a restart?  I am aware of a few ways to