Constraint based on existing rows in table

I have the following situation:
a table something like:
create table allow_only_one_in_set
(item_number number,
set_number number,
special_case number(1));
I want to write a constraint that will not allow you to add a row with special_case set to 1 if there already exists a special_case = 1 in that set.
I think a check constraint cannot work because it would require a sub-query. Correct?
Would the way to do this be to use a trigger, and if so how best to pass a message back to the user (already have a special case in this set)?
Thanks,
Jon

You'd want to create a conditional unique constraint.
For this example i've assumed that set number can only have 1 special case with a value of 1, you can change the unique index as needed....
ME_XE?create table allow_only_one_in_set
  2  (
  3     item_number    number,
  4     set_number     number,
  5     special_case   number(1)
  6  )
  7  ;
Table created.
Elapsed: 00:00:00.01
ME_XE?
ME_XE?create unique index allow_only_one_in_set_U_01 on allow_only_one_in_set
  2  (
  3     case when special_case = 1 then set_number else null end
  4  );
Index created.
Elapsed: 00:00:00.00
ME_XE?insert into allow_only_one_in_set values (1, 1, 1);
1 row created.
Elapsed: 00:00:00.00
ME_XE?insert into allow_only_one_in_set values (1, 1, 0);
1 row created.
Elapsed: 00:00:00.00
ME_XE?insert into allow_only_one_in_set values (1, 1, 1);
insert into allow_only_one_in_set values (1, 1, 1)
ERROR at line 1:
ORA-00001: unique constraint (TFORSYTH.ALLOW_ONLY_ONE_IN_SET_U_01) violated
Elapsed: 00:00:00.04
ME_XE?insert into allow_only_one_in_set values (1, 1, 0);
1 row created.
Elapsed: 00:00:00.01
ME_XE?

Similar Messages

  • Create form based on existing row : advice from specialists

    hello,
    i've coded a "create form" based on a row selected by the user.
    this create form displays the same information as the selected row (except for the primary key which is a sequence trigger-calculated) the user can then modify any field and then commit the creation. It's quicker for tables with many columns since the user will override only several fields instead of setting every field one by one.
    I've done it this way :
    1) creation of a createCustomMethod() in my ViewObject implementation class and published it in the client interface.
    2) drag and drop the method as a command button on the selection list page
    3) set the action of the command button to the navigation case value to open the create form when the button is clicked.
    the code of the createCustomMethod() is the following
    public void createCustomMethod() {       
    Row currentRow = this.getCurrentRow();
    Row newRow = this.createRow();
    newRow.setAttribute("Attribute1",currentRow.getAttribute("Attribute1"));
    newRow.setAttribute("Attribute2",currentRow.getAttribute("Attribute2"));
    /* more initialization code here */
    this.insertRow(newRow);
    this.setCurrentRow(newRow);
    it works fine but as i'm knew to ADF BC is this a good solution ? are there any drawbacks to it ?
    thanks
    -regards

    what's the advantage of exposing it in the application module rather than in the view object ?
    Message was edited by:
    user562278
    i've tried implementing the method in the application module (i had to call the findViewObject() now) but the "Row currentRow = vo.getCurrentRow();" instruction throws a NPE.

  • Add row based on previous row in table control?

    Dear all,
    I have a table control with some rows. Every row contains one button. On button click i want to add another row with dirrerent data. I want to add content based on button text or another columns (ex text views text,) based on this text view, I have to add row. One button can click any no of times. On every click i want to add row, but desired position and content should be based on button click.  Any help in doing this??
    Cheers,
    Venkys.

    Refer to these old threads referring this table and button problem.
    Adding rows to table
    How to create different rows in table or in ALV?
    and for the current scenario what you can do is ...
    in the eventhandler of the button click .
    find out the row number by using the code to read index.
    then based upon that add the element in the node at the desired position.
    finding the row number
      data indx type i.
          DATA lo_el TYPE REF TO if_wd_context_element.
          lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    indx = lo_el->get_index( ).
    and the adding the element at the desired position say n
        DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.
        lo_nd_zdealer = wd_context->get_child_node( name = 'DEALER' ).
    data ls_str type  wd_this->element_dealer.
       ls_str-id = '00023445'.
       ls_str-name = 'sarbjeet'.
       ls_str-location = 'hosiarpur'.
       ls_str-status = '0001'.
       lo_nd_zdealer->bind_structure( new_item = ls_str
       set_initial_elements = abap_false
       index = n
    thanks
    sarbjeet singh

  • Constraint based on existing values for a column in the table

    I have a table as follows
    create table MS_FAV_ACCT
    NICKNAME VARCHAR2(50) not null,
    ACCOUNT VARCHAR2(6) not null,
    SUB_ACCOUNT VARCHAR2(3) not null,
    DETAIL VARCHAR2(4) not null,
    ICID VARCHAR2(3) not null,
    SEGMENT VARCHAR2(2) not null,
    PRIMARY_ACCT VARCHAR2(1) not null
    I want to have a constraint such that there can be only one row with PRIMARY_ACCT ='Y' there could be multiple rows with value 'N'.
    I have put a CHECK constraint on this column to check for values Y or N but I want to be able to check this condition too that only one row can have PRIMARY_ACCT as Y .
    I saw a thread on this forum regarding using UNIQUE INDEX with case when but didnt understand how I could use it in my case.
    Could anyone please help?

    You only want to have 1 row in the table with an identifier of 'Y'?
    That is what i understood, in which case you can use something like this.
    ME_XE?create table MS_FAV_ACCT
      2  (
      3     NICKNAME VARCHAR2(50) not null,
      4     ACCOUNT VARCHAR2(6) not null,
      5     SUB_ACCOUNT VARCHAR2(3) not null,
      6     DETAIL VARCHAR2(4) not null,
      7     ICID VARCHAR2(3) not null,
      8     SEGMENT VARCHAR2(2) not null,
      9     PRIMARY_ACCT VARCHAR2(1) not null
    10  );
    Table created.
    Elapsed: 00:00:00.03
    ME_XE?CREATE UNIQUE INDEX MS_FAV_ACCT_U01 ON MS_FAV_ACCT (CASE WHEN  PRIMARY_ACCT = 'Y' THEN 1 ELSE NULL END);
    Index created.
    Elapsed: 00:00:00.01
    ME_XE?
    ME_XE?INSERT INTO MS_FAV_ACCT VALUES('ONE','TWO', 'U','I','X','A','N');
    1 row created.
    Elapsed: 00:00:00.00
    ME_XE?INSERT INTO MS_FAV_ACCT VALUES('ONE','TWO', 'U','I','X','A','Y');
    1 row created.
    Elapsed: 00:00:00.00
    ME_XE?INSERT INTO MS_FAV_ACCT VALUES('ONE','TWO', 'U','I','X','A','N');
    1 row created.
    Elapsed: 00:00:00.01
    ME_XE?INSERT INTO MS_FAV_ACCT VALUES('ONE','TWO', 'U','I','X','A','Y');
    INSERT INTO MS_FAV_ACCT VALUES('ONE','TWO', 'U','I','X','A','Y')
    ERROR at line 1:
    ORA-00001: unique constraint (TFORSYTH.MS_FAV_ACCT_U01) violated

  • How to apply the constraint ONLY to new rows

    Hi, Gurus:
       I have one question as follows:
       We need to migrate a legacy system to a new production server. I am required to add two columns to every table in order to record who updates the row most recently through triggers, and  I should apply not null constraint to the columns . However, since legacy system already has data for every table, and old data does not have value for the 2 new columns. If we apply the constraint, all of existing rows will raise exception. I wonder if there is possibility to apply the constraint ONLY to new rows to come in future.
    Thanks.
    Sam

       We need to migrate a legacy system to a new production server. I am required to add two columns to every table in order to record who updates the row most recently through triggers, and  I should apply not null constraint to the columns .
    The best suggestion I can give you is that you make sure management documents the name of the person that came up with that hair-brained requirement so they can be sufficiently punished in the future for the tremendous waste of human and database resources they caused for which they got virtually NOTHING in return.
    I have seen many systems over the past 25+years that have added columns such as those: CREATED_DATE, CREATED_BY, MODIFIED_DATE, MODIFIED_BY.
    I have yet to see even ONE system where that information is actually useful for any real purpose. Many systems have application/schema users and those users can modify the data. Also, any DBA can modify the data and many of them can connect as the schema owner to do that.
    Many tables also get updated by other applications or bulk load processes and those processes use generic connections that can NOT be tied back to any particular system.
    The net result is that those columns will be populated by user names that are utterly useless for any auditing purposes.
    If a user is allowed to modify a table they are allowed to modify a table. If you want to track that you should implement a proper security strategy using Oracle's AUDIT functionality.
    Cluttering up ALL, or even many, of your tables with such columns is a TERRIBLE idea. Worse is adding triggers that server no other purpose but capture useless infomation but, because they are PL/SQL cause performance impacts just aggravates the total impact.
    It is certainly appropriate to be concerned about the security and auditability of your important data. But adding columns and triggers such as those proposed is NOT the proper solution to achieve that security.
    Before your organization makes such an idiotic decision you should propose that the same steps be taken before adding that functionality that you should take before the addition of ANY MAJOR structural or application changes:
    1. document the actual requirement
    2. document and justify the business reasons for that requirement
    3. perform testing that shows the impact of that requirement on the production system
    4. determine the resource cost (people, storage, etc) of implementing that requirement
    5. demonstrate how that information will actually be used EFFECTIVELY for some business purpose
    As regards items #1 and #2 above the requirement should be stated in terms of the PROBLEM to be solved, not some preconceived notion of the solution that should be used.
    Your org should also talk to other orgs or other depts in your same org that have used your proposed solution and find out how useful it has been for them. If you do this research you will likely find that it hasn't met their needs at all.
    And in your own org there are likely some applications with tables that already have such columns. Has anyone there EVER used those columns and found them invaluable for identifying and resolving any actual problem?
    If you can't use them and their data for some important process why add them to begin with?
    IMHO it is a total waste of time and resources to add such columns to ALL of your tables. Any such approach to auditing or security should, at most, be limited to those tables with key data that needs to be protected and only then when you cannot implement the proper 'best practices' auditing.
    A migration is difficult enough without adding useless additional requirements like those. You have FAR more important things you can do with the resources you have available:
    1. Capture ALL DDL for the existing system into a version control system
    2. Train your developers on using the version control system
    3. Determining the proper configuration of the new server and system. It is almost a CERTAINTY that settings will get changed and performance will suffer even though you don't think you have changed anything at all.
    4. Validating that the data has been migrated successfully. That can involve extensive querying and comparison to make sure data has not been altered during the migration. The process of validating a SINGLE TABLE is more difficult if the table structures are not the same. And they won't be if you add two columns to every table; every single query you do will have to specify the columns by name in order to EXCLUDE your two new columns.
    5. Validating the performance of the app on the new system. There WILL BE problems where things don't work like they used to. You need to find those problems and fix them
    6. Capturing the proper statistics after the data has been migrated and all of the indexes have been rebuilt.
    7. Capturing the new execution plans to use a a baseline for when things go wrong in the future.
    If it is worth doing it is worth doing right.

  • Add column to user defined type based on existing table

    Hello guys,
    I am trying to compile my function which returns a user defined type based on existing table. Throughout the initializing process though my query returns one additional column - SCORE(1). Here is my package:
    create or replace
    PACKAGE STAFF_AGENCY_PKG AS
    TYPE TYPE_SEEKER_TABLE IS TABLE OF TOSS.SEEKER%ROWTYPE;
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED;
    END STAFF_AGENCY_PKG;
    create or replace
    PACKAGE BODY STAFF_AGENCY_PKG
    AS
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED
    IS
    R_TBL TYPE_SEEKER_TABLE; -- to be returned
    BEGIN
    FOR R IN(
    SELECT Seeker.SEEKER_ID,
    Seeker.FIRSTNAME,
    Seeker.LASTNAME,
    Seeker.NATIONALITY,
    Seeker.ISELIGIBLE,
    Seeker.BIRTHDATE,
    Seeker.ISRECIEVEEMAILS,
    Seeker.HIGHESTDEGREE,
    Seeker.ETHNICITY,
    Seeker.GENDER,
    Seeker.ISDISABILITY,
    Seeker.DISABILITY,
    Seeker.CV,
    Seeker.PASSWORD,
    Seeker.PREFFERED_CITY,
    SEEKER.EMAIL,
    SEEKER.JOB_PREFERENCES_ID,
    SCORE(1)
    FROM SEEKER Seeker
    WHERE CONTAINS(CV, '<query>
    <textquery lang="ENGLISH" grammar="context">' ||
    GET_RELATED_CATEGORIES(IN_KEYWORD) ||
    '</textquery>
    <score datatype="INTEGER"/>
    </query>', 1) > 0
    LOOP
    PIPE ROW(R); --Error(38,10): PLS-00382: expression is of wrong type
    END LOOP;
    RETURN;
    END GET_SEEKERS;
    END STAFF_AGENCY_PKG;
    How do I need to amend my user type in order to suffice?
    Oracle Release 11.2.0.1.0
    Many thanks in advance!

    >
    How do I need to amend my user type in order to suffice?
    >
    You will need to create two new TYPEs. One that has all of the columns of the TOSS.SEEKER table and the new SCORE column and then a TYPE that is a table of the first type.
    See the Example 12-22 Using a Pipelined Table Function For a Transformation in the PL/SQl language reference
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm#i53120
    Here is the first part
    -- Define the ref cursor types and function
    CREATE OR REPLACE PACKAGE refcur_pkg IS
      TYPE refcur_t IS REF CURSOR RETURN employees%ROWTYPE;
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
    FUNCTION f_trans(p refcur_t)
          RETURN outrecset PIPELINED;
    END refcur_pkg;
    CREATE OR REPLACE PACKAGE BODY refcur_pkg IS
      FUNCTION f_trans(p refcur_t)
       RETURN outrecset PIPELINED IS
        out_rec outrec_typ;
        in_rec  p%ROWTYPE;
      BEGINModify
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;to include all of the columns you need. Unfortunately you will have to manually list all of the columns of the TOSS.SEEKER table. If you expect to need this same structure in other places you should create them as SQL types instead of PL/SQL types.
    This example should be enough to show you how to change your code to do something similar.

  • Would like to update a table based on 1 row being returned from a join.

    Hi, hope you guys can help.
    I'd like to update 1 rown that is returned from a join query. The following code returns 1 row.
    SELECT pt.*, pv.* FROM
    --SELECT pt.template_id, pt.property_code, pv.value FROM
    property_template pt inner join
    property_value pv on pt.template_id = pv.template_id
    WHERE property_code = '500_URL';
    Based on the row returned i'd like to update a column called VALUE from the property_value table.
    I've tried the following code but it updates every row in the value column.
    update property_value set value = 'http://10.14.64.170:8080/XTI/UPLOAD'
    where exists
    SELECT pt.*, pv.* FROM
    --SELECT pt.template_id, pt.property_code, pv.value FROM
    property_template pt inner join
    property_value pv on pt.template_id = pv.template_id
    WHERE property_code = '500_URL'
    Any help with this would be appreciated.

    You need this
    UPDATE property_value   pv
       SET value            = 'http://10.14.64.170:8080/XTI/UPLOAD'
    WHERE EXISTS            (
                             SELECT 1
                               FROM property_template   pt
                              WHERE pt.template_id      = pv.template_id
                                AND property_code       = '500_URL'
                            );Regards
    Arun

  • How add primary key constraint to already existing table with data

    I want apply primary key constraint to already existing table with data
    is there any command or way to do

    Alternatively, assuming you want to ensure uniqueness in your primary key column you can do this:
    alter table <table name> add constraint <cons name> primary key (col1,col2) exceptions into <exception_table>
    If the altter table statement fails this will populate the EXCEPTIONS table with the rows that contain duplicate values for (col1,col2).
    You will need to run (or get a DBA to run) a script called UTLEXCPT.SQL (which will be in the $ORACLE_HOME/rdbms/admin directory) if you don't already have an EXCEPTIONS table.
    Cheers, APC

  • How to check if a constraint existed in the table and drop it?

    Hi all,
    I want to drop a constraint from a table. I do not know if this constraint already existed in the table. So I want to check if this exists first.
    Below is my query:
    DECLARE
    itemExists NUMBER;
    BEGIN
         itemExists := 0;
    SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
    FROM ALL_CONSTRAINTS
    WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
    IF itemExists > 0 THEN
    ALTER TABLE my_table DROP CONSTRAINT my_constraint;
    END IF;
    END;
    Here is the error I got when I executed the above query:
    ORA-06550: line 11, column 5: PLS-00103: Encountered the symbol "ALTER" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
    Please help me with this!
    Greatly appreciate!
    Khoi Le

    Yes, I also tried to put the pl-sql in the Execute Immediate. However, the error still remains
    EXECUTE IMMEDIATE 'DECLARE
    itemExists NUMBER;
    BEGIN
         itemExists := 0;
    SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
    FROM ALL_CONSTRAINTS
    WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
    IF itemExists > 0 THEN
    ALTER TABLE my_table DROP CONSTRAINT my_constraint;
    END IF;
    END';
    I execute the above code via running the batch file.
    Here is the error after I ran the batch file:
    ORA-06550: line 11, column 5:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    ( begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    continue close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe purge
    The symbol "lock was inserted before "ALTER" to continue.
    ORA-06550: line 11, column 53:
    PLS-00103: Encountered the symbol "DROP" when expecting one of the following:
    . , @ in <an identifier>
    <a double-quoted delimited-identifier> partition subpartition
    ORA-06512: at line 2117
    I can not manually drop it. I need to do this via running an update script file.
    Is there a different way to accomplish this?
    Thank you very much!

  • How to populate a table based on a row selection from another table.

    Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
    By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
    ganesh

    I understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
    I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
    Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
    Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
    "EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
    This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
    Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
    Hope this helps.

  • Creating multiple tables based on existing tables

    Hi,
    I have to create 60 tables based on existing 60 tables. Instead of creating one by one how can I create all 60 at once.
    The current 60 tables are named FY11_ACC1, FY11_ACC2, FY11_SALES1, FY11_SALES2 ...... , but all 60 tables start with FY11. I need to create the same structured tables but with FY12 names like FY12_ACC1, FY12_ACC2, FY12_SALES1, FY12_SALES2 .....
    Currently I am using "create table FY12_ACC1 as select * from FY11_ACC1 where 1=0". Is there a way I can write all of them in one query?
    Thanks for your time and help.

    ssk1974 wrote:
    Hi,
    I have to create 60 tables based on existing 60 tables. Instead of creating one by one how can I create all 60 at once.
    The current 60 tables are named FY11_ACC1, FY11_ACC2, FY11_SALES1, FY11_SALES2 ...... , but all 60 tables start with FY11. I need to create the same structured tables but with FY12 names like FY12_ACC1, FY12_ACC2, FY12_SALES1, FY12_SALES2 .....
    Currently I am using "create table FY12_ACC1 as select * from FY11_ACC1 where 1=0". Is there a way I can write all of them in one query?
    Thanks for your time and help.Well, i'm assuming FY = Fiscal Year and 11 = 2011 and then ACC1 = Account #1.
    From the sounds of things, your design isn't likely "correct'.
    If you'd care to delve in to the requirements a little bit ... what you have and what you need (business speak wise) there are no shortage of experts here that i'm sure would be happy to help you.
    If you're stuck with what you've got (or don't care to change your 'design') and all you care about is achieving that please disregard this message.

  • Deleting rows from table based on value from other table

    Hello Members,
    I am struck to solve the issue said below using query. Would appreciate any suggestions...
    I have two tables having same structures. I want to delete the rows from TableA ( master table ) with the values from TableB ( subset of TableA). The idea is to remove the duplicate values from tableA. The data to be removed are present in TableB. Catch here is TableB holds one row less than TableA, for example
    Table A
    Name Value
    Test 1
    Test 1
    Test 1
    Hello 2
    Good 3
    TableB
    Name Value
    Test 1
    Test 1
    The goal here is to remove the two entries from TableB ('Test') from TableA, finally leaving TableA as
    Table A
    Name Value
    Test 1
    Hello 2
    Good 3
    I tried below queries
    1. delete from TestA a where rowid = any (select rowid from TESTA b where b.Name = a.Name and a.Name in ( select Name from TestB ));
    Any suggestions..
    We need TableB. The problem I mentioned above is part of process. TableB contains the duplicate values which should be deleted from TableA. So that we know what all values we have deleted from TableA. On deleted TableA if I later insert the value from TableB I should be getting the original TableA...
    Thanks in advance

    drop table table_a;
    drop table table_b;
    create table  table_b as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual;
    create table table_a as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual union all
    select 'Test' ,1 from dual union all
    select 'Hello' ,2 from dual union all
    select 'Good', 3 from dual;
    /* Formatted on 11/23/2011 1:53:12 PM (QP5 v5.149.1003.31008) */
    DELETE FROM table_a
          WHERE ROWID IN (SELECT rid
                            FROM (SELECT ROWID rid,
                                         ROW_NUMBER ()
                                         OVER (PARTITION BY name, VALUE
                                               ORDER BY NULL)
                                            rn
                                    FROM table_a a
                                   WHERE EXISTS
                                            (SELECT 1
                                               FROM table_b b
                                              WHERE a.name = b.name
                                                    AND a.VALUE = b.VALUE))
                           WHERE rn > 1);
    select * from table_a
    NAME     VALUE
    Test     1
    Hello     2
    Good     3Edited by: pollywog on Nov 23, 2011 1:55 PM

  • How to variable exit read table based on selected row on weblayout ??

    Hi All,
    Greeting,
    I have a question regarding IP.
    I have report where I can choose the line. I've already been able to catch the selected row there using ABAP Planning Function.
    The requirement is to change some value from other customized table ( not info cube ) based on selected row.
    So when user's selecting data and pressing a button, the idea is to prompt a variable where they can see the old value, and they can entry the new value. But to query that value, I need to select based on the values the row.
    My Question is how user-exit in variable can read selected row in web planning layout especially it happens when I_step = 1 ?
    Or the other idea is to get the value on that customized table and put it in text web item as the old value. How can I fetch data from table and put it in text web item ?
    Thanks a lot and have a good day,

    Hi.
    My Question is how user-exit in variable can read selected row in web planning layout especially it happens when I_step = 1 ?
    I think there is no way to do it. I_STEP=1 called before the report shows the data.
    But may be the next approach could help you:
    1. when you select line you can use command for populating variables according to selected line. let's say yohave selected line with costcenterr XXX so you can populate variable (let's say Z_CC) with selected value.
    2. create FOX that reads variable Z_CC value and calls any function module with customized table and variable value (you can use CALL FUNCTION statement within FOX and pass to it variable value).
    This is just an idea of some direction - may be you can take it and develope to required result.
    Regards.

  • Adding Constraints to an existing table

    Hi,
    I've consulted the forum, documentation, the internet and text books but cannot find the correct SQL command to add constraints to an existing table
    Obviously I would
    ALTER TABLE Turkey ADD CONSTRAINT Whitemeat
    But what comes next is puzzling, the values of column Whitemeat can be any value other than Dinner, Gravy, Pumpkin, or Sauce
    Any assistance would be great
    Thank You

    Hi,
    user8998591 wrote:
    Sorry,
    This is what I'm trying to run
    ALTER TABLE TURKEY add
    CONSTRAINT TURKEY_WHITEMEAT_CK CHECK WHITEMEAT NOT IN ('Dinner', 'Gravy', 'Pumpkin', 'Sauce');And this is the error message I am getting
    Error report:
    SQL Error: ORA-00906: missing left parenthesis
    00906. 00000 -  "missing left parenthesis"
    *Cause:   
    *Action:Thank you for your assistanceSee the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3001.htm#sthref5176] for the correct syntax.
    The condition after the keyword CHECK has to be in parentheses.
    To add a CHECK constraint to an existing table, I think you have to modify the column.
    ALTER TABLE turkey
    MODIFY  ( whitemeat     CONSTRAINT     turkey_whitemeat_ck
                     CHECK          ( whitemeat NOT IN ( 'Dinner'
                                                , 'Gravy'
                                          , 'Pumpkin'
                                          , 'Sauce'
         )                    )             );Edited by: Frank Kulash on Jan 22, 2010 4:37 PM

  • How to create new or delete the existing row in the grid....

    hi my friends...
    i am developing report using Reuse_alv_grid_display...
    my requirement is... At runtime
              1.  i may create new row on the grid (empty row inwhich  i may enter the data).
              2.  i may delete a existing row in the grid
              3.  i may edit the existing data...
    then i have to trace the modification in the grid in one internal table...
    how can i get into this.....
    note:
    i have some idea to edit the existing record in the grid and trace those modification,
    but i don't know abt how to create new or delete the existing row....
    can you give me some idea...

    Hi deva,
    write a class which implemets these methods
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    To handle the toolbar on alv
         handle_toolbar
           FOR EVENT toolbar OF cl_gui_alv_grid
              IMPORTING e_object e_interactive,
    To handle the buttons on the alv grid
         handle_user_command
           FOR EVENT user_command OF cl_gui_alv_grid
           IMPORTING e_ucomm.
    endclass.
    Now Implement these methods.
    CLASS lcl_event_receiver IMPLEMENTATION.
    To handle the toolbar on alv
      METHOD handle_toolbar.
       DATA ls_toolbar  TYPE stb_button.
        CLEAR gs_toolbar.
        MOVE 3 TO gs_toolbar-butn_type.
        APPEND gs_toolbar TO e_object->mt_toolbar.
        CLEAR gs_toolbar.
        PERFORM icon_create USING 'ICON_INSERT_ROW' gs_toolbar-icon.
        MOVE text-010 TO gs_toolbar-function.
        MOVE text-012 TO gs_toolbar-quickinfo.
        MOVE ' ' TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object->mt_toolbar.
        CLEAR gs_toolbar.
        PERFORM icon_create USING 'ICON_DELETE_ROW' gs_toolbar-icon.
        MOVE text-011 TO gs_toolbar-function.
        MOVE text-013 TO gs_toolbar-quickinfo.
        MOVE ' ' TO gs_toolbar-disabled.
        APPEND gs_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.
       METHOD handle_user_command.
    In this form, check the function code(e_ucomm has the function code), based on that do the required action.
    as i said yesterday(i.e for appending a row, deleting a row, modifying a row)
        PERFORM user_command USING e_ucomm.
      ENDMETHOD
    endclass.
    Before calling the alv method, create a object of this class.
    DATA :
          gref_event_receiver  TYPE REF TO lcl_event_receiver,
          gv_tables_alv          TYPE REF TO cl_gui_alv_grid.
          CREATE OBJECT gref_event_receiver.
          SET HANDLER   gref_event_receiver->handle_user_command
                        FOR gv_tables_alv.
          SET HANDLER   gref_event_receiver->handle_toolbar
                        FOR gv_tables_alv.
    check this program for event handling, it is the similar way
    demo_abap_objects_events
    Hope u understood this.
    Regards,
    Prasant
    reward if helpful

Maybe you are looking for

  • External hard drives and MacBook

    Sorry, I don't know if this is posted in the right section. I have a MacBook connected with an external hard drive. I'm not sure what it takes for an external hard drive to crash, but I unplug it until I need to pull something from it or backup files

  • Vendor balance still open after cash payment

    Hello,         I am doing cash payments to Vendors for the the month of April in T.code FBCJ,  even after saving and posting the payment of Vendor, the balance is still showing "OPEN" in ledger display, my configuration is correct related to cash jou

  • Airport and network problems after recent update

    I want to know if someone is aware of what went wrong with the latest OS updates, all my computers forget my local wireless connection and sometimes I'm connected to my co-workers unprotected red. Airport just won't do its job. This issue is really f

  • Help noob! HelloWorld Servlet

    Using Windows & Sun Java System Application Server Platform Edition 9.0_01 I just would like to get such result: http://localhost:8080/HelloWorld?name=MYNAME Where HelloWorld is my simple servlet displays MYNAME HelloWorld.java: import java.io.*; imp

  • Transferring drivers over to new install

    Hi! I'm a recent switcher (5 months), and since I've moved to OS X, I've installed, and subsequently uninstalled, untold piles of crap. Therefore I've decided that together with the external enclosure I'm getting for one of my hard drives, I'm going