Need help writing a TRIGGER !!!

The trigger below:
create or replace
TRIGGER dtworepair_after_update_status
AFTER UPDATE OF worepair_status
ON dtworepair
FOR EACH ROW
WHEN (NEW.worepair_status = 'CLOSED')
DECLARE
--workorder_nbr_var   dtworepair.worepair_wonbr%TYPE;*
id_count_var        NUMBER;
status_count_var    NUMBER;
BEGIN
SELECT COUNT(worepair_wonbr) INTO id_count_var
FROM dtworepair
WHERE worepair_wonbr = :OLD.worepair_wonbr;
SELECT COUNT(worepair_status) INTO status_count_var
FROM dtworepair
WHERE worepair_status = 'CLOSED' AND worepair_wonbr = :OLD.worepair_wonbr;
IF UPDATING THEN
IF id_count_var != status_count_var THEN
update_wo_status_proc(:OLD.worepair_wonbr,'OPEN');
ELSIF id_count_var = status_count_var THEN
update_wo_status_proc(:OLD.worepair_wonbr,'CLOSED');
END IF;
END IF;
END dtworepair_after_update_status;
is suppose to fire when the DTWORepair table worepair_status column is updated to 'CLOSED'. And if all the records with the same worepair_wonbr now have a 'CLOSED' worepair_status then this trigger is suppose to call the procedure:
create or replace
PROCEDURE update_wo_status_proc
repair_wonbr_param  IN dtworkorder.wo_nbr%TYPE,
status_param        IN VARCHAR2
AS
BEGIN
IF status_param = 'CLOSED' OR status_param = 'OPEN' THEN
UPDATE dtworkorder
SET wo_status = status_param, wo_enddate = SYSDATE
WHERE wo_nbr = repair_wonbr_param;
END IF;
END update_wo_status_proc;
But I keep getting the error below when I try:
UPDATE dtworepair
SET worepair_status = 'CLOSED'
WHERE worepair_wonbr = 2 AND worepair_tasknbr = 4;
Error starting at line 1 in command:
UPDATE dtworepair
SET worepair_status = 'CLOSED'
WHERE worepair_wonbr = 2 AND worepair_tasknbr = 4
Error report:
SQL Error: ORA-04091: table DISTRAN.DTWOREPAIR is mutating, trigger/function may not see it
ORA-06512: at "DISTRAN.DTWOREPAIR_AFTER_UPDATE_STATUS", line 6
ORA-04088: error during execution of trigger 'DISTRAN.DTWOREPAIR_AFTER_UPDATE_STATUS'
04091. 00000 - "table %s.%s is mutating, trigger/function may not see it"
*Cause:    A trigger (or a user defined plsql function that is referenced in
this statement) attempted to look at (or modify) a table that was
in the middle of being modified by the statement which fired it.
*Action:   Rewrite the trigger (or function) so it does not read that table.
worepair_wonbr worepair_tasknbr worepair_id worepair_status worepair_labor
1     1     15     CLOSED     0.5
2     1     3     CLOSED     0.75
2     2     4     CLOSED     2
2     3     5     CLOSED     0.25
2     4     6     OPEN     0.5
For example, worepair_wonbr 2 in the above table has 1 record in the DTWorkorder table and 4 worepair_tasknbr in the above table. So long as 1 of the task,worepair_status, in the above table is OPEN, then the trigger will not fire. The Trigger should only fire when all 4 worepair_status in the above table for worepair_wonbr 2 are 'CLOSED'. This should in-turn run the procedure that will change the wo_status in DTWorkorder table to 'CLOSED' for wo_nbr 2.
This is in a nutshell what I am trying to accomplish.
Any ideas?

Hi,
'mutating trigger' error means that you are trying to use a trigger on a table to modify the contents of the same table -- Oracle doesn't allow that.
The standard workaround for this problem is to use row-level triggers to fill an array with data of rows that need to be modified, and do the modification in the statement-level trigger.
From 11g on, you can use compound triggers to do all in one trigger, see example in:
http://www.oracle-base.com/articles/11g/TriggerEnhancements_11gR1.php
Best regards,
Nikolay

Similar Messages

  • Need help writing host program using LabView.

    Need help writing host program using LabView.
    Hello,
    I'm designing a HID device, and I want to write a host program using National Instrument's LabView. NI doesn't have any software support for USB, so I'm trying to write a few C dll files and link them to Call Library Functions. NI has some documentation on how to do this, but it's not exactly easy reading.
    I've written a few C console programs (running Win 2K) using the PC host software example for a HID device from John Hyde's book "USB by design", and they run ok. From Hyde's example program, I've written a few functions that use a few API functions each. This makes the main program more streamlined. The functions are; GetHIDPath, OpenHID, GetHIDInfo, Writ
    eHID, ReadHIC, and CloseHID. As I mentioned, my main program runs well with these functions.
    My strategy is to make dll files from these functions and load them into LabView Call Library Functions. However, I'm having a number of subtle problems in trying to do this. The big problem I'm having now are build errors when I try to build to a dll.
    I'm writing this post for a few reasons. First, I'm wondering if there are any LabView programmers who have already written USB HID host programs, and if they could give me some advice. Or, I would be grateful if a LabView or Visual C programmer could help me work out the programming problems that I'm having with my current program. If I get this LabView program working I would be happy to share it. I'm also wondering if there might already be any USB IHD LabView that I could download.
    Any help would be appreciated.
    Regards, George
    George Dorian
    Sutter Instruments
    51 Digital DR.
    Novato, CA 94949
    USA
    [email protected]
    m
    (415) 883-0128
    FAX (415) 883-0572

    George may not answer you.  He hasn't been online here for almost eight years.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Need help writing small program!

    Hi. I'm learning Java programming, and I need help writing a small program. Please someone help me.
    Directions:
    Create a program called CerealCompare using an if-then-else structure that obtains the price and number of ounces in a box for two boxes of cereal. The program should then output which box costs less per ounce.

    class CerealCompare {
        public static void main(String[] args) {
            // your code goes here
    }Hope that helps.
    P.S. Java does not have an if-then-else statement.

  • Need Help Writing Server side to submit form via API

    Hey
    I need help writing a serverside application to submit
    information via API to a separate server.
    I have a client that uses constant contact for email
    campaigns. We want to add to her website a form taht submits the
    information needed to subscribe to her email list, to constant
    contact via API.
    FORM.asp :: (i got this one under control)
    name
    email
    and submits to serverside.asp
    SERVERSIDE.ASP
    In serverside.asp i need to have
    the API URL
    (https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp)
    username (of the constant contact account)
    password (of the constant contact account)
    name (submited from form.asp)
    email (submitted from form.asp)
    redirect URL (confirm.asp)
    Can anyone help get me going in the right direction?
    i have tried several things i found on the net and just cant
    get anyone to work correctly.
    One main issue i keep having is that if i get it to submit to
    the API url correctly - i get a success code, it doesnt redirect to
    the page i am trying to redirect to.
    ASP or ASP.NET code would be find.
    THANKS
    sam

    > This does require server side programming.
    > if you dont know what that is, then you dont know the
    answer to my question. I
    > know what i need to do - i just dont know HOW to do it.
    If you are submitting a form to a script on a remote server,
    and letting
    that script load content to the browser, YOU have no control
    over what it
    loads UNLESS there is some command you can send it that it
    will understand.
    No amount of ASP on your server is going to change what the
    remote script
    does.
    http://www.constantcontact.com/services/api/index.jsp
    they only allow their customers to see the instructions for
    the API so i
    can't search to see IF there is a redirect you can send with
    the form info.
    But posts on their support board say that there is.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Need help writing a query for following scenario

    Hi all, I need some help writing a query for the following case:
    One Table : My_Table
    Row Count: App 5000
    Columns of Interest: AA and BB
    Scenario: AA contains some names of which BB contains the corresponding ID. Some
    names are appearing more than once with different IDs. For example,
    AA BB
    Dummy 10
    Me 20
    Me 30
    Me 40
    You 70
    Me 50
    Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
    I would appreciate any input. Thanks

    Is it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
    With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
    WITH t AS (
    SELECT 'me' aa, 10 bb FROM dual
    UNION ALL
    SELECT 'me' aa, 20 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    SELECT DISTINCT aa, bb
      FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
    WHERE cnt > 1;

  • Need help writing Labview Program!!!!!

    I have a labview project that needs to be finished. I was not the original creator of the program and the guy who created no longer is involved with the project and I am left to finish it. Could you make the final adjustment so I can turn this into my professor and get the final grade. Thanks! Willing to pay! Negeotiable price!!!!!!!!

    Need help completing assignment! Could anyone assist me in this project!
    Attachments:
    dial tone detection.zip ‏1253 KB

  • Need help writing a script

    I am trying to convert my prcess from DTS to SSIS. I am running this report out of SAP and then using Monarch to put into the correct form, then I am using the DTS to put it into the database on the SQL server.  I am able to get all the other info to
    move out having so much trouble here to get the plant number. The issuse is that it is on top on the page and it will change when a new plant is needed.
    Thanks for any help
    I need help wrting a script that will put that 7010 into a cloumn nnamed plant number.

    To convert from DTS packages to SSIS you can just open the DTS package in a new SSIS project (depends on target SSIS version by using SSDT or BIDS).
    The rest is mechanics how the iteration with SAP is done and may be beyond the scope of this forum.
    Arthur
    MyBlog
    Twitter

  • Need help writing a Java rule in PDF Forms

    I have created an invoice for my contractors via "forms", and in turn made each cell either a drop down list or "read only" field so they cannot change the rate of pay, etc.  Here is my issue...My first drop down cell is titled "Job Description".  When the contractor selects one of the 8 dropdown options within the Job Description field, I would like it to automatically fill in the hourly rate that is associated with that particular job description (or skill).  I currently have my "rate" cell as a drop down, and I want to make that a read only, and when you select the A1 position from Job Description, it will populate the "rate" field with the appropriate amount for that A1 rate.  I believe this can be done with writing some Java script, but I have never played with Java and I don't really have the time to teach myself.  If anyone can help with me a quick tutorial, or even the formula I should use, so that I can just plug and play, that would be super helpful.  If this is a time consuming issue, I would be interested in paying someone to do it for me. Thank you!

    Hi George,
    I was able to copy my data over to a fresh document, and now it works just fine....thank you so much for your insight and help!
    I have another question if you have a moment. 
    I am trying to do a simple calculation of start time and end time for my employees.  Do I need to do this via a javascript, and if so, what area in properties of the result field should I copy it to?  for the purpose of the script, the fields are as follows:
    DataField1 = start time
    DataField2 = end time
    DataField3 = total time
    I would like to use the h:MM tt format for my time fields if possible.
    I've attached a link to the file through my dropbox account, and you'll notice that I created three new fields at the top of the invoice just to test the time calculations before i mock up the whole document.
    Dropbox - Contractor Invoice Template (1).pdf
    Any help you can give me would awesome! 
    Thank you!!

  • Need help on a trigger

    I am using Oracle 9i. I tried to take a lot of the other fields out of this trigger so that the real problem could be seen. I am trying to create a trigger that cleans up a string field, then verifies the new character with a field in another table. Once they are equal it will grab that ID number and place it in required field. Below is what I have so far for the trigger.
    Table 1
    SP_id INTEGER
    TT_id INTEGER
    LEGACY VARCHAR2
    Table 2
    SID NUMBER (10)
    UID VARCHAR2
    DESCRIPTION VARCHAR2
    Table 3
    T_id INTEGER
    NAME VARCHAR2
    CREATE OR REPLACE TRIGGER ABC
    AFTER INSERT OR UPDATE
    ON 2
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
    IF (INSERTING)
    THEN
    INSERT INTO 1
    (SP_id,
    TT_id,
    LEGACY)
    VALUES (XXX_seq.NEXTVAL,
    substr(:New.description, 1, instr(translate(:New.description, '1234567890', '**********'),'*')-2) ,
    SUBSTR (:NEW.uid, 1, 30));
    END IF;
    END ABC;
    I need to take the parsed character field [substr(:New.description, 1, instr(translate(:New.description, '1234567890', '**********'),'*')-2) ,]
    then verify its value with table 3's NAME field. Once the correct name is found I need to grab the table3.T_id and place it in the TT_id in table 1. Should this all be done in a trigger or should I try to create a function that is then called out in the trigger? Any help, advice, or examples would be appreciated.

    Below I've done it using two different approaches:
    1) using triggers
    2) using an api
    I prefer using an api for mainly for performance reasons, but it's your call
    SQL> create table t1
      2  ( sp_id integer
      3  , tt_id integer
      4  , legacy varchar2(100)
      5  )
      6  /
    Tabel is aangemaakt.
    SQL> create table t2
      2  ( sid number (10)
      3  , u_id varchar2 (100)
      4  , description varchar2(100)
      5  )
      6  /
    Tabel is aangemaakt.
    SQL> create table t3
      2  ( t_id integer
      3  , name varchar2(100)
      4  )
      5  /
    Tabel is aangemaakt.
    SQL> create sequence xxx_seq start with 1 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> create or replace trigger abc
      2  after insert on t2
      3  for each row
      4  declare
      5    l_t3_id t3.t_id%type;
      6  begin
      7    begin
      8      select t3.t_id
      9        into l_t3_id
    10        from t3
    11       where t3.name = substr(:new.description, 1, instr(translate(:new.description, '1234567890', '**********'),'*')-2)
    12      ;
    13    exception
    14    when no_data_found
    15    then
    16      null;
    17    when too_many_rows
    18    then
    19      null;
    20    end
    21    ;
    22    insert into t1
    23    ( sp_id
    24    , tt_id
    25    , legacy
    26    )
    27    values
    28    ( xxx_seq.nextval
    29    , l_t3_id
    30    , substr (:new.u_id, 1, 30)
    31    );
    32  end abc;
    33  /
    Trigger is aangemaakt.
    SQL> insert into t3 values (1, 'abc')
      2  /
    1 rij is aangemaakt.
    SQL> insert into t3 values (2, 'xyz')
      2  /
    1 rij is aangemaakt.
    SQL> commit
      2  /
    Commit is voltooid.
    SQL> insert into t2 values (11, '12', 'abc 12345')
      2  /
    1 rij is aangemaakt.
    SQL> insert into t2 values (13, '14', 'pqr 65432')
      2  /
    1 rij is aangemaakt.
    SQL> insert into t2 values (15, '16', 'xyza9875123')
      2  /
    1 rij is aangemaakt.
    SQL> select * from t2
      2  /
           SID U_ID                           DESCRIPTION
            11 12                             abc 12345
            13 14                             pqr 65432
            15 16                             xyza9875123
    3 rijen zijn geselecteerd.
    SQL> select * from t1
      2  /
         SP_ID      TT_ID LEGACY
             1          1 12
             2            14
             3          2 16
    3 rijen zijn geselecteerd.This is the end of the trigger approach.
    From here on it's the api approach:
    SQL> rollback
      2  /
    Rollback is voltooid.
    SQL> drop trigger abc
      2  /
    Trigger is verwijderd.
    SQL> create package t2_dml
      2  as
      3    procedure create_t2_and_t1
      4    ( p_sid         t2.sid%type
      5    , p_u_id        t2.u_id%type
      6    , p_description t2.description%type
      7    );
      8  end t2_dml;
      9  /
    Package is aangemaakt.
    SQL> create package body t2_dml
      2  as
      3    procedure create_t2_and_t1
      4    ( p_sid         t2.sid%type
      5    , p_u_id        t2.u_id%type
      6    , p_description t2.description%type
      7    )
      8    is
      9      l_t3_id t3.t_id%type;
    10    begin
    11      insert into t2
    12      ( sid
    13      , u_id
    14      , description
    15      )
    16      values
    17      ( p_sid
    18      , p_u_id
    19      , p_description
    20      );
    21      begin
    22        select t3.t_id
    23          into l_t3_id
    24          from t3
    25         where t3.name = substr(p_description, 1, instr(translate(p_description, '1234567890', '**********'),'*')-2)
    26        ;
    27      exception
    28      when no_data_found
    29      then
    30        null;
    31      when too_many_rows
    32      then
    33        null;
    34      end
    35      ;
    36      insert into t1
    37      ( sp_id
    38      , tt_id
    39      , legacy
    40      )
    41      values
    42      ( xxx_seq.nextval
    43      , l_t3_id
    44      , substr (p_u_id, 1, 30)
    45      );
    46    end create_t2_and_t1
    47    ;
    48  end t2_dml;
    49  /
    Package-body is aangemaakt.
    SQL> exec t2_dml.create_t2_and_t1(11,'12','abc 12345')
    PL/SQL-procedure is geslaagd.
    SQL> exec t2_dml.create_t2_and_t1(13,'14','pqr 65432')
    PL/SQL-procedure is geslaagd.
    SQL> exec t2_dml.create_t2_and_t1(15,'16','xyza9875123')
    PL/SQL-procedure is geslaagd.
    SQL> select * from t2
      2  /
           SID U_ID                           DESCRIPTION
            11 12                             abc 12345
            13 14                             pqr 65432
            15 16                             xyza9875123
    3 rijen zijn geselecteerd.
    SQL> select * from t1
      2  /
         SP_ID      TT_ID LEGACY
             4          1 12
             5            14
             6          2 16
    3 rijen zijn geselecteerd.I hope this helps.
    Regards,
    Rob.

  • I need help with a trigger mutating a table

    I'll add the trigger I have written now at the bottom. Here is the problem that I have. We have employees and their families in an individual table.
    A family is indicated by matching client, branch, and emp_id. An employee is indicated by individual_num = 1. All other numbers indicate family members. A person is determined to be terminated by having a date other than '2299/12/31' (It's a varchar(10) and very very wrong. Don't ask...) in the termination date column.
    A family member can be terminated in the system independent of the rest of there family. However, if an employee is terminated then all active family members need the termination date set to the same date as the employee. If that termination date is then changed for the employee all family members with the same date need to have their dates updated.
    I understand why this causes table mutation but I need a work around. Any ideas? Please...
    CREATE OR REPLACE TRIGGER INDIV_EMP_TERM
    after update on INDIVIDUAL
    for each row
    begin
    if ( :new.INDIVIDUAL_NUM = 1 and :old.TERMINATION_DATE <> :new.TERMINATION_DATE ) then
    if ( :old.TERMINATION_DATE = '2299/12/31' ) then
         update INDIVIDUAL
              set TERMINATION_DATE = :new.TERMINATION_DATE
              where CLIENT = :new.CLIENT
              and BRANCH = :new.BRANCH
              and EMP_ID = :new.EMP_ID
              and INDIVIDUAL_NUM <> 1
              and TERMINATION_DATE = '2299/12/31';
         else
         update INDIVIDUAL
              set TERMINATION_DATE = :new.TERMINATION_DATE
              where CLIENT = :new.CLIENT
              and BRANCH = :new.BRANCH
              and EMP_ID = :new.EMP_ID
              and INDIVIDUAL_NUM <> 1
              and TERMINATION_DATE = :old.TERMINATION_DATE;
         end if;
    end if;
    end;

    Try your code like this below .It will help you to eliminate the mutating error
    create or replace PACKAGE test_update IS
    type row_type is table of rowid index by binary_integer;
    v_row row_type ;
    v_index binary_integer ;
    v_num integer := 0 ;
    flag integer := 1 ;
    END;
    create or replace trigger test_up
    before update
    on test123
    begin
    select USR_ID
    into test_update.v_num
    from test123 ;
    dbms_output.put_line ( 'before update '||test_update.v_num );
    test_update.v_index := 0;
    end ;
    create or replace trigger test_up_after
    after update
    on test123
    begin
    dbms_output.put_line ( test_update.v_index );
    test_update.flag := 0 ;
    for i in 1 .. test_update.v_index loop
    update test123
    set UPD_BY = nvl(test_update.v_num ,0),
    UPD_DATE = sysdate
    where rowid = test_update.v_row(i) ;
    end loop ;
    test_update.flag := 1 ;
    test_update.v_index := 0;
    end ;
    create or replace trigger test_1
    after update on test123
    for each row
    begin
    -- dbms_output.put_line ( 'after update test flag '||test_update.flag );
    if test_update.flag = 1 then
    test_update.v_index := test_update.v_index + 1 ;
    test_update.v_row(test_update.v_index) := :old.rowid ;
    end if ;
    end ;

  • Need help writing a toString

    I have no idea how to go about writing the toString method for this code. I have to print the array that provides the longest sequence. I would appreciate your help.
    Here is the code: import java.io.FileReader;
    import java.io.IOException;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Scanner;
    import java.util.StringTokenizer;
    class Grid
        private int [ ][ ] mainGrid;
        public Grid( String file ) throws IOException
            FileReader fr = new FileReader( file );
            Scanner scan = new Scanner( fr );
            ArrayList<ArrayList<Integer>> numR = new ArrayList<ArrayList<Integer>>( );
            while( scan.hasNextLine( ) )
                String line = scan.nextLine( );
                StringTokenizer st = new StringTokenizer ( line );
                String number;
                ArrayList<Integer> numC = new ArrayList<Integer>( );
                while( st.hasMoreTokens( ) )
                    number = st.nextToken( );
                    int num = Integer.parseInt(number);
                    numC.add(num);      
                numR.add( numC );
            int height = numR.size();
            int width = numR.get( 0 ).size();
            mainGrid = new int [height][width];
            for(int i = 0; i < height; i++)
                for( int j = 0; j < width; i++)
                    mainGrid [ i ][ j ] = numR.get( i ).get( j );
        private class Position
            private int row;
            private int col;
            public Position( int r, int c )
                r = row;
                c = col;
            public List<Position> getAdjacents( )
                int lowRow = row != 0 ? row - 1 : 0;
                int lowCol = col != 0 ? col - 1 : 0;
                int highRow = row != mainGrid.length - 1 ? row + 1 : mainGrid.length - 1;
                int highCol = col != mainGrid[ 0 ].length - 1 ? col + 1 : mainGrid[ 0 ].length - 1;
                List<Position> result = new ArrayList<Position>( );
                for( int r = lowRow; r <= highRow; r++ )
                    for( int c = lowCol; c <= highCol; c++ )
                        if( r != row || c != col )
                            result.add( new Position( r, c ) );
                return result;
            public boolean equals( Object other )
                if( ! ( other instanceof Position ) )
                    return false;
                Position rhs = (Position) other;
                return row == rhs.row && col == rhs.col;
            public int getValue( )
                return mainGrid [ row ][ col ];
            public String toString( )
                return "(" + row + "," + col + ")";
        public Position newPosition( int r , int c )
            return new Position( r, c );
        // Public driver
        public List<Position> getSequence( )
             List<Position> sequence = new ArrayList<Position>( );
             for( int r = 0; r < mainGrid.length - 1; r++)
                  for( int c = 0; c < mainGrid[ 0 ].length - 1; c++)
                       sequence = getSequence( new Position( r, c ));          
             return sequence;
        // Recursive routine
        private List<Position> getSequence( Position pos )
          List<Position> adj = pos.getAdjacents( );
          if( adj.size( ) == 0)
               List<Position> seq = new ArrayList<Position>( );
               seq.add( pos );
               return seq;
          List<Position> maxSeq = null;
          for( Position p: adj)
               List<Position> currentSeq = getSequence( p );
               if( currentSeq.size( ) < maxSeq.size( ))
                    maxSeq = currentSeq;
          maxSeq.add( pos );
          return maxSeq;
        public String toString( )
             StringBuffer sb = new StringBuffer( );
              return new String( sb );
    class MaxSubsequence
        public static void main( String [ ] args )
            try
                 System.out.println( new Grid( "numbergrid1.txt" ));
            catch( IOException e)
                 System.err.println( "Error opening file");
    }

    Call your getSequence method from the toString
    method. This gives you a List. Take a look at the
    methods of List to see how you can iterate
    over the list. Then look at the StringBuffer/Builder
    class and see how you can add those elements (plus
    any other formatting and words) to the final string.ok, i think i may be getting it a bit more. I don't need to use a loop at all?
    I can just call the getSequence method, use a toArray to return the sequence and append the sequence to the new string?

  • I need help writing an if then statement Java Script.

    In the Text Field Properties box I see the Calculate tab where I think that the form can do a logic (IF/THEN) function if I can place the correct Java Script code into the form. Unfortunately; I do not know how to write in Java Script.
         - I have a form with a field identifier called BACompnayAddress (this is the field where they would enter their address).
         - I then have a form field with two radials that says "Is the shipping address the same as the business Address" - "Yes" and "No" (the form identified for the radials is SASame.
    What I am trying to accomplish:
         - If they click Yes, I would like the Shipping Address field (field identifiier ShippingAddressAddress) to fill in the information found in BACompanyAddress and if they click No leave the  field blank to be filled out by the person filling out the form.
    I appreciate any help.
    Thanks,
    Brett

    If that's what it does, that is exactly what you said it needs to do. You said niothing about what should cause it to go back to frame 1.  If you want it to go back to frame 1 with a ROLL_OUT event, then you would add a listener for that. If you want something else to trigger it to go back, then you just need to work that out.
    The only time I can see where an if/else would be needed is if you want it to change frames for every rollover such that if it is in frame 1, then go to frame 2, and vice versa the next time you rollover it.

  • Need help writing formula to count checked boxes

    This is probably a no brainer for you experts but I am making a spreadsheet for scoring a test and I have put in check boxes. Beside in the adjacent cells to the cells with check boxes I have placed the values that correspond to those check boxes. I want to be able to format a cell to do several things.
    First I need to link the adjacent values to the check box cell that it corresponds to.
    Then I need to format a cell to
    1. Count the number of boxes that have been checked.
    2. Display the values that are linked to cells if the total is 10 or under
    3. Display text that relates to the values that are linked to the cells.
    Your help is greatly appreciated.
    Shane

    The Pickler wrote:
    In answer to your first question. Each question is multiple choice and my layout is chosen to mimick the test itself for easy scoring.
    So I take this to mean that it is only valid to have one check per row.
    Second, if there are more than 10 I want it left blank.
    Right now, it is simpler to have this behave the the other way, in that it eliminates a complicating special case.
    So here's a screen shot of what I have on this:
    !http://img227.imageshack.us/img227/6263/questionairesummarywo1.png!
    Let me discuss this and explain some of the changes I made to your initial attempt.
    (1) Since I presumed one check per row, you can see in the "Responses" table I switched over to this type of data entry. This has several advantages and, most importantly, was key in clarifying my thoughts downstream. It does not permit the invalid multi-check per row and can be more readily entered via keyboard. The use of A,B,C,D for the choices is arbitrary; they could be 1,2,3,4 or any other distinct set of 4. If you ever want to simultaneously evaluate several questionnaires this can be accommodated better by adding additional columns to this table.
    (2) The references associated with each question's choices are encoded in the "Key" table. This table can be squirreled away on another sheet dedicated to questionnaire configuration and remain out of harm's way while entering response data. The column headings must correspond with the answer designations used in the "Responses" table.
    (3) The "Tally" table is purely for the computation of the "Summary". It allows both the number of each type of reference to be computed and the listing of the references. Since it is purely computational, it should be hidden away on another sheet.
    (4) The "Descriptions" table is where the association of references and the statements is expressed. Since, like the "Key" table, it is likely edited infrequently, this too should be squirreled away on the questionnaire configuration sheet.
    (5) Finally, the "Summary" table display the counts of each reference type and zero to ten of the references and associated statements. Currently, this shows as many as the first 10 because, as stated above, it avoids a complicating special case and is displayed elegantly via this filtered table (which avoid displaying the unused reference rows). The count is always the total count, even if it is exceeds ten.
    Third, since I don't know the first thing about writing formula's I guess I need to have you hold my hand through this process or teach me some basics. Please.....if your kind and willing enough to do so.
    As there are more than a couple of formulas here, the least time consuming way to explain them is simply to upload this Numbers document to a place you (or anyone else who is interested) can download it. Explore it for yourself and feel free to ask any questions you have about it or how to modify it to better suite your needs.
    You will find that the file contains three sheets. What is presented here resides solely on the third sheet. The first two sheets can safely be ignored/deleted, but I have left them in as they represent two earlier attempts (the first only partial, the second, more complete) at a solution. Some may find them interesting, perhaps containing good techniques for other problems.
    [Questionnaire Summary Numbers Document|http://www.mediafire.com/?1125t9nm9xm|Click to download a zip archive]
    This will take you to a page that will allow you to download the file directly (I apologize for any of this free hosting site's advertisements that you might find offensive). Click on the link in the yellow region on the mid-left part of the page. If all goes well, the zip will download and automatically unarchive into the Numbers document "QuestionnaireSummary.numbers". Let me know if you have trouble.

  • Need help with creating trigger using instead of insert.

    Hi all,
    I am trying to create a trigger that can read the inserted Mail data from table1 and check if the Mail data matches the Mail data from table2. If the Mail data matches the Mail data from table2 it will get the EmpID from table2 and insert it into table1
    column EmpID. 
    Here are table2 columns:
    EmpID (int) Mail(varchar) Mail2(varchar)
    101 [email protected] [email protected]
    102 [email protected] [email protected]
    table1 columns 
    EmpID (int)(primary key) Mail(varchar) Mail2(varchar)
    If I insert [email protected] into table1 column Mail, I would like it to get the value for the EmpID from table2 before actually inserting the record into table1, by matching the Mail from table1 = Mail from table2.
    I am using ASP.Net to insert the records into Mail and Mail2.
    How can I achieve that?
    I appreciate any help.

    There should be two SQL statements in the stored procedure in order to accomplish the task?
    Ideally you need to include logic as a part of your insert procedure itself. You should have a standard insert stored procedure which should include this logic and should be used for all inserts.
    Also if EmpID field has to have a non NULL value always you may better off creating a foreign key constraint from Table1 to Table2 on EmpID column to enforce the Referential Integrity.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • Can't open itunes on windows 7 32bit

    I can't open itunes 10.7 on my laptop with opera system windows 7 ultimate 32bit

  • Numeric error in a function

    Hi there! ...got a problem with a Function I wrote... after several iterations the Program stops while executing it with a larger number than before (had values between -1 and 1 before, than I get the value 7167943,57300470185652922197670142674731) M

  • Verizon Web Mail doesn't work Thru Third Party Internet providers including Time Warner Cable

    A few weeks ago, my Verizon Web Mail would not download on Outlook via TIme Warner Cable.  Verizon tech acknowledged this and then said it was an Apple issue.   No response.  TWC says its Verizon issue

  • Attributes not showing up in POV

    In the process of developing some financial reports, it looks like I hosed the display of attributes on my admin account somehow. The scenario is as follows: On several reports I have attributes setup in the POV, when I originally developed the repor

  • Elementary Search Help

    Hi All I ve created a elementary search help for my ABAP program, the elementary search help contains 2 fields which has values in it,, im selecting one of the filed in parameter selection, but i want the other field to be populated in a variable in