PL/SQL 10g - Cannot Insert Values from PL/SQL

Hi People,
BACKGROUND (if required):
I'm trying to write a message threading algorithm for uni, I believe it works so far, it's just matching the subjects at the moment I want to expand it to include email addresses but that will be at a later date.
A brief run down, at the moment, a user can generate a list of email addresses to filter the corpus with, these are then inserted (via Java) into the table Sender. These addresses are then used in an IF statement, however they are only used if the table sender is populated. The messges that are identified as threads have their Message ID inserted into another table but they also have their values printed to the DBMS output.
QUESTION:
What I need help with is although the values print out to the DBMS Output after a great deal of time, normally after the DBMS buffer has maxed out (thus the statement ends in error). The values printed are not inserted into the table.
Any help on solving this or optimising if would be greatly appreciated, I'm new to PL/SQL i'm afraid so it's probably a really messy statement.
If this is a badly worded question and I need to supply more information then I gladly will, however i'm not 100% on what information is relevant at the moment.
Below is the statement in question.
Thanks and Regards,
K
LOOP
IF sender_cur1%FOUND THEN
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID and Sub_One_Sender = send_user_cur THEN
INSERT INTO MATCHING_SUB (MID) VALUES (sub_Two_MID);
dbms_output.put_line('MID is: ' || sub_Two_MID);
END IF;
ELSE
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID THEN
INSERT INTO MATCHING_SUB (MID) VALUES (sub_Two_MID);
dbms_output.put_line('MID is: ' || sub_Two_MID);
END IF;
END IF;
Edited by: user8967525 on 01-Mar-2010 07:27
Edited by: user8967525 on 01-Mar-2010 08:08

cd,
I will most certainly try.
I have a table of emails that I am attempting to thread by means of comparing the subjects together (for now). However ultimately I want to be able to bring in the recipients as well. However this can be ignored for now.
The main variables from the Messages table are:
MID(number) - 0 - 245000
SENDER(VARCHAR) - Email Address
SUBJECT_CLN6 - VARCAHR - Cleaned email subject.
I am creating two instancs of a cursor that contains the subjects and MID's from Messages. I am then looping through cur1 comparing the value against all values in cur2, this continues until all values in cur1 have been compared against cur2. I use the MID to ensure that I am not comparing the same Message. Furthermore I am also filtering the Emails by Sender (if the table has been populated by the user, via a java applet, otherwise if just uses the subject). The variable Send_User_Cur takes takes its values from the Table called Sender, whilst sub_one_sender takes its values from the column Sender in Messages.
The proposed output of this at the moment is to just have the MID's (and later all the relevant columns, however just for now MID) of all the threaded emails, inserted into the table MATCH_THREAD, such that they can be called upon later for further processing and most likely called from a java applet at some point as well.
I've pasted the entire code below. I understand that it looks a bit messy on the preview and for that I apologise.
Thanks all!
Kev
DECLARE
CURSOR sub_cur1 IS
SELECT MID, Sender, trim(subject_cln6) from MESSAGES;
sub_One MESSAGES.subject_cln6%TYPE;
sub_One_MID MESSAGES.MID%type;
sub_One_Sender MESSAGES.SENDER%type;
CURSOR sub_cur2 IS
SELECT MID, trim(subject_cln6) from Messages;
sub_Two MESSAGES.subject_cln6%TYPE;
sub_Two_MID MESSAGES.MID%type;
CURSOR sender_cur1 IS
SELECT SENDER_ID FROM SENDER;
Send_User_Cur SENDER.SENDER_ID%type;
counter number := 0;
MID_t MESSAGES.MID%TYPE;
i number := 0;
j number := 0;
BEGIN
SELECT count(subject) INTO counter
FROM MESSAGES;
OPEN sub_cur1;
OPEN sub_cur2;
OPEN sender_cur1;
FETCH sub_cur1 INTO sub_One_MID, Sub_One_Sender, Sub_One;
FETCH sender_cur1 INTO Send_User_Cur;
WHILE sub_cur1%FOUND
LOOP
IF sub_cur2%ISOPEN THEN
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
dbms_output.put_line('OPEN');
ELSE
OPEN sub_cur2;
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
--dbms_output.put_line('OPENED and FETCHED');
END IF;
LOOP
IF sender_cur1%FOUND THEN
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID and Sub_One_Sender = send_user_cur THEN
INSERT INTO MATCH_THREAD (MID) VALUES (sub_Two_MID);
commit;
END IF;
ELSE
IF sub_One = Sub_two and sub_One_MID != sub_Two_MID THEN
INSERT INTO MATCH_THREAD (MID) VALUES (sub_Two_MID);
commit;
END IF;
END IF;
FETCH sub_cur2 INTO sub_Two_MID, SUB_Two;
i := i + 1;
EXIT WHEN i = counter;
END LOOP;
CLOSE sub_cur2;
FETCH sub_cur1 INTO sub_One_MID, Sub_One_Sender, SUB_One;
i := 0;
dbms_output.put_line('sub_One_MID: ' || sub_one_mid);
END LOOP;
CLOSE sub_cur1;
CLOSE sub_cur2;
END;

Similar Messages

  • Logic for inserting values from Pl/sql table

    Hi I'm using Forms 6i and db 10.2.0.1.0
    I am reading an xml file using text_io, and extracting the contents to Pl/sql table.
    Suppose, the xml
    <?xml version="1.0" encoding="UTF-8" ?>
      <XML>
      <File name="S2_240463.201002170044.Z">
      <BookingEnvelope>
      <SenderID>KNPROD</SenderID>
      <ReceiverID>NVOCC</ReceiverID>
      <Password>TradingPartners</Password>
      </BookingEnvelope>
    </File>
    </XML>From this xml, i'm extracting contents to a table of records, say bk_arr, which look like
    Tag                             Val
    File name                     S2_240463.201002170044.Z
    SenderID                     KNPROD
    ReceiverID                   NVOCC
    Password                     TradingPartnersAnd now from this i've to insert into table, say bk_det .
    The tag may come in different order, sometimes some additional tags may also come in between,
    So i cannot access it sequentially and insert like
    Insert into bk_det(file,sndr,rcvr,pswd) values(bk_arr(1).val,bk_arr(2).val....)
    The tag name is constant ir for sender id, it will always be SenderID , not something like sndrid or sndid etc..
    So if i've to insert to senderid column, then i've to match the tag = SenderID, and take the value at that index in the array.
    How best i can do this?
    Thanks

    I am referring to how you are parsing the XML - as you can extract values from the XML by element name. And as the name is known, it's associated value can be inserted easily.
    Basic example:
    SQL> with XML_DATA as(
      2          select
      3                  xmltype(
      4  '<?xml version="1.0" encoding="UTF-8" ?>
      5  <XML>
      6          <File name="S2_240463.201002170044.Z">
      7                  <BookingEnvelope>
      8                          <SenderID>KNPROD</SenderID>
      9                          <ReceiverID>NVOCC</ReceiverID>
    10                          <Password>TradingPartners</Password>
    11                  </BookingEnvelope>
    12          </File>
    13  </XML>'         )       as XML_DOM
    14          from    dual
    15  )
    16  select
    17          extractValue( xml_dom, '/XML/File/@name' )                      as FILENAME,
    18          extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' )   as SENDER_ID,
    19          extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ) as RECEIVER_ID,
    20          extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' )   as PASSWORD
    21  from       xml_data
    22  /
    FILENAME                  SENDER_ID  RECEIVER_I PASSWORD
    S2_240463.201002170044.Z  KNPROD     NVOCC      TradingPartners
    SQL> Now this approach can be used as follows:
      create or replace procedure AddFile( xml varchar2 ) is
    begin
            insert into foo_files(
                    filename,
                    sender_id,
                    receiver_id,
                    password
            with XML_DATA as(
                    select
                            xmltype( xml ) as XML_DOM
                    from    dual
            select
                    extractValue( xml_dom, '/XML/File/@name' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' )
            from    xml_data;
    end;
    /No need for a fantasy called PL/SQL "+tables+".

  • While inserting values from a xml file into the database.

    Dear Forum Members,
    While using Samp10.java (given in XSU!2_ver1_2_1/oracleXSU12/Sample)for inserting values from xml file Sampdoc.xml into database table xmltest_tab1,the error shown below appears on the DOS prompt.
    The code for sam10 is:
    import oracle.xml.sql.dml.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.jdbc.*;
    import java.net.*;
    public class samp10
    public static void main(String args[]) throws SQLException
    String tabName = "xmltest_tab1";
    String fileName = "sampdoc.xml";
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbc:odbc:BookingSealinerScott","scott","tiger");
    OracleXMLSave sav = new OracleXMLSave(conn, tabName);
    URL url = sav.createURL(fileName);
    int rowCount = sav.insertXML(url);
    System.out.println(" successfully inserted "+rowCount+
    " rows into "+ tabName);
    conn.close();
    }catch (Exception e){e.printStackTrace();}
    The Structure of Sampdoc.xml is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW num="1">
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    </ROW>
    <ROW num="2">
    <EMPNO>7499</EMPNO>
    <ENAME>ALLEN</ENAME>
    <JOB>SALESMAN</JOB>
    </ROW>
    <ROW num="3">
    <EMPNO>7521</EMPNO>
    <ENAME>WARD</ENAME>
    <JOB>SALESMAN</JOB>
    </ROW>
    </ROWSET>
    Description of table xmltest_tab1 is:
    SQL> desc xmltest_tab1;
    Name Null? Type
    EMPNO NUMBER(4)
    ENAME CHAR(10)
    JOB VARCHAR2(9)
    Error Displayed is:
    A nonfatal internal JIT (3.00.078(x)) error 'Structured Exception(c0000005)' has
    occurred in :
    'oracle/xml/sql/dml/OracleXMLSave.cleanLobList ()V': Interpreting method.
    Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi
    oracle.xml.sql.OracleXMLSQLException: sun.jdbc.odbc.JdbcOdbcConnection
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1967)
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:1880)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1013)
    at samp10.main(samp10.java:36)
    Press any key to continue . . .
    Please send me the solution as soon as possible.
    Thanks,
    Waiting for your Reply,
    Bye,
    Vineet Choudhary
    Email id: [email protected]
    null

    Go and read about JDBC. You need to know some basics before asking such a st&*id questions.
    Paul

  • Java.sql.SQLException: Cannot convert value

    I have a database table - name is client. It has one field with TimeStamp Datatype.
    I am using mysql-3.23.51-win and j2sdk-1_4_0_01-windows-i586.
    create table client (
    MODIFIED timestamp(14)
    while I am doing select MODIFIED from client that time I am receiving 00000000000000.
    So It has 00000000000000 value in databse.
    Now I am getting this value using ResultSet. for that
    I have a one Client Object class name is GenericClient
    public class GenericClient {
    private java.util.Date _modified;
    public java.util.Date getModified() {
    return _modified;
    public void setModified(java.util.Date newVal) {
    this._modified = newVal;
    In my database processing class I am getting database value and set that value in setModified(java.util.Date newVal).
    like
    private Client decodeRow(ResultSet rs) throws SQLException {
    GenericClient obj = new GenericClient();
    obj.setModified(rs.getTimestamp(1));
    return obj;
    So at obj.setModified(rs.getTimestamp(1)); line I am received error message
    java.sql.SQLException: Cannot convert value '00000000000000' from column 1 to TIMESTAMP.
    Please guide me why I am receiving the above error.
    Thanks
    Amit

    Please find some more information from my side
    1) I am passing Timestamp Object
    2) I am using PreparedStatement
    3) code
    Table : client
    create table client (
         MODIFIED timestamp(14)
    );Bean Class
    public class GenericClient {
         private java.util.Date _modified;
         public java.util.Date getModified() {
              return _modified;
         public void setModified(java.util.Date newVal) {
              this._modified = newVal;
    }Method - which is fired error
    private Client decodeRow(ResultSet rs) throws SQLException {
         GenericClient obj = new GenericClient();
         obj.setModified(rs.getTimestamp(1));
         return obj;
    }3) Error Stack
    ==========
    java.sql.SQLException: Cannot convert value '00000000000000' from column 1 to TIMESTAMP.
            at com.mysql.jdbc.ResultSet.getTimestampFromString(ResultSet.java:5538)
            at com.mysql.jdbc.ResultSet.getTimestampInternal(ResultSet.java:5566)
            at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:5219)
            at com.ksea.manager.ClientManager.decodeRow(ClientManager.java:463)
            at com.ksea.manager.ClientManager.loadByWhere(ClientManager.java:266)
            at com.ksea.manager.ClientManager.loadByWhere(ClientManager.java:221)
            at com.ksea.manager.ClientManager.loadByWhere(ClientManager.java:203)
            at com.ksea.manager.ClientManager.loadByUsername(ClientManager.java:53)
            at com.ksea.nt.DBSynch.synchEmployees(DBSynch.java:83)
            at com.ksea.nt.DBSynch.synchAll(DBSynch.java:35)
            at com.ksea.nt.DBSynch.main(DBSynch.java:168)4) db Info
    =======
    I am using mysql-3.23.51-win and j2sdk-1_4_0_01-windows-i586.

  • Script fails when passing values from pl/sql to unix variable

    Script fails when passing values from pl/sql to unix variable
    Dear All,
    I am Automating STATSPACK reporting by modifying the sprepins.sql script.
    Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
    I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
    From the sprepins.sql script
    variable bid number;
    variable eid number;
    begin
    select begin_snap into :bid from db_snap;
    select end_snap into :eid from db_snap;
    end;
    This fails with the following error:
    DB Name DB Id Instance Inst Num Release Cluster Host
    RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
    :ela := ;
    ERROR at line 4:
    ORA-06550: line 4, column 17:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    &lt;a string literal with character set specification&gt;
    &lt;a number&gt; &lt;a single-quoted SQL string&gt; pipe
    The symbol "null" was substituted for ";" to continue.
    ORA-06550: line 6, column 16:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev su
    But when I change the select statements below the report runs successfully.
    variable bid number;
    variable eid number;
    begin
    select '46' into :bid from db_snap;
    select '47' into :eid from db_snap;
    end;
    Even changing the select statements to:
    select TO_CHAR(begin_snap) into :bid from db_snap;
    select TO_CHAR(end_snap) into :eid from db_snap;
    Does not help.
    Please Help.
    TIA,
    Nischal

    Hi,
    could it be the begin_ and end_ Colums of your query?
    Seems SQL*PLUS hs parsing problems?
    try to fetch another column from that table
    and see if the error raises again.
    Karl

  • How can I insert values from table object into a regular table

    I have a table named "ITEM", an object "T_ITEM_OBJ", a table object "ITEM_TBL" and a stored procedure as below.
    CREATE TABLE ITEM
    ITEMID VARCHAR2(10) NOT NULL,
    PRODUCTID VARCHAR2(10) NOT NULL,
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE T_ITEM_OBJ AS OBJECT
    ITEMID VARCHAR2(10),
    PRODUCTID VARCHAR2(10),
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE ITEM_TBL AS TABLE OF T_ITEM_OBJ;
    PROCEDURE InsertItemByObj(p_item_tbl IN ITEM_TBL, p_Count OUT PLS_INTEGER);
    When I pass values from my java code through JDBC to this store procedure, how can I insert values from the "p_item_tbl" table object into ITEM table?
    In the stored procedure, I wrote the code as below but it doesn't work at all even I can see values if I use something like p_item_tbl(1).itemid. How can I fix the problem?
    INSERT INTO ITEM
    ITEMID,
    PRODUCTID,
    LISTPRICE,
    UNITCOST,
    STATUS,
    SUPPLIER,
    ATTR1
    ) SELECT ITEMID, PRODUCTID, LISTPRICE,
    UNITCOST, STATUS, SUPPLIER, ATTR1
    FROM TABLE( CAST(p_item_tbl AS ITEM_TBL) ) it
    WHERE it.ITEMID != NULL;
    COMMIT;
    Also, how can I count the number of objects in the table object p_item_tbl? and how can I use whole-loop or for-loop to retrieve values from the table object?
    Thanks.

    Sigh. I answered this in your other How can I convert table object into table record format?.
    Please do not open multiple threads. It just confuses people and makes the trreads hard to follow. Also, please remember we are not Oracle employees, we are all volunteers here. We answer questions if we can, when we can. There is no SLA so please be patient.
    Thank you for your future co-operation.
    Cheers, APC

  • How to retrieve the values from PL/SQL table types.

    Hi Every one,
    I have the following procedure:
    DECLARE
    TYPE t1 IS TABLE OF emp%ROWTYPE
    INDEX BY BINARY_INTEGER;
    t t1;
    BEGIN
    SELECT *
    BULK COLLECT INTO t
    FROM emp;
    END;
    This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
    Can anybody help me please!!!!!
    Thanks
    Ahmed.

    You mean, you can't add this
    for i in t.first..t.last loop
    dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
    end loop;or you can't add this
    set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
    You see, not able like very similar it is not working - both are too vague...
    Best regards
    Maxim

  • *Urgent*How to insert data from MS SQL to the table that create at the adobe form?

    Hi,
    I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
    I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
    Thanks

    Tou need to do a couple of things
    1. On the Essbase server, set up an odbc system connection to your MySQL database
    2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
    The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it

  • Retreiving a value from and SQL query

    If anyone can give me sample code or pointers to retreive a value from an sql query, I'd be greatful.
    Source code I've muddled together so far:
    Class seqNumType = Class.forName(nameOfClass);
    Constructor theConstructor = seqNumType.getConstructor(null);
    Object seqNumInstance = theConstructor.newInstance(null);
    String theStatement = "SELECT value INTO v_seqnum FROM DUAL;";
    OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall(theStatement);
    ocs.registerOutParameter( 1, OracleTypes.NUMBER, 0);
    Method method = seqNumInstance.getClass().getMethod("getORADataFactory", null);
    seqNumInstance = ocs.getORAData(1, (ORADataFactory)method.invoke(null,null));
    ocs.execute();
    Problem with this seems to be the ORADataFactory isn't a method of the class, but as I'm thumbling around in the dark here a little, I've no idea where to go from here. Is this just generally overkill anyway?
    Suggestions?
    Cheers for any help.

    Like this:
                ResultSet resultSet=statement.executeQuery("SELECT * FROM TEST");
                while(resultSet.next())
                    for(int i=0;i<resultSet.getMetaData().getColumnCount();i++)
                        System.out.print(resultSet.getObject(i+1).toString()+" ");
                    System.out.println();

  • APP-FND-01242: Cannot read value from field Error in Forms

    Hi,
    I have a form which is having a navigation
    Setup -> Codes,
    as soon as the Code page has open, am pressing Cntrl + F11, and am getting the
    below error.
    APP-FND-01242: Cannot read value from field COMBO.ENABLED_FLAG
    Cause: The field COMBO.ENABLED_FLAG could not be located or read.
    Action: This error is normally the result of an incorrectly-entered field name string in a trigger, or a field name string that does not uniquely specify a field in your form. Correct your trigger logic to precisely specify a valid field.
    when am clicking on the button 'Ok' am getting a value one by one.
    am a newbie to forms, please let me know how to solve this error in details
    steps that helps me

    Ask your question in an eBusiness-suite related forum, maybe here OA Framework

  • Oracle.sql.STRUCT cannot be cast to oracle.sql.STRUCT

    I met a problem,I use oracle spatial to store geometry,then get it like this:
    STRUCT dbObject = (oracle.sql.STRUCT)rs.getObject("shape");
    JGeometry geom = JGeometry.load(dbObject);
    tomcat 6 told me java.lang.ClassCastException: oracle.sql.STRUCT cannot be cast to oracle.sql.STRUCT
    does everyone knows this problem?thanks
    Edited by: 811014 on 2010-11-13 下午9:28
    Edited by: 811014 on 2010-11-13 下午9:28

    Hi, this is a known problem for most Spatial 10g Java APIs with WLS.
    WLS is only certified with 11g DB.
    Instead of using Weblogic JNDI Lookup for Datasource, try the following snippet to create your connection/datasource (with Oracle JDBC thin driver):
    String databaseUrl = jdbc:oracle:thin:@1.2.3.4:1521:yourdbname
    String databaseUser = dbusername
    String databasePassword = dbpassword
    DriverManager.registerDriver(new OracleDriver());
    Connection aConnection = DriverManager.getConnection(databaseUrl, databaseUser, databasePassword);
    For more information, see the following:
    Classcast Exception while using Oracle ARRAYs
    regards,
    jack

  • Inserting values from a PL SQL table to a database table

    Hi,
    Here is my dilemma.
    I have values inserted to a pl sql table which I have gathered from a web page. Now I need to add these same values to a database table. I see the values as 1-'AA', 2='BB' etc.
    I use the following code to insert to a outside table in the database and it seems to be crashing.
    for i in app_table.first .. app_table.last loop
    r_convention(i).priority_country_code:=app_table(i);
    insert into test_countries
    values (test_seq,tion(i).r_convention(i).priority_country_code);
    commit;
    end loop;
    WHen I run this code I see the values. But it goes to the first value and then crashes and does not go through the
    rest of the values. What am I missing here?
    Thanks!

    Hi,
    Why can't you directly insert into the table from the object type....
    for i in app_table.first .. app_table.last loop
    r_convention(i).priority_country_code:=app_table(i);
    insert into test_countries
    values (test_seq,app_table(i));
    commit;
    end loop;Can you give me your complete code, so that we can have a better picture..
    Edited by: plsql dev on Sep 10, 2010 10:14 PM

  • Cannot insert value with : into BLOB field

    I am using Oracle 10g Express Edition.
    Attempting to run this insert from the SQL Commands page:
    INSERT INTO table1 (col1, col2)
    VALUES ('one', '\"2.001:2372.002:002.005:Y2.018:G')
    Table1 info:
    col1 = VARCHAR2(25)
    col2 = BLOB
    After I click Run an Enter Tab Variables appears?
    Is it possible to insert the value straight into col2 without entering bind variables?

    wrong forum

  • Cannot insert data from local database into remote database using subquery

    I have two oracle databases on different host.
    One is version 8i in Host A and the other is 9i in Host B.
    First, I try to create a dblink in 8i to 9i, but it fail.
    Then, I create a dblink in 9i to 8i, it success.
    I have already tried some select statement in 9i to view the table in 8i, which is success and that means the dblink is really work.
    The sql statement is like
    Select * from table1@hostA
    Then I have tried running some INSERT statement in 9i, which is copy data from table 1 in 8i to table 2 in 8i, both tables are in 8i. The sql statement is like
    Insert INTO table2@hostA(field1, field2)
    select field1, field2
    from table1@hostA
    This also success.
    Also, I have tried to use the following INSERT statement
    Insert INTO table2@hostA(field1, field2) values ('XXX', 'XXX)
    This also success.
    However, when I try to insert data from table in 9i to table in 8i using the following INSERT statement, it failed.
    Insert INTO table2@hostA(field1, field2)
    select field1, field2
    from table1
    The statement can execute, but all the rows inserted with every field value equal to NULL. I have tried to run the select part, it can return the data. But when I run the INSERT statement above, the value inserted into table2 is all equal to NULL.
    One more thing, I discover that the databases are using different NLS_CHARACTERSET
    9i is AL32UTF8
    8i is WE8ISO8859P1
    Is this relevant to my problem?
    Does anyone know the solution about this problem?
    Thanks!!

    How is the best way to do this ?How much are you planning to send?
    You can use COPY command. Ensure that you have valid database link between two databases.
    Available options are:
    create - creates a new table. errors out if the destination table exists.
    replace - drop the destination table and re-creates with data.
    insert - inserts data if the destination table exists.
    append– appends data into an existing table.
    use set arraysize 5000 -The arraysize specifies the number of rows that SQL*Plus will retrieve from the database at one time.
    copy from scott/tiger@ORCL to scott/tiger@ORCL92 create new_emp using select * from emp;

  • Insert values from more than one select query

    Hi all, I've a simple question:
    I need to insert values into a table from two select statements.
    There's what I need to accomplish:
    I need to monitor the cursors opened on a database, so:
    I created the following table:
    O_CURSORS
    Cols: TOTAL (Number 5), USER (VARCHAR2 20), DATE (TIMESTAMP)
    I think some query like the following should work, but unfortunately, it doesn't.
    insert into O_CURSORS (total,user,date)
    values (
    (select a.value, s.username from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic#  and s.sid=a.sid and b.name = 'session cursor cache count'),
    (select sysdate from dual)
    )This statement is not working, the message is
    "Not enough values"
    If I modify the statement as follows, it works fine
    insert into O_CURSORS (total,user)
    (select a.value, s.username from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic#  and s.sid=a.sid and b.name = 'session cursor cache count'),
    )Any advice would be very appreciated!
    Thanks in advance.

    You don't have to select sysdate from dual; it can be a part of any select statement. Just include sysdate in your first query:
    INSERT INTO O_CURSORS (total,user,date)
    SELECT a.value, s.username, SYSDATE
    FROM v$sesstat a,  v$statname b,   v$session s
    WHERE a.statistic# = b.statistic#
      AND s.sid=a.sid and b.name = 'session cursor cache count'You'll note also that I elimiated the VALUES keyword, and just used a SQL statement to satisfy the INSERT statement.
    Edited by: user13640471 on Feb 21, 2011 1:17 PM
    Edited by: user13640471 on Feb 21, 2011 1:18 PM

Maybe you are looking for

  • DVI to ADC adapter forcing powerbook to shut down on connection

    Hi there, I have been using my powerbook 1.25GHz for about 8 months with my DVI to ADC adapter to connect to my 22" cinema display with no troubles whatsoever. Yesterday evening when I came home as soon as connected the adapter to my powerbook- it sh

  • External hard drive won't appear

    I bought a 250GB Formac external hard drive a few years ago and have used it on and off to back up my old G4 powerbook. I purchased my MacBook in March this year and have previously connected it to the Formac drive without any problems. A couple of w

  • P2V Server using Bootable media

    I have a server that cannot boot fully into Windows. I want to boot off a CD and create a VHD of the server on a USB drive or network drive. I'm hoping someone can point me in the right direction of how I can do this quickly and easily. Vincent Sprag

  • Standard transaction for PO Reporting

    Hi all, I'm on SRM 5.0 ECS. I'm looking for some standard transactino for reporting about PO. Something like transaction ME2L, ME2M, ME2K on R/3. Thanks enzo

  • SETUP STEPS OF A MULTI-ORG

    I AM LOOKING FOR A DETAIL LIST OF THE SETUP STEPS OF A MULTI-ORG. null