Insert twice using single sql

Hi,
I want to achieve
1. insert into t1 select col1,'a',col2 from t2;
2. insert into t1 select col1,'b',col2 from t2;
using a single sql.
Thanks..

Hi,
Does this work for you?
SQL> INSERT ALL
  2  INTO t1 VALUES(c1, 'a', c3)
  3  INTO t1 VALUES(c1, 'B', c3)
  4  SELECT * FROM t2;
2 rows created.
Elapsed: 00:00:00.00
SQL> SELECT * FROM t1;
        C1 C2                                                                                                                               C3
         1 a                                                                                                                                 2
         1 B                                                                                                                                 2
Elapsed: 00:00:00.00Lukasz

Similar Messages

  • Multiple SQLs INSERT in a single SQL with O.Lite on PDA

    Hi,
    We are using(and new to) Oracle on PDA, dvlping in JAVA. We need to increase performance and reliability to make multiple INSERT in a single SQL statement, dynamically created :
    We've got a syntax error when executing this :
    INSERT INTO t1 (row1,row2) VALUES ('x','y');
    INSERT INTO t1 (row1,row2) VALUES ('a','v');
    INSERT INTO t1 (row1,row2) VALUES ('e','r');
    etc... in a single execSql
    Any suggests would be helpfull !
    JMarc
    [email protected]

    Hi Praveen
    If your use case is like having large no. of data rows and inserting those into DB. I believe best appropriate way would be form a xml and then pass it to DB. While in DB, you can create SP and perform your logical steps(if any) thereafter inserting data into table.
    The above link shared by Muzammil talks on the same subject.
    While once within SP(DB layer), you can fetch entire xml using below example:
    DECLARE @data XML;
    -- Element-centered XML
    SET @data = '<data>
        <customer>
          <id>1</id>
          <name>Name 1 </name>
        </customer>
        <customer>
          <id>2</id>
          <name>Name 2</name>
        </customer>
         <customer>
          <id>3</id>
          <name>Name 3</name>
        </customer>  
        </data>';
    SELECT T.customer.value('(id)[1]', 'INT') AS customer_id,
           T.customer.value('(name)[1]', 'VARCHAR(20)') AS customer_name
    FROM @data.nodes('data/customer') AS T(customer);
    The above run will give you output from xml in single shot.
    You can also find maximum no. of rows as below.
    declare @max int
    select @max = @data.value('fn:count(/data/customer/id)','int')
    select @max  
    I believe above should help you around with your insertion...

  • Restful service unable to insert data using PL/SQL.

    Hi all,
    Am running: AL 2.01 standalone mode on OEL 4.8 in VM box A.
    Oracle database 10.2.0.4 with Apex 4.2.0.00.27 on OEL4.8 in VM box B.
    Able to performed oracle.example.hr Restful services with no problem.
    Unable to insert data using AL 2.0.1 but works on AL 1.1.4.
    which uses the following table (under schema: scott):
    create table json_demo ( title varchar2(20), description varchar2(1000) );
    grant all on json_demo to apex_public_user; and below procedure ( scott's schema ):
    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 executing in sqldeveloper 3.2.20.09 when connecting 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;which resulted in :
    anonymous block completed
    status code: 200
    reason phrase: OK
    with data inserted. Setup using 2.0.1
       Workspace : wsdemo
    RESTful Service Module:  demo/
              URI Template:      test
                    Method:  POST
               Source Type:  PL/SQLand executing in sqldeveloper 3.2.20.09 when connecting 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;which resulted in :
    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-idPlease advise.
    Regards
    Zack

    Zack.L wrote:
    Hi Andy,
    Sorry, forgot to post the Source that's use by both AL1.1.4 and AL2.0.1.
    Source
    begin
    insert into scott.json_demo values(:title,:description);
    end;
    it's failing during the insert?
    Yes, it failed during insert using AL2.0.1.
    So 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
    <an identifier> <a double-quoted delimited-idThis suggests to me that an unprintable character (notice how there is nothing between the double quotes - "") has worked its way into your PL/SQL Handler. Note how the error is reported to be a column 74 on line 2, yet line 2 of the above block should only have 58 characters, so at a pure guess somehow there's extra whitespace on line 2, that is confusing the PL/SQL compiler, I suggest re-typing the PL/SQL handler manually and seeing if that cures the problem.

  • Inserting rows using pl sql

    Hi all,
    I created one tabale to inserting some numbers
    create table loc_number (c1 number);
    now i want to insert 10 rows into this table using pl sql.
    How can i do that using pl sql?

    Hi,
    Yes it is possible.
    Why do you want to use loops here ?
    (I'm assuming, you need this for practice purpose)
    begin
    for i in 1..10
    loop
       insert into loc_number
           values (i);
    end loop;
    commit;
    end;

  • Updates using single SQL Update statement.

    Hi Guys,
    I had an interview... and was not able to give an answer of one of the question.
    Given the emp table... need to update the salary with following requirement using one SQL statement...
    1. Update salary+1000 for those employees who have salary between 500 and 1000
    2. Update salary+500 for those employees who have salary between 1001 and 1500
    Both above requirement should be done by using only one SQL update statement... can some one tell me how to do it?

    update emp
      set salary   = case when salary between 500 and 1000
                                then salary + 1000
                                when salary between 1001 and 1500
                                then salary + 500
                          end;Regards
    Arun

  • How to find a dependent row in the all tables using single SQL query

    hi all,
    I have created some table with master and some dependent tables.I want to mark a (row)tuple as inactive in master so that corresponding child records also should be marked as inactive.
    So i decided to mark the master and dependent records as inactive starting from master table and traverse to child tables.
    So I need SQL query to fetch all dependend records to the row(marked row in the master ) from the master table and dependent rows from the child row and to mark as flag inactive.
    can anybody help me out to build this query or any other way to mark flag as inactive ?
    Regards
    punithan

    You can find dependant tables from ALL_CONSTRAINTS, e.g:
    SQL> CREATE TABLE m (id INT PRIMARY KEY, flag VARCHAR2(1) NOT NULL);
    Table created.
    SQL> CREATE TABLE d1 (m_id REFERENCES m, flag VARCHAR2(1) NOT NULL);
    Table created.
    SQL> CREATE TABLE d2 (m_id REFERENCES m, flag VARCHAR2(1) NOT NULL);
    Table created.
    SQL> SELECT table_name, owner, status
      2  FROM   all_constraints c
      3  WHERE  c.constraint_type = 'R'
      4  AND    ( c.r_owner, c.r_constraint_name ) IN
      5         ( SELECT owner, constraint_name
      6           FROM   user_constraints
      7           WHERE  table_name = 'M'
      8           AND    constraint_type IN ('U','P') );
    TABLE_NAME                     OWNER                          STATUS
    D2                             WILLIAMR                       ENABLED
    D1                             WILLIAMR                       ENABLED
    2 rows selected.There is no SQL command to apply all updates in one go, if that's what you were looking for.
    AFAIK the word "tuple" is for mathematics and relational theory, and does not refer to a physical row in a database.

  • Compare and insert in single SQL

    Hi ,
    I want to insert data from one source table to destination table based on the condition that a row does not exist in destination table based on some column filter . Is it achievable using single SQL.?
    Merge statement cannot be used as there is no unique key in source table and destination table.
    Here is the data and tables.
    create table test_source
    x_id number,
    report_sent_flag varchar2(30),
    year number
    insert into test_source
    select 10 , 'Y' , 2013 from dual
    union all
    select 20 , 'Y' , 2013 from dual
    union all
    select 30 , 'Y' , 2013 from dual
    union all
    select 10 , 'Y' , 2013 from dual
    union all
    select 20 , 'Y' , 2013 from dual
    union all
    select 30 , 'Y' , 2013 from dual;
    create table test_dest
    x_id number,
    report_sent_flag varchar2(30),
    year number
    insert into test_dest
    select 10 , 'Y' , 2013 from dual
    union all
    select 10 , 'Y' , 2013 from dual;
    select * from test_source  ;
    10    Y    2013                                            
    10    Y    2013
    20    Y    2013
    20    Y    2013
    30    Y    2013
    30    Y    2013
    select * from test_dest ;
    10    Y    2013
    10    Y    2013
    Now , i need compare test_source and test_dest tables on column  (x_id , report_sent_flag and year ) column , since 10 , Y , 2013 is present in test_dest , it will be skipped . Rest should get inserted into test_dest table from test_source.
    Can it done by SQL only ?
    Please assist
    Thanks
    Please assist

    only SQL :
    SQL> select * from test_source  ;
          X_ID REPORT_SENT_FLAG                     YEAR
            10 Y                                    2013
            20 Y                                    2013
            30 Y                                    2013
            10 Y                                    2013
            20 Y                                    2013
            30 Y                                    2013
    6 rows selected
    SQL> select * from test_dest ;
          X_ID REPORT_SENT_FLAG                     YEAR
            10 Y                                    2013
            10 Y                                    2013
    SQL> select * from log_exists_records;
          X_ID REPORT_SENT_FLAG                     YEAR
    SQL>
    SQL> insert into log_exists_records
      2  select * from test_source
      3  where (x_id,report_sent_flag,year ) in (select x_id,report_sent_flag,year from test_dest)
      4  /
    2 rows inserted
    SQL>
    SQL> insert into test_dest
      2  select * from test_source
      3  where (x_id,report_sent_flag,year ) not in (select x_id,report_sent_flag,year from test_dest)
      4  /
    4 rows inserted
    SQL> select * from test_source  ;
          X_ID REPORT_SENT_FLAG                     YEAR
            10 Y                                    2013
            20 Y                                    2013
            30 Y                                    2013
            10 Y                                    2013
            20 Y                                    2013
            30 Y                                    2013
    6 rows selected
    SQL> select * from test_dest ;
          X_ID REPORT_SENT_FLAG                     YEAR
            20 Y                                    2013
            30 Y                                    2013
            20 Y                                    2013
            30 Y                                    2013
            10 Y                                    2013
            10 Y                                    2013
    6 rows selected
    SQL> select * from log_exists_records;
          X_ID REPORT_SENT_FLAG                     YEAR
            10 Y                                    2013
            10 Y                                    2013
    SQL>
    Ramin Hashimzade

  • Sql insert in Java vs. sql dts package

    Hi,
    I was wondering the speed difference between inserting records to database from Java as oppose to inserting records using a sql server dts package. I'm talking about 3000+ records.
    See Java when inserting records to database it looks something like this:
    while (recordHasNext)
       String insertStr = "insert into table(item) values(" + valueVariable + ")";
       statement.executeQuery(insertStr);
    }where as if I'm executing a dts package I would create a .bat file with the following commands:
    DTSRUN.EXE /S ServerName /E /N PackageName /F FileName
    And then have Java execute the batch file.
    So my question is, which is faster for the amount of records I'm inserting?
    thanks,

    veryConfused wrote:
    Hi,
    I was wondering the speed difference between inserting records to database from Java as oppose to inserting records using a sql server dts package. I'm talking about 3000+ records.That's not many.
    >
    See Java when inserting records to database it looks something like this:
    while (recordHasNext)
    String insertStr = "insert into table(item) values(" + valueVariable + ")";
    statement.executeQuery(insertStr);
    }where as if I'm executing a dts package I would create a .bat file with the following commands:
    DTSRUN.EXE /S ServerName /E /N PackageName /F FileName
    And then have Java execute the batch file.
    So my question is, which is faster for the amount of records I'm inserting?
    thanks,Measure it for your situation and see.
    My recommendation would be to go with DTS. They have a graphical way of mapping from one database to another, including transforms. You don't have to write code to do it. And I'd bet that DTS will do it faster, but I'm not certain.
    %

  • Lync Standard Edition Server pairing -- Archiving and monitoring collocated but Single SQL backend

    Hi,
    I have a scenario where in ---we have Two Standard Edition Servers ( SE1 and SE2) with 1K users each ( Total 2K in one Site) paired to enable High Availability. The Standard Edition Server has archiving and monitoring and mediation server collocated.
    For archiving + monitoring database we have a Seperate SQL enterprise edition server.
    Quetions:
    1. Can we use single SQL Enterprise Edition as backend for (archiving and monitoring ) for both SE1 and SE2 ?
    2. If yes, do we need two seperate instances?
    3. If not, could you please suggest the best possible solution in such an environment ?
    Regards,
    Archana Rao

    Hi ArchanaVR,
    Agree with Michael, and add some more details.
    By default, the SQL Server Express back-end database is collocated on the Standard Edition server. You cannot move it to a separate computer. With one exception, you cannot collocate other databases on the Standard Edition server. If you choose to deploy
    Persistent Chat Server on a Standard Edition server, you can collocate the Persistent chat database and the Persistent Chat Compliance database on the same Standard Edition server.
    You can collocate each of the following databases on a single database server:
    Monitoring database
    Archiving database
    A back-end database for an Enterprise Edition Front End pool
    You can collocate any or any or all of these databases in a single SQL instance or use a separate SQL instances for each, with the following limitations:
    Each SQL instance can contain only a single back-end database (for an Enterprise Edition Front End pool), single Monitoring database, single Archiving database, single persistent chat database, and single persistent chat compliance database.
    The database server cannot support more than one Enterprise Edition Front End pool, one server running Archiving, one server running Monitoring, single Persistent Chat database, and single Persistent Chat compliance database, but it can support one of each,
    regardless of whether the databases use the same instance of SQL Server or separate instances of SQL Server.
    http://technet.microsoft.com/en-us/library/gg398131.aspx
    Best regards,
    Eric

  • Insert to multiple table using single DB Adapter

    Hi,
    I m using Jdev 11g Build JDEVADF_11.1.1.2.0_GENERIC_091029.2229.5536
    Can anyone tell me how can we do insert and update operations to mutliple tables using single DB adapter.
    I want to do insert in 2 tables and update the third using same DB apater. Is it possible?If yes, how?

    Hi,
    You can write a PL\SQL (Stored Procedure) to do your operations and call the PL\SQL code from DB Adapter.
    -Senaka

  • Can this be done using a single sql......

    Hi,
    I have a problem to solve an was just wondering if it was possible to do it using a single sql. It is not imperative that I use a single sql but would like to know if it were possible and if so how, else I would appreciate if I was guided in the general direction where I may be able to find a solution....
    1) Esstentially in this example an employee can have 3 types of managers 'A' 'B' or 'C'.
    2) the emplyee must have 1 and only 1 manager of type 'A' (it is imperative that an emp have a manager of type A)
    3) the employee can have multiple managers of Type B and C but it is possible that the emp does not have any manager of type B and C
    We need a report which compares all the type B managers of an employee to the type A manager of the same employee and if any one of the Type B manager is same as the type A manager then the report indicates 'Equal' else the report indicates 'Not Equal'. if there is no type B manager for the employee then the report should show is as 'Not Equal'.
    The same comparsion need to be done between type C and type A managers for the employee...
    here are the scripts you would require to create a dummy table with data
    ?SCRIPTS START?
    create table emp (empid number(3), mgrid number(3), mgr_type varchar2(1))
    insert into emp values (1,3,'A')
    insert into emp values (1,10,'B')
    insert into emp values (1,14,'C')
    insert into emp values (2,15,'A')
    insert into emp values (3,10,'A')
    insert into emp values (3,10,'B')
    insert into emp values (3,10,'C')
    insert into emp values (4,12,'A')
    insert into emp values (5,2,'A')
    insert into emp values (5,2,'B')
    insert into emp values (5,3,'B')
    insert into emp values (6,1,'A')
    insert into emp values (6,5,'C')
    select * from emp
    ?SCRIPTS-END?
    EMPID> MGRID> M
    1> 3> A
    1 > 10 > B
    1 > 14 > C
    2 > 15 > A
    3 > 10 > A
    3 > 10 >B
    3 > 10> C
    4 >12 > A
    4 > 12 > C
    5 > 2 > A
    5 >2 > B
    5 > 3> B
    6 > 1 > A
    6 > 5 > C
    6 > 7 > C
    Expected Report
    emp_id>     mgr_type_A>     mgr_type_B>     mgr_type_C
    1>>>     3>>>          Not Equal>>>     Not Equal
    2>>>     15>>>          Not Equal>>>     Not Equal
    3>>>     10>>>          Equal>>>          Equal
    4>>>     12>>>          Not Equal>>>     Equal
    5>>>     2>>>          Equal>>>          Not Equal
    6>>>     1>>>          Not Equal>>>     Not Equal
    at the end of the day the report is to be exported as an xls. I would be using java to connect to the DB and create the xls. Obv I could run a simple sql and do a lot of comparision in java and get the desired report... What I am looking for is
    - Is it possible using a single sql.
    - if not.. is it better to use a pl/sql procedure or do it using java code.
    the table has abt 100,000 records .... performance is not really a factor right now...
    I just have no idea where to look.. I thought of pivot tables but could not find a solution... thought of decode as well... but again to no avail... (i am not oracle expert by any means....)
    Appreciate any help I can get...
    Thanks...
    PS: Have used > to seperate the data.. since the preview of the post was truncating all spaces between the columns and was making it difficult to differetiate the data....
    ooooppppsss....just realised i should have put this in the PL/SQL forum.. dont' seem to find an option to delete the post.. so if someone can move it to the other forum... it would be great....
    Message was edited by:
    user520267

    Well, there are no moderators here, so you are going to have to get your answer here :-). Most of us that hang out in PL/SQL are here too.
    Assuming that 4>>> 12>>> Not Equal>>> Equal is a typo because there is only one record for empid 4, this works. There may be more efficient ways but ...
    SQL> SELECT a.empid, a.mgrid,
      2         NVL((SELECT 'EQUAL' FROM emp b
      3             WHERE b.empid = a.empid and
      4                   b.mgrid = a.mgrid and
      5                   b.mgr_type = 'B'), 'NOT EQUAL') bmgr,
      6         NVL((SELECT 'EQUAL' FROM emp c
      7             WHERE c.empid = a.empid and
      8                   c.mgrid = a.mgrid and
      9                   c.mgr_type = 'C'), 'NOT EQUAL') cmgr
    10  FROM emp a
    11  WHERE mgr_type = 'A';
         EMPID      MGRID BMGR      CMGR
             1          3 NOT EQUAL NOT EQUAL
             2         15 NOT EQUAL NOT EQUAL
             3         10 EQUAL     EQUAL
             4         12 NOT EQUAL NOT EQUAL
             5          2 EQUAL     NOT EQUAL
             6          1 NOT EQUAL NOT EQUALYou can format your code and data, as I did here, by using [ pre ] and [ /pre ] without the spaces around the text you want preserved. [ code ] and [ /code ] works too.
    HTH
    John

  • Insert into using a select and dynamic sql

    Hi,
    I've got hopefully easy question. I have a procedure that updates 3 tables with 3 different update statements. The procedure goes through and updates through ranges I pass in. I am hoping to create another table which will pass in those updates as an insert statement and append the data on to the existing data.
    I am thinking of using dynamic sql, but I am sure there is an easy way to do it using PL/SQL as well. I have pasted the procedure below, and what I'm thinking would be a good way to do it. Below I have pasted my procedure and the bottom is the insert statement I want to use. I am faily sure I can do it using dynamic SQL, but I am not familiar with the syntax.
    CREATE OR REPLACE PROCEDURE ACTIVATE_PHONE_CARDS (min_login in VARCHAR2, max_login in VARCHAR2, vperc in VARCHAR2) IS
    BEGIN
    UPDATE service_t SET status = 10100
    WHERE poid_id0 in
    (SELECT poid_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    DBMS_OUTPUT.put_line( 'Service Status:' || sql%rowcount);
    UPDATE account_t SET status = 10100
    WHERE poid_id0 IN
    (SELECT account_obj_id0 FROM service_t
    WHERE poid_type = '/service/telephony'
    AND login >= min_login AND login <= max_login);
    DBMS_OUTPUT.put_line( 'Account Status:' || sql%rowcount);
    UPDATE account_nameinfo_t SET title=Initcap(vperc)
    WHERE obj_id0 IN
    (SELECT account_obj_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >=min_login AND login <= max_login);
    DBMS_OUTPUT.put_line('Job Title:' || sql%rowcount);
    INSERT INTO phone_card_activation values which = 'select a.status, s.status, s.login, to_char(d.sysdate,DD-MON-YYYY), ani.title
    from account_t a, service_t s, account_nameinfo_t ani, dual d
    where service_t.login between service_t.min_login and service_t.max_login
    and ani.for_key=a.pri_key
    and s.for_key=a.pri_key;'
    END;
    Thanks for any advice, and have a good weekend.
    Geordie

    Correct my if I am wrong but aren't these equal?
    UPDATE service_t SET status = 10100
    WHERE poid_id0 in
    (SELECT poid_id0 FROM service_t
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    (update all the records where there id is in the sub-query that meet the WHERE Clause)
    AND
    UPDATE service_t SET status = 10100
    WHERE poid_type='/service/telephony'
    AND login >= min_login AND login <= max_login);
    (update all the records that meet the WHERE Clause)
    This should equate to the same record set, in which case the second update would be quicker without the sub-query.

  • How to insert data in tables using loops sql

    Oracle 10.2g
    using Oracle sql*plus
    Table student is
    create table student(id)
    as
    select distinct student_id
    from students_table;now
    desc student; will retrieve
    student
    ======
    Name         Null?    Type
    ===========================
    ID                  VARCHAR2(10)Now creating a sequence
    create sequence st_seq;
    alter table student add column no;
    select * from student
    no       id
    =========
            234
            298
    This is the main part
    There are 100 student id in the table
    now i want to populate the table with sequences using seq.next_val
    how to use a loop to insert 100 auto generated numbers in the table.
    Thank you.
    Expected result
    Select * from student
    no     id
    =========
    1     234
    2     298
    .........Why i am doing this way instead of
    create table student(no,id)
    as
    select st_se.nextval,student_id
    from students;This will cause duplication of upn
    using distinct would throw an error.
    create table student(st_id,id)
    as select distinct st_seq.nextval,academicyear
    from student
    as select distinct st_seq.nextval,academicyear
    ERROR at line 2:
    ORA-02287: sequence number not allowed hereThank you.

    Follow the example:
    SQL> create table students_table (student_id number);
    Table created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(20);
    1 row created.
    SQL> insert into students_table values(30);
    1 row created.
    SQL> insert into students_table values(40);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL> select *
    2 from students_table;
    STUDENT_ID
    10
    10
    20
    30
    40
    SQL> create sequence st_seq;
    Sequence created.
    SQL> create table student(no,id)
    2 as
    3 with distinct_table as
    4 (
    5 select distinct student_id
    6 from students_table
    7 order by student_id
    8 )
    9 select st_seq.nextval, student_id
    10 from distinct_table
    11 ;
    Table created.
    SQL> select *
    2 from student;
    NO ID
    1 10
    2 20
    3 30
    4 40
    SQL>
    Cheers,
    Davide

  • Problem using a SQL database Catalogue to insert data to a table

    I am developing with Version:
    10.3.1.0, Build: #99765....
    as part of a step in my process I need to store some data in an audit table.
    I have setup the SQL Catalogue entry and then use the following code:
    sentMail is defined as a local variable
    sentMail = RSPCA.Resources.RSPCA.R_SENTEMAIL()
    sentMail.sentemailBody = sendInternalRequest.htmlbody
    sentMail.sentemailDatesent = Fuego.Lang.Time
    sentMail.sentemailSubject = subject
    sentMail.sentemailTo = creation.participant.email
    sentMail.sentemailType = "People"
    store sentMail
    This works if I comment out this line:
    sentMail.sentemailBody = sendInternalRequest.htmlbody
    The issue I'm having maybe something to do with the size of the data, in oracle the field is a varchar2(4000) and it looks like the catalogue treats it as a String(4000), if I make sure I only put around 1500 characters in the field it works, but as soon as I put all in from my test data (about 2300) it fails with this message:
    The method 'CIL_sendToHQ' from class 'EstablishmentManagement.EMMaintainPeopleProcess.Default_1_0.Instance' could not be successfully executed.
    Caused by: [BEA][Oracle JDBC Driver][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column
    Caused by: [BEA][Oracle JDBC Driver][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column
    fuego.lang.ComponentExecutionException: The method 'CIL_sendToHQ' from class 'EstablishmentManagement.EMMaintainPeopleProcess.Default_1_0.Instance' could not be successfully executed.
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:519)
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:273)
         at fuego.fengine.FEEngineExecutionContext.invokeMethodAsCil(FEEngineExecutionContext.java:219)
         at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1278)
         at fuego.server.execution.microactivity.ComponentExecutionMicroActivity.runCil(ComponentExecutionMicroActivity.java:126)
         at fuego.server.execution.microactivity.ComponentExecutionMicroActivity.execute(ComponentExecutionMicroActivity.java:84)
         at fuego.server.execution.microactivity.MicroActivityEngineExecutionHandler.executeActivity(MicroActivityEngineExecutionHandler.java:57)
         at fuego.server.execution.ImmediateActivity.execute(ImmediateActivity.java:42)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
         at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
         at fuego.server.execution.DefaultEngineExecution.executeAutomaticWork(DefaultEngineExecution.java:62)
         at fuego.server.execution.EngineExecution.executeAutomaticWork(EngineExecution.java:42)
         at fuego.server.execution.ToDoItem.executeAutomaticWork(ToDoItem.java:251)
         at fuego.server.execution.ToDoItem.run(ToDoItem.java:536)
         at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:775)
         at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:755)
         at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:142)
         at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:134)
         at fuego.fengine.ToDoQueueThread$PrincipalWrapper.processBatch(ToDoQueueThread.java:450)
         at fuego.component.ExecutionThread.work(ExecutionThread.java:839)
         at fuego.component.ExecutionThread.run(ExecutionThread.java:408)
    Caused by: fuego.components.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column
         at fuego.sql.TableSQLObject.implicitStore(TableSQLObject.java:409)
         at fuego.sql.TableSQLObject.store(TableSQLObject.java:340)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at fuego.lang.JavaClass.invokeMethod(JavaClass.java:1410)
         at fuego.sql.SQLObject.invoke(SQLObject.java:364)
         at fuego.lang.Invokeable.invokeImpl(Invokeable.java:234)
         at fuego.lang.Invokeable.invokeDynamic(Invokeable.java:188)
         at EstablishmentManagement.EMMaintainPeopleProcess.Default_1_0.Instance.CIL_sendToHQ(Instance.xcdl:100)
         at EstablishmentManagement.EMMaintainPeopleProcess.Default_1_0.Instance.CIL_sendToHQ(Instance.xcdl)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:512)
         ... 23 more
    Caused by: java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column
         at albpm.jdbc.base.BaseExceptions.createException(Unknown Source)
         at albpm.jdbc.base.BaseExceptions.getException(Unknown Source)
         at albpm.jdbc.oracle.OracleImplStatement.execute(Unknown Source)
         at albpm.jdbc.base.BaseStatement.commonExecute(Unknown Source)
         at albpm.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
         at albpm.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
         at fuego.jdbc.FaultTolerantPreparedStatement.executeUpdate(FaultTolerantPreparedStatement.java:623)
         at fuego.sql.TableSQLObject.insert(TableSQLObject.java:626)
         at fuego.sql.TableSQLObject.implicitStore(TableSQLObject.java:391)
         ... 39 more
    Edited by: user10778731 on 21-Jan-2010 06:17

    Suspect you're not going to like this answer, but I never use the store() method for a database heir object anymore.
    The store() database method has been broken and then fixed and then broken again on too many release cycles to trust that it will work consistently as MPs/Hotfixes are applied. I'd suspect that your "String(4000)" problem might also be related to using the store() method.
    Others will probably disagree, but only use the OOTB PBL (JDBC) SQL or Dynamic SQL in the PBL logic. In your case, I think you might be best served by using Dynamic SQL. With Dynamic SQL you don't run into the shortcomings of JDBC SQL (String(4000) might be one of them) and you can then test / debug your SQL in your favorite DB tool of choice first (e.g. Toad, Squirrel, Sql Plus). Once successfully tested, you can then paste it back into your PBL.
    Dan

  • Insert & Update using Writeback in a single Report

    Hi,
    Here is requirement:
    In the single report where the user has to do the Insert & update using the writeback functionality.
    below is the XMl:
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="SUBMITBUTTON">
    <XML>
    <writeBack connectionPool="CSDK">
    <insert>INSERT INTO HSCRTARGETLOOKUP(SLA_TYPE,TARGET_AVAILABILITY,TARGET_MTTR) VALUES ('@{c0}', @{c1}, @{c2})</insert>
    <update>UPDATE HSCRTARGETLOOKUP SET TARGET_AVAILABILITY = @{c1}, TARGET_MTTR = @{c2} WHERE SLA_TYPE = '@{c0}'</update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    Can you please let us know whether both insert & update will work at the same time using a single report.
    Thanks in Advance
    Siva

    Hi,
    Insert & update is working with the Single xml file:
    here it is how i have done:
    in the 1st criteria i have taken three columns and made union with the 3 dummy columns.
    in the 1st dummy column: CASE WHEN 1= 0 THEN HSCRTARGETLOOKUP.SLA_TYPE ELSE NULL END
    2nd dummy column: CAST('' AS INT)
    3rd dummy column: CAST('' AS INT)
    below is the single XML file which is working for both insert & update
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="STATES">
    <XML>
    <writeBack connectionPool="XXXX">
    <insert>INSERT INTO HSCRTARGETLOOKUP(SLA_TYPE,TARGET_AVAILABILITY,TARGET_MTTR) VALUES ('@{c0}', @{c1}, @{c2})</insert>
    <update></update>
    <update>UPDATE HSCRTARGETLOOKUP SET TARGET_AVAILABILITY = @{c1}, TARGET_MTTR = @{c2} WHERE SLA_TYPE = '@{c0}'</update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    Hope it works for you also.

Maybe you are looking for

  • Why is Save As box for downloading files opening to random directories?

    In version 9 when I performed a download of a file the save as dialog box would prompt me for a save location per my settings. I would select a directory to save it to and save the file. When I saved another file from the same site it would default t

  • Correlation ID

    I have a quick question on the CorrelationID on a JMS message and the use of that in ALSB. Can the correlationID be primed with any value I desire or do I have to conform to certain rules regarding length etc? Pete

  • Ftp blob object in osb

    Through a UI uploaded attachments are getting stored in DB as blob objects Now we need to Ftp these attachments to our service providers particular location Could someone tell me how to go about it Should i be using DBadapter to select the blob objec

  • SunMC Error Copying XML APIS

    Hello, I'm installing Sun Manager Center 4.0 over Solaris 10 8/07, but immediatly it begin instalation, fails. I get this error in the log file: *"Error copying XML APIs to /var/run/tmp/SunMCInstall/XML/APIs"* Please help.

  • So where can I get authorised Logic plug ins?

    What the above says really..