Must insert and update day.3 billion rendered here are 3 approaches...

..... Please let me know what is the best... SUGGESTIONS AND IMPROVISATIONS WILL BE REALLY APPRECIATED!

Approach 1 in bulk then insert update

PROCEDURE MIGRATE_TWO_YRS_HOURLY_DATA

IS

v_proc_nameVARCHAR2 (60);
v_NameVARCHAR2 (60): = "MIGRATE_TWO_YRS_HOURLY_DATA";
v_actionVARCHAR2 (200);
v_errorsVARCHAR2 (200);

BEGIN

v_proc_name: = v_name;
v_action: = ' mwatch MIGRATE_TWO_YRS_HOURLY_DATA. Table SUMMARY_HOURLY';
INSERT / * + append * / INTO mwatch. SUMMARY_HOURLY_NCIS
(s_MTRID,
S_UOM,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE)
SELECT
s_MTRID,
s_MTRCH,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE
FROM mwatch. SUMMARY_HOURLY
WHERE the trunc (S_DATETIME) BETWEEN TO_DATE('01-01-2013','MM-DD-YYYY')
AND TO_DATE('09-30-2015','MM-DD-YYYY');

commit;

Mwatch UPDATE. SUMMARY_HOURLY_NCIS
SET S_UOM = DECODE(S_UOM,'1','KWH','2','KVARH');

commit;

EXCEPTION
WHILE OTHERS THEN
v_action: = ' * failure * ' | v_action;
v_errors: = "Sql Error Code: ' |" SQLCODE. "SQL error message: ' | SQLERRM;

mwatch_common_ncis.mwatch_log_error (v_proc_name, v_action, v_errors);

END MIGRATE_TWO_YRS_HOURLY_DATA;

Approach 2 with the cursor

PROCEDURE MIGRATE_TWO_YRS_DAILY_DATA

IS

v_proc_nameVARCHAR2 (60);
v_NameVARCHAR2 (60): = "MIGRATE_TWO_YRS_DAILY_DATA";
v_actionVARCHAR2 (200);
v_errorsVARCHAR2 (200);
I haveNUMBER: = 0;
CURSOR daily_cur IS
SELECT
s_MTRID,
s_MTRCH,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE,
s_PEAK,
s_SEAS
FROM mwatch. SUMMARY_DAILY
WHERE the trunc (S_DATETIME) BETWEEN TO_DATE('01-01-2013','MM-DD-YYYY')
AND TO_DATE('09-30-2015','MM-DD-YYYY');

BEGIN

v_proc_name: = v_name;
v_action: = ' mwatch MIGRATE_TWO_YRS_DAILY_DATA. Table SUMMARY_DAILY';
C1 in daily_cur
LOOP
INSERT INTO mwatch. SUMMARY_DAILY_NCIS
(s_MTRID,
S_UOM,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE,
s_PEAK,
s_SEAS)
VALUES
(C1.s_MTRID,
decode (C1.s_MTRCH, '1', 'KWH', '2', 'KVARH', NULL);
C1.s_DATETIME,
C1.s_USAGE,
C1.s_COST,
C1.s_RATE,
C1.s_PEAK,
C1.s_SEAS);
MOD IF (i, 10000) = 0 THEN-Commit every 10000 records
COMMIT;
END IF;
END LOOP;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
v_action: = ' * failure * ' | v_action;
v_errors: = "Sql Error Code: ' |" SQLCODE. "SQL error message: ' | SQLERRM;

mwatch_common_ncis.mwatch_log_error (v_proc_name, v_action, v_errors);

END MIGRATE_TWO_YRS_DAILY_DATA;

Insert mass approach 3 with an instruction BOX in the select itself

PROCEDURE MIGRATE_TWO_YRS_DAILY_DATA

IS

v_proc_nameVARCHAR2 (60);
v_NameVARCHAR2 (60): = "MIGRATE_TWO_YRS_DAILY_DATA";
v_actionVARCHAR2 (200);
v_errorsVARCHAR2 (200);

BEGIN

v_proc_name: = v_name;
v_action: = ' mwatch MIGRATE_TWO_YRS_DAILY_DATA. Table SUMMARY_DAILY';
INSERT / * + append * / INTO mwatch. SUMMARY_DAILY_NCIS
(s_MTRID,
S_UOM,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE,
s_PEAK,
s_SEAS)
SELECT
s_MTRID,
CASE s_MTRCH
WHEN 1 THEN "KWH" / * kWh * /.
WHEN 2 THEN "KVARH" / * KiloVarHour * /.
END AS S_UOM,
s_DATETIME,
s_USAGE,
s_COST,
s_RATE,
s_PEAK,
s_SEAS
FROM mwatch. SUMMARY_DAILY
WHERE the trunc (S_DATETIME) BETWEEN TO_DATE('01-01-2013','MM-DD-YYYY')
AND TO_DATE('09-30-2015','MM-DD-YYYY');

commit;

EXCEPTION
WHILE OTHERS THEN
v_action: = ' * failure * ' | v_action;
v_errors: = "Sql Error Code: ' |" SQLCODE. "SQL error message: ' | SQLERRM;

mwatch_common_ncis.mwatch_log_error (v_proc_name, v_action, v_errors);

END MIGRATE_TWO_YRS_DAILY_DATA;

I'd go with approach 3 as it is likely to be most effective.  As others have said, a slow by slow approach, especially with engages in the middle of the loop is a very bad idea.  The first approach and then insert updated is better, but why do two operations when you can do it in one as for approach 3.

The only change I could do would be to change the predicate to something like:

where s_datetime > = to_date ('01-01-2013', ' mm-dd-yyyy') and

s_datetime<>

which could be beneficial if s_datetime is indexed.

Whether or not this should be done in a stored procedure is a somewhat different matter.

John

Tags: Database

Similar Questions

  • Create triggers in the table, sequence, insert and update with "model"?

    It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:

    1.), I add the table to the logic model

    2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary

    3.) then I have the new table to add

    -but

    I would then have auto-DDL of to be synchronized to database:

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    -Create triggers for insert and update

    -l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.

    -activate the triggers

    Each of them following the same naming convention.

    Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.

    rgrds Paavo

    Hi Paavo,

    most of the steps can be made in one or other way

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.

    fields of record defined in the table, so that each table has them

    You can add the same set of columns in all tables with the transformation script 'model of Table... ».

    You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.

    Philippe

  • Combining insert and update to a form?

    Hello

    I am a developer web amateur who is new to dynamic Web sites, php and dreamweaver. I am currently working on a project that uses many forms to send data to a database.

    Data that are inserted must also be available to update if necessary. so I need currently 2 versions of each form 1 to insert and the other for the update.

    Is it possible to use a single form for insert and update, instead of using 2 forms 1 for each function. This would help reduce the level of duplication on the site.

    If so is anyway to do this in Dreamweaver? or could someone point me to an example of how this can be achieved.

    Thank you all

    Thanks for the information, disappointing that Dreamweaver cannot handle it, but at least I know where I am...

    Looks like that's what I need... http://forums.Adobe.com/message/1927405

    Once again thanks for your help

  • apostrophe problem for insert and update pages

    I read in the book "Dreamweaver MX dynamic Applications" that a solution must be placed in the ASP to insert code and form fields record updated to replace the apostrophes by their equivalent html entity character (') before its entry in a database do not have SQL wrong interpret the entered text. How would you say this hotfix is essential because I tested my form with apostrophes and have not gotten into trouble yet?

    > I read in the book "Dreamweaver MX dynamic Applications" as a fix
    > should
    > place in the ASP code for insert and update the fields of the registration form to
    > replace
    > apostrophes with their equivalent html entity character (') before his
    > entry
    > in a database do not have SQL wrong interpret the entered text. How
    > Essentials
    > would you say this fix is that I tested my form with single quotes and
    > have
    > not got any trouble yet?

    If you are user of Jack and sending it to the db in plaintext in
    the query, and then people can use techniques of SQL injection basically destroy
    your database:

    http://en.Wikipedia.org/wiki/SQL_injection

    So, Yes, it's a pretty serious problem.

    -Darrel

  • How to modify and update a line later was inserted and updated in the doDML() method?

    Mr President

    Jdev worm is 12.2.1

    How to modify and update a line later was inserted and updated in the doDML() method?

    I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

    Method 1-first row in managed bean

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
            RowSetIterator rsi = dciter.getRowSetIterator();        
            Row lastRow = rsi.last();        
            int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
            Row newRow = rsi.createRow();        
            newRow.setNewRowState(Row.STATUS_NEW);        
            rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
            rsi.setCurrentRow(newRow);
            
            BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
            RowSetIterator rsi1 = dciter1.getRowSetIterator();        
            Row lastRow1 = rsi1.last();        
            int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
            Row newRow1 = rsi1.createRow();        
            newRow1.setNewRowState(Row.STATUS_NEW);        
            rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
            rsi1.setCurrentRow(newRow1); 
            
            
        }
    


    Method of doDML() of line 2 seconds in the entityImpl class


        protected void doDML(int operation, TransactionEvent e) {        
            setAmount(getPurqty().multiply(getUnitpurprice()));
           
            if (operation == DML_INSERT)  
                       {          
                         insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                           }
                           
                           if(operation == DML_UPDATE)
                           {
                               
                           updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                           }                                       
            super.doDML(operation, e);
        }
    
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
       ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                      System.out.println("sql= " + sql);    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }  
                  
                  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
       + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                      System.out.println("sql= " + sql);      
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }
    

    Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

     <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
    

    This button update the first line added by bean managed, but the second row remains unchanged.

    Please help how to update the two lines with the same button or something else.

    Concerning

    DML_UPDATE will call only if there is some change data attributes.

    I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

    I assume the update statement should look like:

      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
      {
        PreparedStatement stat = null;
        try
        {
          String sql =
            "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
            "' where VID='" + value1 + "'";
          System.out.println("sql= " + sql);
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • You want to capture update dates, with trigger on a view to refresh quickly materialized. But trigger on MV consider inserting and updates are inserts only.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    I create the structure of the table like that.

    create table test1 (a primary key, b (2) char number, date c, d varchar2 (10), date of e);

    create table test2 (number of ab, cd (2) tank, date of the ef, gh varchar2 (10), date of the ij, kl varchar2 (100));

    Create materialized view log on test1;

    create materialized view fast refresh test1_v on commit in select * from test1;

    I have create a trigger of the sample

    CREATE OR REPLACE TRIGGER test1_trig

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    lr_test2. AB: =: NEW.a;

    lr_test2. CD: =: NEW.b;

    lr_test2. GH: =: NEW.d;

    IF THE INSERTION

    THEN

    lr_test2. EF: = SYSDATE;

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'INSERT ';

    INSERT INTO test2

    VALUES lr_test2;

    ELSIF UPDATE

    THEN

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'UPDATE ';

    UPDATE test2 = lr_test2 ab WHERE = LINE: OLD.a;

    ELSIF REMOVAL

    THEN

    DELETE FROM test2

    AB = WHERE: old.a;

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    COMMIT;

    END test1_trig;

    /

    So, if check you my code,.

    When I insert EF = SYSDATE, IJ = SYSDATE.

    Update EF is not changed, IJ = SYSDATE.

    So I like to capture their insertion and update dates.

    But if updates or insert arrives on the materialized table. The trigger themselves as an INSERT only.

    So how do you capture the updates?

    I use the statemnet with out merger with performance and also able to capture the update dates.

    CREATE OR REPLACE TRIGGER test1_trig_merge

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    IF THE REMOVAL

    THEN

    DELETE FROM test2

        AB = WHERE: old.a;

    ELSIF INSERTION

    THEN

    MERGE INTO test2 one

    B using (SELECT 1 FROM DUAL)

    WE (ab =: new.a)

    WHEN MATCHED

    THEN

    UPDATE the VALUE ab =: NEW.a.

    CD =: NEW.b,

    GH =: NEW.c

    IJ = SYSDATE,

    KL = "Update"

    AB WHERE =: old.a

    WHEN NOT MATCHED

    THEN

    INSERTING VALUES (: NEW.a,)

    : NEW.b,.

    : NEW.c.

    : NEW.d,.

    : NEW.e,.

    "INSERT");

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    END test1_trig_merge;

    /

    DISPLAY ERRORS;

  • Add error causing senior in 4.2.1 when inserting and updating same time

    Hi all

    I have problems with the top to add a line in a table.

    There is already a thread here on how to add the line above in table form in version 4.0.

    We have recently upgraded to version 4.2.1 Apex.

    Since then we have question while inserting a new line and update an existing line at the same time, and then click Save button causing the error below:

    Current version of the data in the database has changed since the user initiated the update process. version of current line identifier = "xxxxxx" line application version identifier = "xxxxxx".

    But insert a new record and update an existing record works well separately with an error.


    Here's the code to add the line at the top of page header HTML

    <script language="javascript" type="text/javascript">
    function addRowTop()
    {
    apex.widget.tabular.addRow();
    apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last()
    .insertBefore(apex.jQuery(apex.widget.tabular.gTabForm).
    find(".highlight-row").first());
    }
    </script>
    

    If I use by default addRow so absolutely no problem to insert and update at the same time.

    Here is the example of work in the workspace apex.

    Looks like a bug to me.

    Can any of the Oracle team please see this and let us know if it needs a patch.

    Thank you

    REDA

    Not sure that I consider this a bug since you are somehow hacking the default functionality of the APEX.  Maybe you could add a feature request 'Add Top line' to https://apex.oracle.com/vote

    It seems that you hit some enhancments to safety that have been made to the tabular forms. You should be able to work around it by putting the new lines to the bottom of the form before submitting the page.

    Create a dynamic action based on the click of the submit button.

    Event: click on

    Selection type: button

    Button: SUBMIT (Submit)

    Condition: - no requirement.

    Add real action to run the JavaScript Code:

    Action: run the JavaScript Code

    Fire when the result of the event is: true

    Fire on Page load: [disabled]

    Code:

    apex.jQuery(apex.widget.tabular.gTabForm).find("input[value=''][name='frowid']").closest(".highlight-row")
     .insertAfter(apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last());
    

    Add a real action to send the page:

    Action: send the Page

    E: Nam request/buttonSUBMIT

    -Jeff

  • INSERT and UPDATE audit generating more lines expected in $ AUD

    Environment:

    Oracle 11.2.0.3 EE on Solaris

    I had a request for verification of the INSERT and UPDATE on the activities of all the tables in a particular schema. It was in anticipation of a request that will live and the owner wanted to see a 'typical' of some test users activity.

    Here are the steps I took:
    alter system set audit_trail=DB_EXTENDED scope=spfile;
    
    Bounce the instance
    
    audit INSERT table, UPDATE table by USERX;
    I also "audit_sys_operations = TRUE' so I know I'll take some SYS audit data in $ AUD as well, but I can ask around those."

    My question is that I see several connections from the application server with "LOGIN" and "LOGOUT" actions and I don't know why they are appearing in the table of AUD $.

    Is it because I have auditing enabled for inserts and updates on all THE tables for USERX and opening operations and logoff do I/O in tables that are not owned by USERX under logon logoff procedure?

    I'm a newbie audit and the docs I read not answered this question.

    I just found an article on the value of 'SESSION_REC' of ACTION_NAME and I need to change my check to "by access. I'll change that and see what happens, but it shouldn't change my question.

    Thanks much for any help!

    -gary

    Hello

    I have the SYS activities audited but I never said anything about the session auditing for this particular user.
    

    "audit session;" check all successful and failed connections to and disconnections of the database, regardless of the user, by session

    Is there a way to confirm what has been turned on for auditing?
    

    You can check with the following query

    Select * from dba_stmt_audit_opts;
    Select * from dba_priv_audit_opts;

    You can also check out the link below for more deatails
    http://psoug.org/reference/auditing.html

  • FORALL using insert and update

    Hello

    I want to use FORALL for insert and update at the same time in a single FORALL...

    It's like...

    FORALL INDX IN 1... record. Count
    insert into Table values (record (i)); - Table is updated with some values in the column
    Update Table
    Set table.col10 = (select val table11 where table11.column = record.count (i))
    -update the Table by taking the value of some other column table... passing the parameter each time...

    Help, please...

    Refer to this

    http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/forall_statement.htm

    But why PL SQL?

    You can do this with the Merge statement

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_9016.htm

    Mezaber

  • Insert and update server behaviors in the same form

    I have a php form that is inserted into a table and then update another table. I have the form of inserting the record first and then I want to update the other table. I'm starting to learn and understand PHP, but I don't know how to have the update function to run after that it inserts the records. I guess that's something like if you insert this disc, then update this record and then go to the redirect page. I know this goes to redirect page after it inserts the record, but I don't know how to tell him not to go to the $insertGoTo. I want him to run the following update function and then go to the $insertGoTo and not the $updateGoTo. Thanks in advance for any help.

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());
      $updateGoTo = "purchases.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
      
    }
    
    

    PHP code is executed from top down and is controlled by the conditional statements ('if' blocks). To achieve what you want, you need to combine the conditional statements that control the insert and update server behaviors and to move the redirect to the end of the code. Amend as follows:

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
    
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());  
    
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
    
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    
  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • How to write insert and update blocks about with an if

    Hai All

    How to write an insert and update block education about with in an if

    I had a condition Ie

    If the time is between 0630 and 1030


    then

    Insert into Daily_attend
    ----


    Update Daily_attend set

    -----

    Concerning

    Srikkanth.M

    There is nothing preventing you to do this:

    BEGIN
      INSERT INTO x (mycolumn) VALUES ('A');
    
      UPDATE x
      SET mycolumn = 'B'
      WHERE mycolumn = 'A';
    
      COMMIT;
    END;
    /
    

    other than the fact that he seems a bit inefficient. Yet once you try to do, and why, is not clear.

    Can you put an IF statement in there to choose one way or the other under certain conditions? Yes. But I wonder if what you
    are actually trying to do is to reinvent the MERGE statement.
    http://www.morganslibrary.org/reference/merge.html

  • Limitation of Table inserts and updates.

    Hi friends,

    I learn Oracle PL/SQL.

    I need to create a table for audit purposes. I want the table to be updated only by a procedure and not by all users.

    I have also some paintings, where only a few columns must be accessible to insert or update to users. The remaining columns in this table may not be editable.

    How can I achieve this in Oracle PL/SQL. Help, please.

    Thank you

    Deepak

    I learn Oracle PL/SQL.

    I need to create a table for audit purposes. I want the table to be updated only by a procedure and not by all users.

    Place the table in diagram A. Do not give access to this table to other drawings.

    Create a procedure/package to diagram A - he can write/update the table has.

    Grant execute access to this procedure/package to other drawings.

    I have also some paintings, where only a few columns must be accessible to insert or update to users. The remaining columns in this table may not be editable.

    Something like

    grant update (col1, col2) on tableA to UserB;

    See GRANT

  • Help me in creating a trigger Insert and Update Options

    Hello

    Please help me in creating a trigger.

    My requirement is that, after insert or update on a Table, I want to launch an event.

    I have started this way, but does not know how to fully implement it.

    I have a dept table


    CREATE TRIGGER DepartmentTrigger
    INSERT AFTER on Dept
    BEGIN
    INSERT INTO mytable VALUES("123","Kiran");
    END DepartmentTrigger;


    Please tell me how I can put the update option also.

    Thanks in advance.

    Please tell me how I can put the update option also.

    Add "or update". ;-)

    Here are a few suggestions, but you definitely need to refer to the manual page that suggested the previous poster.

    CREATE OR REPLACE the TRIGGER DepartmentTrigger
    AFTER INSERT or Update ON Dept
    BEGIN
    INSERT INTO mytable VALUES(:new.) Dept 'DEPT ADDED OR CHANGED');
    END DepartmentTrigger;

    The "or replace" means that you can replace the shutter button as you develop without having to type in a drop statement each time. Just change and reissue your script over and over again until you get it right.

    The addition of "update or" or "Or remove" fact the trigger too much fire for these events. Note, you peut want separate triggers in different scripts and with different names for each event. You must decide whether your design is really the same thing either an insert or an update.

    : new. Dept, this is how you should refer to the vale has changed the Dept column (: old.) Dept is the previous value). I changed the double quotes in the string in the clause VALUES of apostrophes.

    Andy

  • Default values for Insert and Update

    What is the default way the current sysdate to a date on one column table when you perform an insert or update via a form? And related to this, what is the best way by default of the current user (APP_USER) for a varchar2 column when you perform an insert or update via a form?

    For these columns, I want to display in a report, but they must be hidden on the form, because I have the default app to sysdate and APP_USER values. However, when I tried to use the default values in table in 'the default UI settings' and using either: APP_USER or & APP_USER or SYSDATE, it shows that this literal value on the form (element is not hidden while to debug it). It does not show the actual value, I would, like "user1". Does make sense?

    Thanks for your help.
    -Reid

    I think that the triggers are the best device.

    Scott

Maybe you are looking for

  • Remove the old Apple ID

    My App Store won't let me update my applications... He said: I need my old Apple ID and I have not used this ID in a long time... And I made a new Apple ID a few months ago... And my App Store is the only thing that gives me problems... I do not know

  • DVD writer internal necessary for Satellite Pro 4340

    Hi everyone has found a suitable DVD INTERNAL burner (preferably double layer) which adapts and will work in a Satellite Pro 4340 or a laptop of the 4200 series? No answers please tell your machine is too old, etc. - they are not useful. I only want

  • final cut pro could run fast with macBook pro mid 2012?

    My MacBook pro (13-inch, mid-2012). Proc. 2.5 GHz intel Core i5. Memory 16GB 1600 MHz DDR3, startup disk Macintosh HD, 4000 1536 MB video card, could run fast with final cut pro X?

  • Laptop HP spectrum

    I need a reasonable sized screen to fix it on my HP laptop, spectrum.  Can anyone recommend one that is compatible?

  • Find delta table timestamp

    Hi, I have to determine an evolution of the timestamps by program.  See attachment.  Time elapsed between the elements of the array is about 8 seconds.  How would I find this delta?