Inserting rows using MERGE?

Hello

I have a table with 3 columns
ID SYSSKONTO SYSLS
1 268 1
2 270 1
3 270 2

I want to insert a new line every time I found a record where SYSLS = 1. I thought a MERGE statement would do but the insert can be done only if the match does not. What I tried

Fusion
in skontom t
a_l'_aide_de)
Select sysskonto,
sysls
of skontom
where sysls = 1
+ 7
on)
u.sysskonto = t.sysskonto
and
u.sysls = t.sysls
)
when matched
then insert (sysskontom, sysskonto, sysls)
values (cic.skontom_seq.nextval, u.sysskonto, 11)

is not working, but I have no idea to change it to "no match."

Probably, I think to complicated, so any ideas to solve the task are appreciated.

Thank you
Carsten

Hello

Is this fair?

INSERT INTO skontom (sysskontom, sysskonto, sysls)
SELECT cic.skontom_seq.nextval, sysskonto, 11
FROM skontom
WHERE sysls = 1
;

Tags: Database

Similar Questions

  • inserting rows using pl sql

    Hi all

    I created a tabale to insert a number

    create the table loc_number (c1 number);

    now, I want to insert 10 lines in this table using pl sql.

    How can I do so using pl sql?

    Hello

    Yes it is possible.

    Why use loops here?

    (I guess, you need to practice this goal)

    begin
    
     for i in 1..10
     loop
    
       insert into loc_number
           values (i);
    
     end loop;
    
     commit;
    
    end;
    
  • find the most recent record inserted by using rowid

    Yes, I suspect that it is a bad idea!

    I work with an application that has been modelled incorrectly. a historical table of the status had been modeled with a primary key on a key of the company and the entry into force instead of the date of the end of the recording of the State. There is one status as possible at the same time.

    logic has been developed to insert new records of status with the dates of null terminator and then a trigger was provided that populated end dates except the one with the MAX (ROWID). so the hope is that ROWID will always get bigger.

    now, the database has been moved in environments of promotion using data pump. in our development environments, it always seems to work. but not in promotional customers environments.

    My question is: is there a setting associated with data pump that the client has used that does not respect the ROWID as it has in our development environment?

    I'm trying to determine if there is a way to continue to use the old code without immediately re-development.

    Thanks in advance for your comments.

    so the hope is that ROWID will always get bigger.

    It is an expectation that has no guarantee of being correct. He has a very good chance that a new line will have a lower value of the ROWID.

    My question is: is there a setting associated with data pump that the client has used that does not respect the ROWID as it has in our development environment?

    There is not this setting. Data pump just inserts rows into a table. Because we cannot guarantee that the next row will have a higher ROWID, then what you are looking for there is no.

    It is time to rethink this misguided approach.

    See you soon,.
    Brian

  • Inserted row is the same as the deleted row

    Hello

    I have another weird behavior with ADF I don't understand... When I delete a line in an af:table and then I insert a line, the insert row is identical to the deleted row. Here is what I do

    1. Go to the page, the table is loaded with a record from the database
    2. Remove the line, using a button that triggers the delete of the iterator method in links
    3. Insert a new line using a method defined in the Application module implementation java class. He defines himself as a methodAction in links
      1. The insert in my interface button calls a method in my java bean

    public void insertNewVariableScheduleRow(ActionEvent ae) {
            insertNewVariableScheduleRow((DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry());   
    }
    
    private Row insertNewVariableScheduleRow(DCBindingContainer bindings) {
            OperationBinding        method = bindings.getOperationBinding("insertNewVariableScheduleRow");          
            Map                     paramsMap;
            Row                     newRow;
    
            paramsMap = method.getParamsMap();  
            paramsMap.put("defaultValues", scheduleDefaultValues.toArray());
            method.execute();
            
            logger.log("(method.getErrors().size(): " +(method.getErrors().size()));
            
            newRow = (Row)method.getResult();
            
            return newRow;
    }
    

    The method in the * class AMImpl do:

    public Row insertNewVariableScheduleRow(int scheduleNo, int scheduleVersion, String declId, String[] defaultValues) {
            ViewObject  vo          = this.getDeclSchedCellUpdView();
            int         displOrder  = getVariableScheduleNextDisplayOrder();
            Row         row         = vo.createRow();
            
            row.setAttribute("DisplOrder",  displOrder);        
            row.setAttribute("DeclId",      declId +"");
            row.setAttribute("SchedVrsnNo", scheduleVersion +"");
            row.setAttribute("ScheduleNo",  scheduleNo +"");
            
            for(int i=0; i<defaultValues.length; i++) {
                    if(defaultValues[i] != null) {
                            row.setAttribute("Col" +String.format("%03d", i+1) +"Value", defaultValues[i]);
                    }
            }
    
            vo.insertRow(row);
            
            return row;
    }
    

    I use JDev 11.1.1.7

    Thank you for all your help

    What is property changeEventPolicy on the iterator parameters in your pageDef? (try to define this 'None')

    In addition, you can try to run the managed bean delete operation and then reset the State of the component with:

    RicheTableau yourTable =...

    yourTable.resetStampState ();

    AdfFacesContext.getCurrentInstance () .addPartialTarget (yourTable);

    Dario

  • RESTful service cannot insert data using PL/SQL.

    Hi all
    Spin: stand-alone 2.01 AL on OEL 4.8 in box a. VM
    Database Oracle 10.2.0.4 with Apex 4.2.0.00.27 on OEL4.8 in the VM B box.

    Measure of oracle.example.hr performed without problem Restful services.

    Cannot insert data using AL 2.0.1 but works on 1.1.4 AL.
    who uses the following table (under scheme: scott):
     
    create table json_demo ( title varchar2(20), description varchar2(1000) ); 
    grant all on json_demo to apex_public_user; 
    and procedure (scott diagram) below:
    CREATE OR REPLACE
    PROCEDURE post(
        p_url     IN VARCHAR2,
        p_message IN VARCHAR2,
        p_response OUT VARCHAR2)
    IS
      l_end_loop BOOLEAN := false;
      l_http_req utl_http.req;
      l_http_resp utl_http.resp;
      l_buffer CLOB;
      l_data       VARCHAR2(20000);  
      C_USER_AGENT CONSTANT VARCHAR2(4000) := 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
    BEGIN
      -- source: http://awads.net/wp/2005/11/30/http-post-from-inside-oracle/
      -- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
      -- rather than just returning the text of the error page.
      utl_http.set_response_error_check(false);
      -- Begin the post request
      l_http_req := utl_http.begin_request (p_url, 'POST', utl_http.HTTP_VERSION_1_1);
      -- Set the HTTP request headers
      utl_http.set_header(l_http_req, 'User-Agent', C_USER_AGENT);
      utl_http.set_header(l_http_req, 'content-type', 'application/json;charset=UTF-8');
      utl_http.set_header(l_http_req, 'content-length', LENGTH(p_message));
      -- Write the data to the body of the HTTP request
      utl_http.write_text(l_http_req, p_message);
      -- Process the request and get the response.
      l_http_resp := utl_http.get_response (l_http_req);
      dbms_output.put_line ('status code: ' || l_http_resp.status_code);
      dbms_output.put_line ('reason phrase: ' || l_http_resp.reason_phrase);
      LOOP
        EXIT
      WHEN l_end_loop;
        BEGIN
          utl_http.read_line(l_http_resp, l_buffer, true);
          IF(l_buffer IS NOT NULL AND (LENGTH(l_buffer)>0)) THEN
            l_data    := l_data||l_buffer;
          END IF;
        EXCEPTION
        WHEN utl_http.end_of_body THEN
          l_end_loop := true;
        END;
      END LOOP;
      dbms_output.put_line(l_data);
      p_response:= l_data;
      -- Look for client-side error and report it.
      IF (l_http_resp.status_code >= 400) AND (l_http_resp.status_code <= 499) THEN
        dbms_output.put_line('Check the URL.');
        utl_http.end_response(l_http_resp);
        -- Look for server-side error and report it.
      elsif (l_http_resp.status_code >= 500) AND (l_http_resp.status_code <= 599) THEN
        dbms_output.put_line('Check if the Web site is up.');
        utl_http.end_response(l_http_resp);
        RETURN;
      END IF;
      utl_http.end_response (l_http_resp);
    EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line (sqlerrm);
      raise;
    END;
    and execution in sqldeveloper 3.2.20.09 when it connects directly to box B as scott:
     
    SET serveroutput ON
    DECLARE
      l_url      VARCHAR2(200)   :='http://MY_IP:8585/apex/demo';
      l_json     VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
      l_response VARCHAR2(30000);
    BEGIN
      post( p_url => l_url, p_message =>l_json, p_response => l_response);
    END;
    leading to:
     
    anonymous block completed 
    status code: 200
    reason phrase: OK 
    with data inserted. 
    Installation using 2.0.1
       Workspace : wsdemo
     RESTful Service Module:  demo/
              URI Template:      test
                    Method:  POST
               Source Type:  PL/SQL
    and execution in sqldeveloper 3.2.20.09 when it connects directly to box B as scott:
     
    SET serveroutput ON
    DECLARE
      l_url      VARCHAR2(200)   :='http://MY_IP:8585//apex/wsdemo/demo/test';
      l_json     VARCHAR2(20000) := '{"title":"thetitle","description":"thedescription"}';
      l_response VARCHAR2(30000);
    BEGIN
      post( p_url => l_url, p_message =>l_json, p_response => l_response);
    END;
    leading to:
     
    status code: 500 
    reason phrase: Internal Server Error 
    
    Listener's log: 
    Request Path passes syntax validation
    Mapping request to database pool: PoolMap [_poolName=apex, _regex=null, _workspaceIdentifier=WSDEMO, _failed=false, _lastUpdate=1364313600000, _template=/wsdemo/, _type=BASE_PATH]
    Applied database connection info
    Attempting to process with PL/SQL Gateway
    Not processed as PL/SQL Gateway request
    Attempting to process as a RESTful Service
    demo/test matches: demo/test score: 0
    Choosing: oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as current candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true]
    Determining if request can be dispatched as a Tenanted RESTful Service
    Request path has one path segment, continuing processing
    Tenant Principal already established, cannot dispatch
    Chose oracle.dbtools.rt.resource.templates.jdbc.JDBCResourceTemplateDispatcher as the final candidate with score: Score [handle=JDBCURITemplate [scopeId=null, templateId=2648625079503782|2797815111031405, uriTemplate=demo/test], score=0, scope=SecurityConfig [constraint=none, realm=NONE, logonConfig=LogonConfig [logonForm=null, logonFailed=null]], originsAllowed=[], corsEnabled=true] for: POST demo/test
    demo/test is a public resource
    Using generator: oracle.dbtools.rt.plsql.AnonymousBlockGenerator
    Performing JDBC request as: SCOTT
    Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
    INFO: Error occurred during execution of: [CALL, begin
     insert into scott.json_demo values(/*in:title*/?,/*in:description*/?);
    end;, [title, in, class oracle.dbtools.common.stmt.UnknownParameterType], [description, in, class oracle.dbtools.common.stmt.UnknownParameterType]]with values: [thetitle, thedescription]
    Mar 28, 2013 1:29:28 PM oracle.dbtools.common.jdbc.JDBCCallImpl execute
    INFO: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" 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> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-id
    
    java.sql.SQLException: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" 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> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-id
    
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
            at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
            at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
            at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:505)
            at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:223)
            at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
            at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:205)
            at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1043)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
            at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3612)
            at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3713)
            at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4755)
            at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1378)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at oracle.ucp.jdbc.proxy.StatementProxyFactory.invoke(StatementProxyFactory.java:242)
            at oracle.ucp.jdbc.proxy.PreparedStatementProxyFactory.invoke(PreparedStatementProxyFactory.java:124)
            at oracle.ucp.jdbc.proxy.CallableStatementProxyFactory.invoke(CallableStatementProxyFactory.java:101)
            at $Proxy46.execute(Unknown Source)
            at oracle.dbtools.common.jdbc.JDBCCallImpl.execute(JDBCCallImpl.java:44)
            at oracle.dbtools.rt.plsql.AnonymousBlockGenerator.generate(AnonymousBlockGenerator.java:176)
            at oracle.dbtools.rt.resource.templates.v2.ResourceTemplatesDispatcher$HttpResourceGenerator.response(ResourceTemplatesDispatcher.java:309)
            at oracle.dbtools.rt.web.RequestDispatchers.dispatch(RequestDispatchers.java:88)
            at oracle.dbtools.rt.web.HttpEndpointBase.restfulServices(HttpEndpointBase.java:412)
            at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:162)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
            at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.doFilter(ServletAdapter.java:1059)
            at com.sun.grizzly.http.servlet.ServletAdapter$FilterChainImpl.invokeFilterChain(ServletAdapter.java:999)
            at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:434)
            at oracle.dbtools.standalone.SecureServletAdapter.doService(SecureServletAdapter.java:65)
            at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:379)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:196)
            at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            at java.lang.Thread.run(Thread.java:662)
    Error during evaluation of resource template: ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" 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> <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
       <an identifier> <a double-quoted delimited-id
    Please notify.
    Concerning
    Zack

    Zack.L wrote:
    Hi Andy,.

    Sorry, I forgot to post the Source that is used by the AL1.1.4 and the AL2.0.1.

    Source

    begin
    insert into scott.json_demo values(:title,:description);
    end;
    

    It is a failure during insertion?
    Yes, he failed in the insert using AL2.0.1.

    If the above statement produces the following error message:

    The symbol "" was ignored.
    ORA-06550: line 2, column 74:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
     
    

    That gives me to think that a character is not printable (notice how there is anything between the quotation marks - "") worked his way in your PL/SQL Manager. Note how the error is reported to correspond to a column 74 on line 2, line 2 of the block above has 58 characters, so a pure assumption somehow, there is extra space on line 2, which confuses the PL/SQL compiler, I suggest retype PL/SQL Manager manually and see if that solves the problem.

  • Error inserting rows in ADF object view by programming

    Hi try to insert rows from one different view to the other, following this example http://howtolearnadf.blogspot.com/2012/10/insert-rows-in-to-adf-view-object.html some how am not able to read my reviews I got the error in this ViewObject targetVO line = obj.getViewObject (); When I click on my button Add. I am jedeveloper 11.1.1.6.0 I created the public class UpdAppModuleImpl in my module of the application, I can see the view
    my log error is
    Caused by: java.lang.NullPointerException
         at OrgDetails.updAddMember(OrgDetails.java:1491)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:148)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:279)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:402)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1018)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:386)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         ... 38 more
    this is my code
        public void updAddMember(ActionEvent actionEvent) {
            // Add event code here...
            //Code to get the bindings for TargetVO :
               
                    DCBindingContainer bindings2 =
                       (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                        
                   JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("UpdAddedMember1");
                   ViewObject targetVO = obj.getViewObject();
    
    
              DCBindingContainer bindings =
                       (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding empIter =
                       bindings.findIteratorBinding("UpdAddedMember1Iterator");
    
            //SourceVO1Iterator is the iterator under Executables section for the SourceVO1 bindings.
    
                   RowSetIterator roleRSIters = empIter.getRowSetIterator();
                   RowSetIterator rs1 = roleRSIters.getRowSet().getViewObject().createRowSetIterator(null);
                   NameValuePairs nvp = null;
    
                   while (rs1.hasNext()) {
                       Key key = rs1.next().getKey();
                       Row r = rs1.getRow(key);           
                      
                       nvp = new NameValuePairs();
                       nvp.setAttribute("Username",r.getAttribute("Username"));
                       nvp.setAttribute("Firstname",r.getAttribute("Firstname"));
                       nvp.setAttribute("Surname",r.getAttribute("Surname"));
                       nvp.setAttribute("Emailaddress",r.getAttribute("Emailaddress"));
                       targetVO.createAndInitRow(nvp);
                    }
                  
                   rs1.closeRowSetIterator();
                   targetVO.getApplicationModule().getTransaction().commit();
        }
    }
    Published by: adf009 on 02/08/2013 11:17

    Edited by: adf009 2013-02-08 11:22

    adf009, a simple NPE?
    You know how to use a debugger?
    You already know that

                   JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("UpdAddedMember1");
    

    Returns a null value. What is the information you get from that?
    He told me that you misspelled the name of link 'UpdAddedMember1' or it does not exist in the page links.

    Then, you use "links" and "bindings2", which are equal. Meanaing you only need one of them.

    What is this code before:

    while (rs1.hasNext()) {
                       Key key = rs1.next().getKey();
                       Row r = rs1.getRow(key);
    ...
                      
    

    you are iterating over a set of rows with the rs1.next () and then jump to the already selected line by setting the line with row.getRow (key);

    while (rs1.hasNext()) {
                       Row r = rs1.next();
                      
    

    should do.

    Timo

  • Insert by using question FORALL

    Hi all, I'm trying to insert many rows using batch - FORALL mode... But when I run the following:

    declare 
    cursor C1 is select
               GL_CODE_COMBINATIONS_S.NEXTVAL
              ,ACCOUNT_TYPE
              ,s1,s2,s3,s4,s5,s6,s7 from XX_CC_SEGMENTS;
    type T_C1 is table of C1%ROWTYPE;
    rec1 t_c1;
    
    begin
    open C1;
    LOOP
      FETCH C1 bulk collect into REC1;
        FORALL I in REC1.first..REC1.last
          insert into XX_GL_CC  values(REC1(I));
    exit when c1%notfound;
    end LOOP;
    close c1;
    end;
    I received the error message:
    ORA-06550: line 14, column 19:
    PL/SQL: ORA-00947: not enough values
    As I am new with BULK COLLECT & FORALL, I guess I can't refer to "REC1" like that. Any ideas what to change?

    Thanks in advance,
    Bahchevanov.

    1. you don't need the LOOP. COLLECTION in BULK retrieves all THE rows in one shot.
    2. because REC1 (I) is a record, you MUST NOT use parenthesis in the VALUES clause:

    SQL> declare
      2  cursor C1 is select
      3             * from emp;
      4  type T_C1 is table of C1%ROWTYPE;
      5  rec1 t_c1;
      6
      7  begin
      8  open C1;
      9    FETCH C1 bulk collect into REC1;
     10  close c1;
     11      FORALL I in REC1.first..REC1.last
     12        insert into emp1 values(REC1(I));
     13  end;
     14  /
          insert into emp1 values(REC1(I));
                      *
    ERROR at line 12:
    ORA-06550: line 12, column 19:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 12, column 7:
    PL/SQL: SQL Statement ignored
    
    SQL> declare
      2  cursor C1 is select
      3             * from emp;
      4  type T_C1 is table of C1%ROWTYPE;
      5  rec1 t_c1;
      6
      7  begin
      8  open C1;
      9    FETCH C1 bulk collect into REC1;
     10  close c1;
     11      FORALL I in REC1.first..REC1.last
     12        insert into emp1 values REC1(I);
     13  end;
     14  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Inserting rows through the procedure of database

    Hello!
    I have a small dilemma. I have to insert rows in the database through pl/sql procedure table. I can't use entity objects, because the insertion is very specific, so it must be done through the procedure of database.
    What is the workflow for my case? Use view object with transient attributes the right way? I have to show form insertion (with entries for the database parameters), and then call my procedure to fill the db table. Where can I find more information on that? Everyone had similar cases? Any info?
    Best regards, Marko

    [Url http://download.oracle.com/docs/cd/E21764_01/web.1111/b31974/bcadveo.htm#sm0328] does help?

    John

  • Impossible to insert rows in the table

    My insert statement below is not correct, when I try to run, his encoutering error "table or view does not exist.

    Basically what I'm doing here collects the table name in THE variable that stores the name of the table in this variable. This variable, I use as a table. I know that's not the right way, please let me how can I insert rows in the complete table with the following code.

    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM model WHERE 1 = 2;
    DECLARE
    I HAVE INTEGER DEFAULT 1;
    S VARCHAR2 (50);
    Start
    for C (select TABLE_NAME IN s from USER_TABLES where TABLE_NAME like '% of the CABLE' and TABLE_NAME NOT like '% OLD' and the order of 0 > Num_ROWS by TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;

    dbms_output.put_line (c.table_name);
    end loop;
    end;



    The insert statement above is not correct. How can I write good way.

    Thank you.

    Best regards
    Arshad

    user13360241 wrote:
    My insert statement below is not correct, when I try to run, his encoutering error "table or view does not exist.

    Basically what I'm doing here collects the table name in THE variable that stores the name of the table in this variable. This variable, I use as a table. I know that's not the right way, please let me how can I insert rows in the complete table with the following code.

    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM model WHERE 1 = 2;
    DECLARE
    I HAVE INTEGER DEFAULT 1;
    S VARCHAR2 (50);
    Start
    for C (select TABLE_NAME IN s from USER_TABLES where TABLE_NAME like '% of the CABLE' and TABLE_NAME NOT like '% OLD' and order > 0 Num_ROWS of TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;

    dbms_output.put_line (c.table_name);
    end loop;
    end;

    The insert statement above is not correct. How can I write good way.

    Thank you.

    Best regards
    Arshad

    STMT: = "INSERT INTO TEMP SELECT * FROM ';"

    STMT: = STMT. S;
    IMMEDIATELY EXECUTE STMT;

  • Generate the insert statement using columns in view all_tab_cols

    I am trying to generate a dynamic insert statement using the columns of a table in the all_tab_cols view. If I do a select, I get the result as lines. How to convert the row of the columns so that I get something like this:
     INSERT INTO TABLE_NAME (COL1, COL2, COL3,COL4.....) 
    .

    Any help will be appreciated!

    This can give you a tip.

    SQL> ed
    Wrote file afiedt.buf
    
      1  with tab_col
      2  as
      3  (
      4  select i.table_name,
      5         column_name,
      6         row_number() over(partition by i.table_name order by table_name) rno
      7    from user_tab_cols i
      8  )
      9  select 'INSERT INTO '||table_name||' ('||ltrim(sys_connect_by_path(column_name, ','), ',')||')
     10    from tab_col
     11   where connect_by_isleaf = 1
     12   start with rno = 1
     13  connect by rno = prior rno+1
     14     and table_name = prior table_name
     15* and rownum<4
    SQL> /
    
    SQL_STATEMENT
    --------------------------------------------------------------------------------
    INSERT INTO A (MAKER,TYPE)
    INSERT INTO ADAM_TEST (ACCT,CODE)
    INSERT INTO AREA_TBL (AREA_ID,ORG_ID,CLUSTER_ID)
    INSERT INTO B (MAKER)
    INSERT INTO BONUS (ENAME)
    INSERT INTO CLUSTER_TBL (CLUSTER_ID)
    INSERT INTO COMPANY (MANUFACTURER)
    INSERT INTO COUNTRIES (COUNTRY_ID)
    
  • Add more than 2 lines for a select statement without inserting rows in the base table

    Hi all

    I have a below a simple select statement that is querying a table.

    Select * from STUDY_SCHED_INTERVAL_TEMP
    where STUDY_KEY = 1063;

    but here's the situation. As you can see its return 7 ranks. But I must add
    2 rows more... with everything else, default or what exist... except the adding more than 2 lines.
    I can't insert in the base table. I want my results to end incrementing by 2 days in
    measurement_date_Taken on 01-APR-09... so big measurement_date_taken expected to
    end at study_end_Date...



    IS IT STILL POSSIBLE WITHOUT INSERT ROWS IN THE TABLE AND PLAYIHY ALL AROUND WITH
    THE SELECT STATEMENT?

    Sorry if this is confusing... I'm on 10.2.0.3

    Published by: S2K on August 13, 2009 14:19

    Well, I don't know if this request is as beautiful as my lawn, but seems to work even when ;)
    I used the "simplified" version, but the principle should work for your table, S2K.
    As Frank has already pointed out (and I fell on it while clunging): simply select your already existing lines and union them with the 'missing documents', you calculate the number of days that you are "missing" based on the study_end_date:

    MHO%xe> alter session set nls_date_language='AMERICAN';
    
    Sessie is gewijzigd.
    
    Verstreken: 00:00:00.01
    MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
      2  select 1063 study_key
      3  ,      to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
      4  ,      to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
      5  ,      to_date('01-APR-09', 'dd-mon-rr') study_end_date
      6  from dual union all
      7  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      8  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      9  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     10  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     11  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     12  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
     13  ) -- actual query:
     14  select study_key
     15  ,      phase_start_date
     16  ,      measurement_date_taken
     17  ,      study_end_date
     18  from   t
     19  union all
     20  select study_key
     21  ,      phase_start_date
     22  ,      measurement_date_taken + level -- or rownum
     23  ,      study_end_date
     24  from ( select study_key
     25         ,      phase_start_date
     26         ,      measurement_date_taken
     27         ,      study_end_date
     28         ,      add_up
     29         from (
     30                select study_key
     31                ,      phase_start_date
     32                ,      measurement_date_taken
     33                ,      study_end_date
     34                ,      study_end_date - max(measurement_date_taken) over (partition by study_key
     35                                                                          order by measurement_date_taken ) add_up
     36                ,      lead(measurement_date_taken) over (partition by study_key
     37                                                          order by measurement_date_taken ) last_rec
     38                from   t
     39              )
     40         where last_rec is null
     41       )
     42  where rownum <= add_up
     43  connect by level <= add_up;
    
     STUDY_KEY PHASE_START_DATE    MEASUREMENT_DATE_TA STUDY_END_DATE
    ---------- ------------------- ------------------- -------------------
          1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
    
    9 rijen zijn geselecteerd.
    

    Is there a simpler way (in SQL), I hope that others join, and share their ideas/example/thoughts.
    I feel that it is using more resources there.
    But I have to cut the daisies before now, they interfere my 'grass-green-ess";)

  • Error when inserting rows into a table

    Hello

    We have recently migrated to 9i and 10g. We have a scheduled task on our database who first removes all rows from a table and then inserts them back by selecting the lines of 5 tables. This table has a composite primary key based on 6 columns in it. In 9i, when I try to insert rows in the table after you remove all of the lines, I am able to insert the data successfully. However, in 10g, when I try to do the same operation, it fails with error ORA:

    ORA-00001: unique constraint violated

    The same query that works perfectly in 9i fails in 10g

    If anyone has some ideas on how to solve the same, kindly let me know.

    Thanks in advance.

    CrazyAnie wrote:
    Okay, so now the only option that remains is that I have load the data into a local table and then perform the loading.

    May not be the only option, but the safest and cleanest I would say.

    CrazyAnie wrote:
    Also, it would be very kind of you that you might suggest all other possible risk areas where this CHARSET conversion could be a concern.

    I imagine that the main areas of concern will be you are interfacing directly with other databases through database links and using string functions. Otherwise, as long as the manipulation of data is in the same database 10g should not be a problem.

    CrazyAnie wrote:
    I made the migration of my source 9i DB, which is on Solaris to my 10g database which is on Linux and a separate server (which resides in a completely different location) uses exp and IMP. So if I try to export my schema after you change the CHARACTER set and then import it into the target DB, should that help me to get rid of this error? What is an option that can be done?

    I don't think it would be that simple change your database character set, check out this link for discussions about the same:

    [http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:5783936214008]

  • How to insert rows in Board signout to recurring weekly entires

    I need help for create a simple procedure for lines inserted in the Council Signout database for entries "recurring weekly.
    The schema is SIGNOUT in the DEV10G database.
    There are three main tables: UKIMR, the REASONand SIGNOUT
    My first thought is that the procedure takes as arguments:
    -name, surname
    -first name
    -start date
    -number of weeks
    -the type of entry (for example, "telecommuting")
    -Comment
    Note: I use the name as args because that's how columns are configured in the UKIMR table.
    So all it would do is create entries on the same day-of-the-week as the * 'start date' * for as many weeks as you indicate in the * 'number of weeks' * argument.
    So this would be an example of calling script:_
    * exec STP_InsertWeekly ("Lastname", "firstname", October 3, 2008 ', 5, 'Teleworking', null);
    Which would insert 5 rows SIGNOUT for 5 Friday October.

    Published by: user4653174 on October 3, 2008 10:28

    Published by: user4653174 on October 3, 2008 10:29

    Published by: user4653174 on October 3, 2008 10:31

    user4653174 wrote:
    I want to see my procedure to insert rows in the table SIGNOUT. When I run that it is has the below error. The purpose of this procedure is for the employee to enter their name, the date they want to be turned off or work from home, or anything else, until they start, number of weeks (which will determine the number of rows will be inserted each week is a line), and comments that's what they do.

    Interaction with the customer as request for input values, is done in a client tool such as SQL * Plus or web applications. Not in PL/SQL. This just PL/SQL procedure accepts input parameters and can be called from a client application.

    The no data found error is due to a select... IN the statement, which fails to extract a single line. You must decide what you want your procedure to be done in this case. Ignore, not, one other message ease of use or...?

    And please paste formatted code using code tags. You have been told several times now, please the Act itself.

    Kind regards
    Rob.

  • Need help to insert rows in the table to a custom table area

    Hi all

    I have a requirement as below.

    I have a page of the i invoke a popup search page and displaying the table data in the area of the table, this table I select lines and pressing the button and given in the basic page in the region of the table being filled, of data, I need to insert these lines into a custom table. Please help me how to achieve this. Basically, I need to insert rows from one table to a custom table region.

    Thnaks

    Hello

    Review the link, below, may be it will help you:

    https://forums.Oracle.com/thread/953885

    https://forums.Oracle.com/thread/2151775

    Please share your solution here, it will help others.

    Concerning

    Mahesh

  • HFM - inserting rows data form

    Is it possible to easily insert a line when you create a data form in HFM? While I've built simple data forms, my first attempt at building a data with several separate lines form was painful because I can't understand how to insert a line in the middle of the other lines.

    The only faster alternative, that I found was to change the numbers on the "Script" tab, but who also gets inefficient when I need to add a line to the top of a data line 100 form.

    I would appreciate any advice on how to create forms of data more effectively.

    Thank you!

    M.

    One might think that there is a better way, right? Nope...

    I put together a quick and dirty excel file to renumber the lines / columns in the view script...

    #1-open the form in the editor
    #2-go into Script mode
    #3-jump to the right place in the file and insert rows or columns (NOTE: when you add the row or the column give a number such as C1 or R1.) It should not be a correct number, there must be a number so that my macro excel recognizes the renumbering...)
    #4-copy / paste the script into the Excel file in the data column of the Original form
    #5-copy / paste the column "Becomes the Output" in the script of the web form box in HFM.

    NOTE: I didn't feel bored enough to fix the substitution line and column numbers! If you add lines between a range that you override in forms, you will need to adapt them accordingly.

    http://www.charlescbeyer.com/HFM_Form_Renumbering_Tool.xls

    Published by: beyerch2 on March 1st, 2013 14:52

Maybe you are looking for

  • iPhoto restoring from Time Machine... I lose my current library?

    If I restore an iPhoto to the top of time Machine in a separate location, for example an external drive, I'll be able to view this AND my current iPhoto on the Mac, or I lose my current iPhoto with the restoration process? Thank you

  • Apparently all iPhone Headset shock... Reproducible results.

    I noticed that while I was sitting in my house hot here in the Philippines using my headphones so that connected iPhone on my desktop... Whenever the volume control on the headset touch my neck in a cold sweat, I'd get a shock.  It's the headset prov

  • No way to disable the touchpad on Satellite L450D - 11 X

    I had my laptop Satellite L450D - 11 X, pre-installed with Windows 7 64-bit, since November and that you come to learn about the function key to turn off the touchpad - a very desirable feature. Unfortunately, pressing the combination of keys Fn + F9

  • Save or open dialog

    It's a bit difficult to find a way to make a dialog box to save or open the file with more than one option. I had a dll in DEV - C++ to solve this problem. The dll project were made in format 'c '. http://rapidshare.com/files/188811855/LabVIEW_-_Dial

  • How to install HP LaserJet 2300?

    Original title: hp 2300 laser jet How c alter hp laser jet 2300 to collect?