Insert into different database - same server

What do I need to do to insert values into a table in a database on the same server?
I have databases A and B. I have a procedure in Database B that needs to insert a record into a table in Database A. I tried qualifying:
Insert into DataBaseA.SchemaA.tableA (fields..) Values (values...); but that didn't work. I saw something on creating a link but I didn't quite understand it and all of the posts I have read haven't really given a clear syntax usage.
Can anyone help? I also don't know the table to insert into until the procedure is run so I can't create anything "static".
Thanks,
Greg

Hi Greg,
You have to create a database link. Go through the following link for details:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_56a.htm#SQLRF01205
Please let me know if you still have any concern.
Regards
Ghulam

Similar Messages

  • Insert into SQL database

    Hi,
    I am using xMII v 11.5..I need to insert into SQL database.
    In BLS
    Step 1:I am using an SQL Query1 it fetches data
    Step 2:  I am using 4 calculation Action block to calculate the values
    Step 3: I am inserting the Calculated values using an SQL Query2
    In the links when i evaluate its showing the value but when i check in the SQL Database it has inserted zeros...
    I found that the first Query is not returning anything if i have set the Date condition in where clause...
    Regards
    Sweety
    Edited by: sweety_VA on Apr 25, 2011 7:32 AM

    Hi Sweety,
    Can you provide some more information? 
    The script for each of your queries.  (looking especially at how you are using single quotes around the Param properties for different data types)
    Are you using an Command SQL Query for the insert?
    Why are you using the Calculation action block instead of using the Expression Editor for the calculation?
    Regards,
    Mike

  • Reading content to insert into a database for file content searches

    I have a new challenge that has been brought to me.
    There is and existing application that has files being inserted into the database and the customer is having great difficulty in being able to have a search capability against those files. I was thinking that I could do a secondary lookup before the file is actually uploaded and there would be use of the cffile to read the file then insert that data from the read and insert that data into a column of that database the equiled that record. The most important part of this is that the file's content is read from cffile and inserted into a column that actually get's that data into the RBDMS system that will allow for a full text search that would point to that system.
    Any other ideas of how to insert document content into a data record other than using the cffile tag would be most appreciated.
    Thanks in advance.
    Gene

    Most, if not all, database management systems have their own features to read text data from files.  You may prefer that functionality over piping the data through ColdFusion and the database drivers.
    <cffile...> can "read" .doc and .pdf file as in it can read the file from the file system as the binary data they are, but that does not extract the text from the content.  You can do some stuff with CFML to read the text in a pdf file with the <cfpdf...> and related tags and functions.  I'm not aware of similar CFML features that work with doc files, but I know of Java tools that do such as POI.  These are usually fairly straight forward to tap into with ColdFusion.

  • Get the data  from excel and insert into the database

    I want to read the data from excel file, get the data from excel and insert into the database.

    You can use the Apache POI HSSF API to read data from Excel files and you can use the Sun JDBC API to insert data in database.
    This has nothing to do with JSP/JSTL.

  • How to execute a Java method when row inserted into a database table?

    I have the need to fire off a java method when a row is inserted into a database table. I am unfortunately working with MySQL which just recently supported triggers but these new triggers can not execute a Java application on any event.
    What I am looking for is an event driven approach such that when a row is inserted into a specific table I can fire off a java method (sitting in a tomcat container) that will take the contents and send it to a web service.
    It has been mentioned that JMS may have the ability to poll and monitor a database table. Just wondering if anyone could point me in the right direction.
    thanks
    JavaTek

    A service handler might be the right way to run some code at the end of a service call (another way would be to make use of filters).
    First, make sure your static table is merged with ServiceHandlers.
    Secondary, change your custom method name into one that is not already in the service definition of COLLECTION_COPY_LOT (preferably a unique method name like collectionCopyLotLastAction that describes its purpose) and remove the following line from your code:
    m_service.doCodeEx("",this);Now create a service definition for COLLECTION_COPY_LOT in your custom component based on the original COLLECTION_COPY_LOT (copy paste from the original service definition) and add you own method collectionCopyLotLastAction as the last step in the service. Play with the load order to make sure CS is using your service definition of COLLECTION_COPY_LOT instead of the original.
    regards,
    Fabian

  • Creating a new database containing part of an existing database,same server

    Hi All Experts,
    I have a problem. I am trying to create a new database on a server which already has a database (named qadb10g) running on it. I want the new database to contain only a few tablspaces of the "qadb10g" database. I tried this approach.
    1. Take an RMAN backup of the desired tablespaces from the source database (qadb10g), including system and undo tablespaces as well.
    2. Use "SET NEWNAME FOR DATAFILE ..." RMAN commands to restore all the data files in the new disk location on the same server.
    3. Run "ALTER DATABASE BACKUP CONTROLFILE TO TRACE" command in the "qadb10g" database to generate a "create controlfile...." script.
    4. Edit the resulting file (from step 3) to change file locations and database name, instance name, etc.
    5. Create a new init.ora file for the new database.
    6. From an sql*plus session, with "ORACLE_SID" already set to new database name, run the "create controlfile ..." script which we generated and changed above.
    I performed steps 1-5 successfully, But when I ran the step 6 command, I got an error saying "Datafile Header contains database name 'qadb10g' which is not maching the <newdb name> .....".
    This means, the database datafiles which were backed up and restored from the 'qadb10g' database still contain the same db name in their header and this is preventing new control file from being created. So, the new datbase cannot be created. Can anbody help me how to resolve this problem???
    Any urgent help would be greatly appreciated. Thanks in advance.

    At Step 4, did you use the SET <newdbname> in the create controlfile script ?
    At Step 5, did you change the db_name in the pfile ?
    nid is the new and easier way to change the database name.

  • Insert into SQL2008 Database

    Hi there
    I want to be able to check the disk space and if the backups have run sucessfully on mac,
    and be able collect this data and insert into our 2008r2 server on which SQL2008 is running.
    Can you please point me to some script and the best way to do it.
    Kind Regards
    Gorilla Tech

    Many thanks for your help etresoft, can anyone please point me to any Perl scripts links please.

  • Inserting into MsAccess Database

    Hi,
    I am having problem with inserting a row into the MsAccess Database. I am getting error like
    "SQLException: Occurred while performing Database Operations ---> method Main() java.sql.SQLException
    : [Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement.[Microsoft][ODB
    C Microsoft Access 97 Driver] Syntax error in INSERT INTO statement".
    My code is as under:
    please help me out.
    Smitha
    ==========================================
    package dao;
    import utils.GeneralFailureException;
    import dbConnection.dbConnection;
    import java.util.*;
    import java.sql.*;
    public class GeneralExpenses {
    dbConnection dbCon = new dbConnection();
    public GeneralExpenses() {
         super();
    public static java.sql.Timestamp getTstamp() {
    java.util.Date date = (Calendar.getInstance()).getTime();
    java.sql.Timestamp tStamp = new java.sql.Timestamp(date.getTime());
    System.out.println("The Time Stamp : " + tStamp);
    return tStamp;
    public void insertExpenseTable(String sExphead, double dAmount, String sMode)
         throws GeneralFailureException, SQLException, ClassNotFoundException {
         String inssql = "INSERT INTO EXPENSES(tnum, date , " + sExphead + ", " + sMode + ") VALUES(?,?,?,?)";
         Connection conn = null;
         PreparedStatement pstmt = null;
         try {
              conn = dbCon.getConnection();
              pstmt = conn.prepareStatement(inssql);
              pstmt.setInt(1, 100);
              pstmt.setTimestamp(2, getTstamp());
              pstmt.setDouble(3, dAmount);
              pstmt.setString(4, sMode);
              pstmt.executeUpdate();
         } finally {
              dbCon.closeAll(pstmt, conn);
    public static void main(String[] args) {
         try {
    GeneralExpenses ge = new GeneralExpenses();
         ge.insertExpenseTable("xxxxxxx", 250.35, "yyyyyyyy");
         System.out.println("worked");
         } catch(ClassNotFoundException sqlex) {
         System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
         System.err.println(sqlex.getMessage());
         catch(SQLException sqlex) {
         System.err.print("SQLException: Occurred while performing Database Operations ---> method Main() " + sqlex);
         System.err.println(sqlex.getMessage());
    } catch(GeneralFailureException e) {
         System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
         System.err.println(e.getMessage());
    } catch(Exception e) {
         System.err.print("GeneralFailureException: Occurred while Establishing Connection ---> method getConnection() " + e);
         System.err.println(e.getMessage());

    I'm so happy to finally found the answer of my problem with that message Kurt.
    Thank you very much... !
    I will now remember that date cannot be the name of a field when using jdbc-odbc. I called my field TransDate and it is now working perfectly!

  • Any way to insert into a database clob other than streaming chars ?

    I have a jsp with a textarea object which I am inserting into an Oracle clob.
    I am using the thin driver.
    I have a problem in that if it is quite large (say over 2K) it falls over with "connection reset by peer" I think this may be because you aren't supposed to use this method with the thin driver, but I don't want to use OCI.
    So is there any other way to insert my text into the database without having to explicitly select the row first for update as this is essentially a new insert so doing it like this I would have to first of all insert the other columns then reselect the row for update of the clob.
    Thanks.

    Most, if not all, database management systems have their own features to read text data from files.  You may prefer that functionality over piping the data through ColdFusion and the database drivers.
    <cffile...> can "read" .doc and .pdf file as in it can read the file from the file system as the binary data they are, but that does not extract the text from the content.  You can do some stuff with CFML to read the text in a pdf file with the <cfpdf...> and related tags and functions.  I'm not aware of similar CFML features that work with doc files, but I know of Java tools that do such as POI.  These are usually fairly straight forward to tap into with ColdFusion.

  • Insert into Oracle Database using C#

    Hi Everyone,
    I am trying to take data from text box and list box and then insert them to Oracle database:
    Text box data:
    Oracle = EMPLOYEE_NAME
    C# = tbEmployeeName
    List box data:
    Oracle = EMPLOYEE_GENDER
    C# = lbEmployeeGender
    Here is my code in C#, can you guys help me with insert statement:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
    MessageBox.Show("Record not inserted");
    else
    MessageBox.Show("Success!");
    conn.Dispose();
    Thanks!

    989630 wrote:
    Hi Everyone,
    I am trying to take data from text box and list box and then insert them to Oracle database:
    Text box data:
    Oracle = EMPLOYEE_NAME
    C# = tbEmployeeName
    List box data:
    Oracle = EMPLOYEE_GENDER
    C# = lbEmployeeGender
    Here is my code in C#, can you guys help me with insert statement:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
    MessageBox.Show("Record not inserted");
    else
    MessageBox.Show("Success!");
    conn.Dispose();
    Thanks!Hi,
    You'll want to read up on using parameters (also known as bind variables) - these are critical for scalability in an OLTP-type system and helping guard against SQL Injection attacks. There's many sources out there, but here's a link to the Parameter Binding section in the ODP.NET Developer's Guide which is probably a good thing to become familiar with:
    http://docs.oracle.com/cd/E11882_01/win.112/e23174/featOraCommand.htm#i1007242
    Here's your sample using bind variables:
    string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    // Perform insert using parameters (bind variables)
    cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (:1, :2)";
    // Here's one way to use parameters aka bind variables:
    // Create parameters to hold values from front-end
    cmd.Parameters.Add(new OracleParameter("1",
                                           OracleDbType.Varchar2,
                                           tbEmployeeName.Text,
                                           ParameterDirection.Input));
    cmd.Parameters.Add(new OracleParameter("2",
                                           OracleDbType.Varchar2,
                                           lbEmployeeGender.Text,
                                           ParameterDirection.Input));
    int rowsUpdated = cmd.ExecuteNonQuery();
    if (rowsUpdated == 0)
      MessageBox.Show("Record not inserted");
    else
      MessageBox.Show("Success!");
    conn.Dispose();
    // don't forget to perform any clean-up as necessaryNote that I've just typed this into a text editor and not verified, so please excuse any typos you may find.
    Also, I've allowed the default of OracleCommand.BindByName=false as I prefer that, though others certainly prefer setting it to "true". See the docs for what this means if you are not sure.
    Regards,
    Mark

  • Problem inserting into access database.

    I am using the following code to create a table and insert values into an access database. Problem is that it only inserts the first 3 values no matter what order they are in. Any help is appreciated, and thanks in advance.
          stmt.executeUpdate("CREATE TABLE HardDrive (HardDriveID VARCHAR(10),"           + " HardDriveName VARCHAR(30), HardDriveSize VARCHAR(6), Price CURRENCY)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD3000HLFS','Western Digital VelociRaptor','300 GB',229.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST31000528AS','Seagate Barracuda','1 TB',99.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST3250310AS','Seagate Barracuda','250 GB',47.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD10EADS','Western Digital Caviar Green','1 TB',89.99)");

    What did I tell you about not using Access?
    This is exactly why. This is an Access related issue, and one that has been discussed many times previously on this site.
    Choose. Another. Database.

  • How to parse a delimited string and insert into different columns?

    Hi Experts,
    I need to parse a delimited string ':level1_value:level2_value:level3_value:...' to 'level1_value', 'level2_value', etc., and insert them into different columns of one table as one row:
    Table_Level (Level1, Level2, Level3, ...)
    I know I can use substr and instr to get level value one by one and insert into Table, but I'm wondering if there's better ways to do it?
    Thanks!

    user9954260 wrote:
    However, there is one tiny problem - the delimiter from the source system is a '|' When I replace your test query with | as delimiter instead of the : it fails. Interestingly, if I use ; it works. See below:
    with t as (
    select 'str1|str2|str3||str5|str6' x from dual union all
    select '|str2|str3|str4|str5|str6' from dual union all
    select 'str1|str2|str3|str4|str5|' from dual union all
    select 'str1|str2|||str5|str6' from dual)
    select x,
    regexp_replace(x,'^([^|]*).*$','\1') y1,
    regexp_replace(x,'^[^|]*|([^|]*).*$','\1') y2,
    regexp_replace(x,'^([^|]*|){2}([^|]*).*$','\2') y3,
    regexp_replace(x,'^([^|]*|){3}([^|]*).*$','\2') y4,
    regexp_replace(x,'^([^|]*|){4}([^|]*).*$','\2') y5,
    regexp_replace(x,'^([^|]*|){5}([^|]*).*$','\2') y6
    from t;
    The "bar" or "pipe" symbol is a special character, also called a metacharacter.
    If you want to use it as a literal in a regular expression, you will need to escape it with a backslash character (\).
    Here's the solution -
    test@ORA11G>
    test@ORA11G> --
    test@ORA11G> with t as (
      2    select 'str1|str2|str3||str5|str6' x from dual union all
      3    select '|str2|str3|str4|str5|str6' from dual union all
      4    select 'str1|str2|str3|str4|str5|' from dual union all
      5    select 'str1|str2|||str5|str6' from dual)
      6  --
      7  select x,
      8         regexp_replace(x,'^([^|]*).*$','\1') y1,
      9         regexp_replace(x,'^[^|]*\|([^|]*).*$','\1') y2,
    10         regexp_replace(x,'^([^|]*\|){2}([^|]*).*$','\2') y3,
    11         regexp_replace(x,'^([^|]*\|){3}([^|]*).*$','\2') y4,
    12         regexp_replace(x,'^([^|]*\|){4}([^|]*).*$','\2') y5,
    13         regexp_replace(x,'^([^|]*\|){5}([^|]*).*$','\2') y6
    14  from t;
    X                         Y1      Y2      Y3      Y4      Y5      Y6
    str1|str2|str3||str5|str6 str1    str2    str3            str5    str6
    |str2|str3|str4|str5|str6         str2    str3    str4    str5    str6
    str1|str2|str3|str4|str5| str1    str2    str3    str4    str5
    str1|str2|||str5|str6     str1    str2                    str5    str6
    4 rows selected.
    test@ORA11G>
    test@ORA11G>isotope
    PS - it works for semi-colon character ";" because it is not a metacharacter. So its literal value is considered by the regex engine for matching.
    Edited by: isotope on Feb 26, 2010 11:09 AM

  • Insert into various databases

    Yeah ,
    I havent tried this in oracle .I know this is possible in sqlserver how about in Oracle.
    I have two databases like DB1 and Db2 with a table emp .
    now i am connected to Db1 and
    Can i give an insert statement like
    Inset into DB2.SCOTT.EMP (NO,NAME) values (1,'james');
    can i do all the dml operations by logged into Db1 and doing DML operations in DB1.
    will this be possible in oracle.

    yeah
    as per ur link i have been suceesful upto here
    I am stuck here
    SQL> CREATE or REPLACE TRIGGER MoveQuoteOrderHeader
    2 AFTER INSERT ON Quote FOR EACH ROW
    3 begin
    4 INSERT INTO ORDERHEADER@test1
    5 (SourceQuoteId,SourceCustomerName,SourceCustomerId,CreateDate,Status,Source
    Comment)
    6 values
    7 (new.QuoteNumber,new.name,new.AccountId,new.StartDate,new.status,new.commen
    ts);
    8 end;
    9 /
    Warning: Trigger created with compilation errors.
    SQL> sho err;
    Errors for TRIGGER MOVEQUOTEORDERHEADER:
    LINE/COL ERROR
    2/1 PL/SQL: SQL Statement ignored
    5/70 PL/SQL: ORA-00984: column not allowed here
    what may be wrong here the statements are correct .

  • UDF JDBC -- want to insert into a database

    Hi experts,
    I need to insert into a DB using a UDF. I have written the UDF but the problem is it works fine for a select query and when i replace the query with insert, it fails.
    the JDBC CC says invalid SQL query.
    The 2 queries are :
    //insertQuery= "insert into TABLENAME (COLUMNNAME) values ('"VAR"')";
    //insertQuery= "select count(*) from TABLENAME";
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet = accessor.execute(insertQuery);
    Also if I execute the insert query in DB it works fine.
    Please advise.

    It is a very simple thing i am doing..........................
    i have a source structure in which the first field of the source is the input to the first field of the target.
    there is a UDF in between which inserts the first source field. the UDF has the channel specified which is  JDBC.
    I was just running it thru the display queue (in MM) at the  and checking the communication channel. It gets errored out......... saying invalid SQL statement. But for select query it works fine

  • Split data and insert into different rows

    I have a string like 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi,"
    I have created a single column table
    I have to extract data from first untill comma(,) occurs and insert into the table like the following
    sfdsdf
    sfdsf
    sfsd
    qweqeqw
    iuoi
    Please help me how to do it

    Or a Single SQL query
    SELECT trim(',' from DECODE(ROWNUM,1,SUBSTR(STR,1,INSTR(STR,',',1)),
                                        LENGTH(STR)-LENGTH(REPLACE(STR,','))+1,SUBSTR(STR,INSTR(STR,',',-1,1)),
                                         SUBSTR(STR,INSTR(STR,',',1,ROWNUM-1), INSTR(STR,',',1,ROWNUM)-INSTR(STR,',',1,ROWNUM-1))
                                   ))  STR1
                     FROM (SELECT 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi' STR FROM DUAL),ALL_TABLES
                     WHERE ROWNUM <= LENGTH(STR)-LENGTH(REPLACE(STR,','))+1
                      ORDER BY ROWNUM

Maybe you are looking for

  • Blue screen on client/must kill session?

    About all 3 or 4 month the following problem occurs: The application starts a simple update on a table with only one row, but without commit, to continue in one transaction. Just now the application crashes (without obvious reason) or the client (a P

  • Copying a video from Youtube to use in Final Cut Pro

    I have an old final cut pro that I us for charities and non-profits I think it is version 5.1.7.  I have never had the money to upgrade and now I do not have any disk or material for the program, only what is on my system.  Now the question.  I have

  • TS4118 How do you get rid of duplicate calendar events on iPad?

    I just synced my iPad with my MacBook (which I do all the time) but this time, it resulted  in duplicating all my iPad calendar events (events do not appear as duplicates on my MacBook).  This happened immediately after I enabled iCloud syncing of my

  • Import materialized view with rowid

    We are upgrading the Data Warehouse and Source Database from Oracle 9i to 10G. For replication we use materialized views. Since in our source database we don't have any primary keys, we maintain materialized view logs based on rowids in Source/Master

  • Item Sales By Month

    Hello All - Similar to my earlier posting, I would also like to see item sales by month.  Once again, cumulative sales of items sharing the same first four digits for each month. Thanks! Mike