Query reg. Trigger

I am writing a trigger to log the history when there is any transaction on the parent table.My history table contains the following columns : table_name,column_name,old_value,new_value.
Is there any method by which I can identify and insert the column names affected in a single insert statement, if more than one column value is changed? or should I proceed with checking for the new and old values of all columns and then form a string of the columns names and values in a variable and then insert it into the history table? Kindly suggest....

You can use
if updating('COLUMN_NAME') then
  insert....                                                                                                                                                                                           

Similar Messages

  • Query mode trigger....

    Hello folks,
    I have this problem, i need when-validate-item to fire in query mode, in the help they say this trigger can't be fired in query mode is there any way to produce the same effect or validation in query mode, what i need is when a user fill a text item and before to query the datablock to test thsi text item... and thank you...

    I would say pre_query is a better place to test your query condition, or set your query condition if nessary.
    or if you need the same check fire normal mode, you could the checking in a program unit and call it from pre_query and when_validate_item trigger.
    hedy

  • Query on trigger.

    create or replace trigger trig_name before update of sal on emp for each row
    Declare
    excep exception;
    begin
    if (:new.sal=3500) then
    dbms_output.put_line('value is more than 3500 okay');
    else
    --:new.sal:=3500
    --update emp set sal=3500 where empno=:new.empno;
    raise excep;
    --raise_application_error(-20400,'update can''t be done');
    --dbms_output.put_line('now sal value is set to 3500');
    end if;
    exception
    when excep then
    dbms_output.put_line('update can''t be done');
    end;
    in the above trigger I want to raise when updating sal is not equal to 3500.
    1)Actually my intention is if it is not 3500 i want to make it ti 3500 and update it.. So I tried assigning 3500 to :new.sal(it gav error so left it)
    2)then for the same i row i gav another update statement inside trigger body with sal=3500(it raised mutating error)
    3) so I cudn't update the value i intented I decided to stop the update by raising a exception whenever sal vaue is not 3500..(this raises the given exception and at the same updates the value in the table)..
    Please help me if I have to do above three transactions using trigger...
    As I am abeginner pls excuse me if i have made any basic mistakes...
    thanks in advance..
    by
    Prabu....

    (this raises the given exception and at the same updates the value in the table)..That's because you trapped the exception in your exception...uhh...handler.
    Get rid of your entire exception section. It's hiding your errors.
    SQL> select * from t;
                       C
                       3
    SQL> create or replace
      2  trigger tr
      3  before update of c on t
      4  for each row
      5  begin
      6     if :new.c = 0 then
      7        raise_application_error(-20400,'c can never be 0');
      8     end if;
      9  exception
    10     when others then null;  --< one of the worst lines in all pl/sql
    11  end;
    12  /
    Trigger created.
    SQL> update t set c = 0;
    1 row updated.
    SQL> select * from t;
                       C
                       0

  • APO ABAP - Query reg. /SAPAPO/BOP_WORKLIST report output

    Hi,
    I have a query in ABAP APO in /SAPAPO/BOP_WORKLIST report. My requirement is to add the fields KNA1-NAME1 & KNA1-MCOD3 to the report output only, but not to the filter as in Note 376773 or 377186. Please let me know if you have any inputs to offer. Thanks in advance.
    Regards
    Murthy

    Hi ,
    The req is not completely clear.
    still , with some assumptions,
    you can use ws_download FM to download the final internal table content to flat file on PC.
    regards.
    santosh.

  • Query reg. Resource and time allocation in cProjects

    Wondering if someone can answer this query related to -  Resource and time allocation in cProjects.
    I understand the following regarding creating cProject -
    1 - Project manager creates a cProject for any upcoming new project in the organization.
    2 - Phases and Tasks will be created automatically (at our end) based on the template selected while creating the cProject.
    3 - Project manager assigns the resources to the project.
    4 - Allocate start date and end date for the resources against Tasks or Phase -
    > This is the point where there isn't enough documentation to help me progress further. Please can someone suggest how and where do we specify the start date and end date to a resource in cProject.
    A sample document on the BEST approach to create cProject, assign reources to tasks, allocate start date and end date would indeed help further clarify my doubt.
    I wante to create a cProject with various tasks, assign resources, start and end date for each task. As the project progresses,
    I want to execute a report to track the progress of this cProject as resources go on completing a task.
    Thanks,
    RB

    Hi Pramod,
       Thanks for your reply. Below are some queries based on few points mentioned by you.
    Allocate start date and end date for the resources against Tasks or Phase -
    When we prepare Project template, we define all project structure with phase, tasks, milestones, etc. - OK
    Also we define phase and task depedency, duration for tasks. - OK
    In actual Project execution PM creates project with reference to template, he add or delete any task / phase, changes duration if required. - How do you change duration of the task ? What series of events or clicks need to be followed ? Would be nice if atleast one option is listed.
    While in project planning, planner has to enter start and end date for project. - OK
    cProject scedules all other dates accordingly. We need not to go to individual phase or task to adjust dates. one can adjust only duration and depency to get required dates for tasks. This is standard planning phelosophy used in CPR, MSP or Primavra I believe. - At phase level, I can see Earliest start + finish and Latest start + finish dates populated automatically. In addition Start date constraint and Finish data constraints fields are available and empty. Is it mandatory to enter these dates ?
    While doing resource assignment, the start and end dates are coming from task assigned to particular Project Role. - At Task level, I can see Earliest start + finish and Latest start + finish dates populated automatically. In addition Start date constraint and Finish data constraints fields are available and empty. Is it mandatory to enter these dates ?
    cProjects automatically schedules the plan in create status, once the project released and actual status updated in cProjects, Project plan needs to schedules manually with help of schedule button in Project menu.- When I click Schedule button, message - Bottom-up scheduling was carried out is populated on screen. What is Bottom-up scheduling ?
    Would be nice to get reply to above queries.
    Thanks,
    RB

  • Enter query form trigger from MENU

    Hi .
    I am using Oracle Developer 9i , I have coded KEY-ENTQRY for some validation.
    I have created MENU using Menu builder . On Enter query Menu I have Coded normal 'ENTER_QUERY' code. When I run the form, form is not calling my KEY-ENTQRY code. How can I perform this task.
    Thanx

    Have you used do_key on the enter query menu?
    Use do_key(''ENTER_QUERY') and it should work.
    Please mark answer as helpful / correct, if it helps you
    Navnit

  • Query reg Variable Substitution with enhanced interface mapping

    Hi All,
      The scenario is IDoc to file using enhanced interface determination (message split based on some conditions) and the output file name should be based on a field value in the  IDoc. So, I've tried using Variable Substitution Option in the receiver file adapter. But it's failing with the error 'com.sap.aii.adapter.file.varsubst.VariableDataSourceException'. 
    My question is does Variable Substitution works with Enhanced Interface Determination? Bcoz the outcome of interface determination is a main and sub payload.
    IDoc Payload
    <?xml version="1.0" encoding="utf-8" ?><HR_HRMD_A07><IDOC BEGIN="Constant"><E1PLOGI SEGMENT="Constant">
    <E1PITYP SEGMENT="1"><E1P0000 SEGMENT="1"><ENDDA>99991231</ENDDA></E1P0000></E1PITYP></E1PITYP></E1PLOGI></IDOC></HR_HRMD_A07>
    Variable Substitution XPATH, which I've mentioned is payload:HR_HRMD_A07,1,IDOC,1,E1PLOGI,1,E1PITYP,1,E1P0000,1,ENDDA,1
    Thanks in advance.
    Regards,
    Joe.

    Hi,
    It was the problem with the capital letters for the variable field. We changed it to small letters, then the issue is resolved.
    Thanks,
    Joe.

  • Query Reg env-entry in ejb jar xml

    Hi,
    I have the following tag in the ejb-jar of my application:
    <env-entry>
    <env-entry-name>postingDate</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>Request</env-entry-value>
    </env-entry>
    When a JNDI LookUp is done for this variable in the application, it doesn't pick up the value of the variable which is "Request" but it picks up the Value of the Posting Date.
    I need to know how this works!
    Just an Fyi, Posting Date is a date entered from the UI.

    I feel it is like declaring global and local variables with the same name and trying to access that variable.

  • Query reg adding custom tags in SOAP Header - AXIS Receiver Adapter

    Hi All,
    I need to send custom tags as mentioned below to my traget webservice application. I think I can do this with Receiver AXIS adapter but not sure how it can be done. Can any of you suggest?
                                                  <WSContext>
                   <FromAppId>ABC</FromAppId>
                   <ToAppId>XYZ</ToAppId>
              </WSContext>
    Thanks,

    If you want to add custom tags in the soap header, one possible solution is use XSLT mapping or Java mapping to create header first then do message mapping for mapping the payload structure between your source and target  as usual.
    So in operation mapping you sequence mapping like this... first XSLT mapping for custom tags for the SOAP Header followed by payload mapping.
    Hope that helps.
    Search SDN for XSLT Mapping for soap header. Already we have handled these issues.

  • Simple query reg radio button

    Hii All
    In my report i am creating two radio buttons normally when we create radio buttion text comes first then radio button comes
    But i want first radio button comes then corresponding text to my radio button appears
    Helpful Answers will be rewarded
    regards
    Hitesh

    Hi
    see this selection screen design
    TABLES EKKO.
    ********END OF DATA DECLARATIONS*********
    ********SELECTION SCREEN DESIGN ***********
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.
    SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : R2 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B2.
    ******END OF SELECTION SCREEN DESIGN****************
    double click that text elements and write what ever you want and activate it
    thats all

  • Query reg. function module ERP_IDOC_INPUT_CREDITOR

    Hi Experts,
    Please tell how to pass the parameter of function module ERP_IDOC_INPUT_CREDITOR.
    parameter like input_method,mass processing,pi_xk99_used .
    Thanks,
    sameer

    you can specify any number fields in file and any number fields in internal table,
    see the program and when you specify the count variable in your internal table ,if the data is not available,then it will take some defualt values,other than this one it will be okay.
    In my system count variable data is  538976288  if the file does not have value.
    report x.
    DATA: BEGIN OF ITAB_MATNR OCCURS 0,
    MATNR LIKE MARA-MATNR,
    COUNT TYPE i,
    END OF ITAB_MATNR.
    data : v_repid like sy-repid.
    parameters p_file like rlgrap-filename.
    initialization.
    v_repid = sy-repid.
    at selection-screen on value-request for p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
       PROGRAM_NAME        = v_repid
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
    IMPORTING
       FILE_NAME           = p_file
    start-of-selection.
    refresh itab_matnr.
    clear itab_matnr.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = P_FILE
    filetype = 'ASC'
    TABLES
    DATA_TAB = ITAB_MATNR
    EXCEPTIONS
    CONVERSION_ERROR = 1
    FILE_OPEN_ERROR = 2
    FILE_READ_ERROR = 3
    INVALID_TABLE_WIDTH = 4
    INVALID_TYPE = 5
    NO_BATCH = 6
    UNKNOWN_ERROR = 7
    GUI_REFUSE_FILETRANSFER = 8
    OTHERS = 9.
    IF SY-SUBRC <> 0.
    MESSAGE E699(PP) WITH 'Unable to load input file' P_FILE.
    ENDIF.
    in my file
    data is like ( No count)
    matnr
    12344
    ssss
    sddd
    sddff
    after ws_upload :
    material          count
    12344             | 538976288                                             |
    ssss               | 538976288                                             |
    sddd               | 538976288                                             |
    sddff               | 538976288

  • Creating a correct trigger condition

    hi All,
    I have a problem in my trigger condition in my query.
    The background:
    1. I have a List view with a Data insertion (Lead Select) into a ROW.
    2. Also, I have 5 different queries which are triggered based on a selection of a Radio button.
    Now, my req is that Query1 should load either on
                                                             change of Lead select in List View
                                                       OR if the chosen Radio button is 1
    Query2 should load either on
                                                             change of Lead select in List View
                                                       OR if the chosen Radio button is 2
    & so on.
    Can you please help me with a valid trigger condition. ? The concatenate is not working as the Xcel only allows Value Change or Value Becomes.
    Currently, I am launching all the 6 queries at once using CONCATENATE + VALUE CHANGE. This is a huge hit on performance.
    Cheers
    Kiran

    What if you have 5 different cells (one for each query) and you only have the trigger cell for Query 1 show the list select value only if the chosen radio button is 1 and so on?
    Formula for Query 1 Trigger Cell: =If(=1,,"")
    Formula for Query 2 Trigger Cell: =If(=2,,"")
    ~~~~~~~~~~~~~~~
    Formula for Query 5 Trigger Cell: =If(=5,,"")
    Then, the value in any given cell should update any time the radio button is changed (from "" to the ListSelectValue) and anytime the ListSelect value changes (assuming that radio button is selected).

  • To connect a datablock to a query - stored procedure: problem

    I have the following table...
    CREATE TABLE I_TIPOLOGIA (
    CODICE NUMBER(6),
    DESCRIZIONE VARCHAR2(100),
    CONSTRAINT I_TIPOLOGIA_PK PRIMARY KEY (CODICE) );
    and the following package to connect a datablock to
    previous table with a stored procedure...
    CREATE or REPLACE PACKAGE DATABANKER_TIPOLOGIE AS
    TYPE TipTableOfRec IS TABLE OF I_TIPOLOGIA%ROWTYPE;
    PROCEDURE leggi(resultset IN OUT TipTableOfRec);
    END DATABANKER_TIPOLOGIE;
    CREATE or REPLACE PACKAGE BODY DATABANKER_TIPOLOGIE AS
    PROCEDURE leggi(resultset IN OUT TipTableOfRec) AS
    BEGIN
    SELECT * BULK COLLECT INTO resultset
    FROM I_TIPOLOGIA;
    END leggi;
    END DATABANKER_TIPOLOGIE;
    When I compile the form I receive in QUERY-PROCEDURE trigger
    en error 306: "number or type of arguments are wrong in POPULATE_BLOCK"
    I post the trigger auto generated by Forms Builder 6i...
    DECLARE
    bk_data DATABANKER_TIPOLOGIE.TIPTABLEOFREC;
    BEGIN
    DATABANKER_TIPOLOGIE.leggi3(bk_data);
    PLSQL_TABLE.POPULATE_BLOCK(bk_data, 'BLOCCO50'); -- <- error here
    END;
    How can I solve this problem? Maybe there is a bug?
    P.S. I'm using Oracle Database 9i

    CREATE or REPLACE PACKAGE DATABANKER_TIPOLOGIE AS
    TYPE TipTableOfRec IS TABLE OF I_TIPOLOGIA%ROWTYPE;
    PROCEDURE leggi(resultset IN OUT TipTableOfRec);
    END DATABANKER_TIPOLOGIE;I have solved with this replacement 1) -> 2)
    1) TYPE TipTableOfRec IS TABLE OF I_TIPOLOGIA%ROWTYPE;
    2) TYPE TipTableOfRec IS TABLE OF I_TIPOLOGIA%ROWTYPE
    INDEX BY BINARY_INTEGER;
    with 2) now works.
    Now I have stored-procedures for query, insert, delete
    and update.
    I have some problems with delete and update of the records
    because it seems that they are locked.
    I think that it is due to the absence of lock
    stored-procedure... there's someone that can help me with
    the lock SP implementation?

  • How to use update trigger in sql server 2008 with specific column

    Hello friends currently my trigger updates on table update, and I need to change this to only fire when specific column changes.
    /****** Object: Table [dbo].[User_Detail] ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[User_Detail](
    [sno] [int] IDENTITY(1,1) NOT NULL,
    [userid] [nvarchar](50) NULL,
    [name] [nvarchar](max) NULL,
    [jointype] [nvarchar](50) NULL,
    [joinside] [nvarchar](50) NULL,
    [lleg] [nvarchar](50) NULL,
    [rleg] [nvarchar](50) NULL,
    [ljoining] [int] NULL,
    [rjoining] [int] NULL,
    [pair] [int] NULL
    ) ON [PRIMARY]
    GO
    /****** Object: Table [dbo].[User_Detail] table data ******/
    SET IDENTITY_INSERT [dbo].[User_Detail] ON
    INSERT [dbo].[User_Detail] values (1, N'LDS', N'LDS Rajput', N'free', N'Left', N'jyoti123', N'SUNIL', 6, 4, 4)
    INSERT [dbo].[User_Detail] VALUES (2, N'jyoti123', N'jyoti rajput', N'free', N'Left', N'mhesh123', N'priya123', 3, 2, 2)
    SET IDENTITY_INSERT [dbo].[User_Detail] OFF
    /****** Object: Table [dbo].[User_Detail] trigger ******/
    CREATE TRIGGER triggAfterUpdate ON User_Detail
    FOR UPDATE
    AS
    declare @userid nvarchar(50);
    declare @pair varchar(100);
    select @userid=i.userid from inserted i;
    select @pair=i.pair from inserted i;
    SET NOCOUNT ON
    if update(pair)
    begin
    insert into Complete_Pairs(userid,pair)
    values(@userid,1);
    end
    GO
    /****** Object: Table [dbo].[Complete_Pairs] Script Date: 05/22/2014 21:20:35 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Complete_Pairs](
    [Sno] [int] IDENTITY(1,1) NOT NULL,
    [userid] [nvarchar](50) NULL,
    [pair] [int] NULL
    ) ON [PRIMARY]
    GO
    my query is TRIGGER triggAfterUpdate is fired only when pair column in User_Details table is update only and when we update other column like ljoin or rjoin then my trigger is not fired
    please any one can suggest us how it can done or provide solution
    Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402

    >select @userid=i.userid
    frominserted i;
            select
    @pair=i.pair
    frominserted i;
    The code above assumes a single row UPDATE.
    You have to setup the trigger for set processing like when 100 rows are updated in a single statement.
    UPDATE trigger example: http://www.sqlusa.com/bestpractices2005/timestamptrigger/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to replace # in the query output ?

    Hi experts,
    In the query output and for a particular field in a record if there is no value then it is displaying as '#'.
    Can  we replace '#' with any text or with any other value ?
    Regards,
    Nishuv V.

    hello,
    if you display the characteristics as Key u will get as '#'.
    You can select as Text,then it will show 'Not Assigned'.
    Further, check on these threads:
    How to replace '#' with blank when there is no value for a date field
    Re: How to replace display attribute Value '0', instead of '#' in the query
    Reg,
    Dhanya

Maybe you are looking for