6 Replies Latest reply: Jan 14, 2013 4:50 AM by 980086 RSS

    Inserting data into a table,from a form developed from a view

    980086
      Hi ,

      I have created a form using a view- con_V(columns:- name , id , suppl , profile , discard).
      This con_V has been created using 2 tables-
      1. land (name , id , ...............)
      2. con (id , discard , .........)
      discard is a check box.When user will select any check box that should update the CON(2nd one) table column DISCARD as N, Not the con_V view. From form which ever data user will select , that ID will be the unique.using ID I have to update the CON table.
      Should I write ON-INSERT,ON-UPDATE,ON-LOCK trigger ? Can you please provide with code?

      Thanks in advance....
        • 1. Re: Inserting data into a table,from a form developed from a view
          Fran├žois Degrelle
          Hello,

          +"...Can you please provide with code?..."+

          ON-INSERT:
          Insert into ....
          ON-UPDATE:
          Update ....
          ON-DELETE:
          Delete ....
          ;-))

          Francois
          • 2. Re: Inserting data into a table,from a form developed from a view
            Askdineshsingh
            You can write a trigger when-checkbox-change
            --------------------------------------------------------------------------
            BEGIN

            UPDATE CON SET DISCORD=:BLOCK.DISCORD WHERE ID=:BLOCK.ID;

            IF SQL%ROWCOUNT> 0 THEN
            COMMIT;
            ELSE
            ROLLBACK;
            END IF;
            EXCEPTION WHEN OTHERS THEN MESSAGE(SQLERRM);ROLLBACK;
            END;
            --------------------------------------------

            *Please mark this helpful/correct if it helped you....
            thanks*
            • 3. Re: Inserting data into a table,from a form developed from a view
              Andreas Weiden
              You shouldn't write any code, but simply configure the DML-data-target to be your base-table:
              - change the blocks "Key-Mode" from Automatic to non-updateable
              - Mark your unique ID-column with "Primary Key" = Yes
              - choose the Name of the Basetable CON as "DML-data-target" in the advanced database options
              - Maybe you have to create an ON-LOCK-trigger (try without and see what happens)
              • 4. Re: Inserting data into a table,from a form developed from a view
                980086
                Thanks a lot for your help.....
                Just to add to this , I would like to say that there will be 230 countries will be shown & a check box for each one.User can select 20-30 countries at a time.....its not that it will be always a single entry...
                So in this case will the solution work?
                • 5. Re: Inserting data into a table,from a form developed from a view
                  980086
                  I have executed the form.but I dont know why I am unable to select any check box.when I am clicking on any check box for any country its not getting ticked.nothing is happening.And also its not getting updated in the CON table.
                  I have made id as primary key,DML-data-target as CON and key mode as non- updatable.
                  I have set value when checked as Y & unchecked as N for discard item(check box).....
                  please help..
                  • 6. Re: Inserting data into a table,from a form developed from a view
                    980086
                    I have created an OK push button.after selecting the check boxes user will click on OK button,then this will get updated in CON table.
                    So I have given this code in WHEN-BUTTON-PRESSED trigger under OK button.

                    BEGIN

                    UPDATE CON SET DISCORD=:BLOCK.DISCORD WHERE ID=:BLOCK.ID;

                    IF SQL%ROWCOUNT> 0 THEN
                    COMMIT;
                    message('The selected countries will not be shown');
                    message('The selected countries will not be shown');
                    ELSE
                    message('No country is selected ');
                    message('No country is selected');     
                    ROLLBACK;
                    END IF;
                    EXCEPTION WHEN OTHERS THEN MESSAGE(SQLERRM);ROLLBACK;
                    END;

                    Please tell me will this work?
                    And also kindly help me why I am unable to select or deselect any check box when I run the form.
                    Thanks in advance.....