"returning into" result is null with insert operation (only in apex)

I'm attempting to capture my primary key or the rowid identifying a particular row when inserted into a table (9.2.0.8) and placing it into an apex variable. I've not been successful using the following methodology. My plsql inserts my data into SM_ORDER successfully. Any suggestions?
MY TABLE -
CREATE TABLE "SM_ORDER"
+( "ORDER_ID" NUMBER NOT NULL ENABLE,+
++ "CUSTOMER_ID" NUMBER NOT NULL ENABLE,++
++ "SAMACCOUNTNAME" VARCHAR2(20) NOT NULL ENABLE,++
++ "ORDER_DATE" DATE NOT NULL ENABLE,++
++ CONSTRAINT "SM_ORDER_PK" PRIMARY KEY ("ORDER_ID") ENABLE++
+)+
+/+
CREATE OR REPLACE TRIGGER "BI_SM_ORDER"
before insert on "SM_ORDER"
for each row
begin
if :NEW."ORDER_ID" is null then
select "SM_ORDER_SEQ".nextval into :NEW."ORDER_ID" from dual;
end if;
end;
+/+
ALTER TRIGGER "BI_SM_ORDER" ENABLE
+/+
MY PLSQL -
declare
r rowid;
order_id_hold number;
begin
select SM_ORDER_SEQ.nextval
into order_id_hold
from dual;
insert into SM_ORDER (CUSTOMER_ID,
SAMACCOUNTNAME,
ORDER_DATE)
values (:F111_CURRENT_CUSTOMER,
+:APP_USER,+
SYSDATE)
returning ORDER_ID
into order_id_hold;
+:P5_ORDER_ID_HOLD := order_id_hold;+
end;
NOTE: If I do it as a straight SQL statement, it works fine.
declare
r rowid;
order_id_hold number;
begin
select      SM_ORDER_SEQ.nextval
into       order_id_hold
from       dual;
insert into SM_ORDER (CUSTOMER_ID,
SAMACCOUNTNAME,
ORDER_DATE)
values              (:F111_CURRENT_CUSTOMER,
+:APP_USER,+
SYSDATE)
returning             ORDER_ID
into                  order_id_hold;
dbms_output.put_line (order_id_hold);
end;
+/+
*49*
*1 row(s) inserted.*
*0.04 seconds*
Thank you!
Paul

I have something similar in one of my applications.
Have you tried it like this?
CREATE OR REPLACE TRIGGER "BI_SM_ORDER"
before insert on "SM_ORDER"
for each row
l_order_id number;
begin
  select SM_ORDER_SEQ.nextval into l_order_id from dual;
:NEW.ORDER_ID := l_order_id;
end;
*Your PLSQL* -
declare
  r rowid;
  order_id_hold number;
begin
  insert into SM_ORDER (CUSTOMER_ID,
                       SAMACCOUNTNAME,
                       ORDER_DATE)
  values (:F111_CURRENT_CUSTOMER,
             :APP_USER,
             SYSDATE)
  returning ORDER_ID
  into order_id_hold;
  :P5_ORDER_ID_HOLD := order_id_hold;
end;The if-then in your trigger was redundant, so was the select-nextval in your PL/SQL. This exact structure works for me.

Similar Messages

  • Database Adapter insert operation with return value

    Hi All,
    I have a table with auto generate parimary key in DB2 database. I need to have an insert operation ont this table which should return current value of primary key after insert.
    For this , I have created an insert operation in DB Adapter. But this insert operation in oneway operation.
    Is there any way I can create an Insert operation in DB2 adapter which returns the primary key value?
    Thanks
    --Sree                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Sree,
    With insert operation it is not possible. You may use stored procedure/function to perform insert and return the required value, and call this SP/function using DB Adapter.
    Regards,
    Anuj

  • Degrading performance when running consecutive insert operations

    Hi,
    I'm using DB-XML (2.5.16) as a backend storage for a web application that works on top of a TBX (TermBase eXchange) document. The application is using the Python bindings and development is being done on GNU/Linux with Python 2.6.
    The document is stored in a node-storage container, autoindexing is off at the time of container creation and transactions are enabled.
    After a set of indexes are set, queries work quite fast.
    On the other hand, when users input new data (terms) or perform edits on existing data, insert and replace operations have instant effect.
    The application has also a feature to insert lots of new terms in a single click, resulting in a new insert operation for each term. If the amount of terms to be inserted is relatively small (let's say ~10), the operation is quickly performed and the user receives a response almost instantly.
    Anyway, the problem arises when there are lots of new terms to be inserted. It starts working fast but performance quickly starts to degrade badly, needing more long seconds for each insert operation. Python's CPU-usage seems to go up to 100% when doing the actual insert, too.
    I understand this is not the best-working scenario for DB-XML (a single large document), but I don't think this performance is normal or acceptable.
    I have tried increasing Berkeley DB's cache size to 64MB with no success.
    Any hints about what should I be looking at? any more recommendations?
    These are the defined indexes:
    dbxml> listindexes
    Index: node-element-equality-string for node {}:admin
    Index: node-element-equality-string for node {}:descrip
    Index: node-attribute-equality-string edge-attribute-equality-string for node {}:id
    Index: node-attribute-equality-string for node {http://www.w3.org/1999/xhtml}:lang
    Index: unique-node-metadata-equality-string for node {http://www.sleepycat.com/2002/dbxml}:name
    Index: node-element-equality-string for node {}:ref
    Index: node-element-equality-string node-element-substring-string for node {}:term
    Index: node-element-equality-string for node {}:termNote
    Index: node-attribute-equality-string edge-attribute-equality-string for node {}:type
    9 indexes found.Container information:
    dbxml> info
    Version: Oracle: Berkeley DB XML 2.5.16: (December 22, 2009)
             Berkeley DB 4.8.30: (2010-12-09)
    Default container name: cont.dbxml
    Type of default container: NodeContainer
    Index Nodes: on
    Auto-indexing: off
    Shell and XmlManager state:
         Transactional, no active transaction
         Verbose: on
         Query context state: LiveValues,Eager

    As you both have mentioned I have tried increasing the cache size to 512MB or even to 1GB (I have recreated the entire DBs after setting cache sizes), but I don't see any significative improvements.
    I have also tried to tune my insert queries, and now I think they're in better shape than before. I would say the initial inserts feel slightly faster, but this only happens when the DB is empty (just bootstrapped). Then, once the DB has some term entries and grows in size, it starts to degrade and inserting becomes expensive in order of magnitudes.
    Each insert operation is performed in a separate transaction. And yes, I'm using transactions all over the application.
    Vyacheslav, I'll send you a couple of containers along with insert queries created by the application so you can play with.

  • A question about piecewise insert(OCI), only data in the first piece ..

    When i do a piecewise insert operation, only data in the first piece was inserted into the column, There is no error occured. a OCI_SUCCESS returned when the last piece operation completed.
    I am really puzzled now:(.
    Who can get me out of this?
    The data to be insert are stored in many structs:
    typedef struct test_st{
         char * buffer;
         struct test_st * next;
    } TEST_ST;
    I use malloc(size) to allocate the buffer of each struct, and I use strcpy() to copy some strings to these buffers.
    table mc_test is like this:
    id number;
    message varchar(64);
    The full source_code goes there:
    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <oci.h>
    static OCIEnv *p_env;
    static OCIError *p_err;
    static OCISvcCtx *p_svc;
    static OCIStmt *p_sql;
    static OCIDefine p_dfn    = (OCIDefine ) 0;
    static OCIBind p_bnd    = (OCIBind ) 0;
    const char * orausername="out_user";
    const char * orapassword="user_out";
    const char * oraserver="bigfish";
    int oraOK=0;
    int rc;
    char errbuf[100];
    int errcode;
    int checkerr(OCIError *errhp, sword status);
    int db_init(void);
    int db_open(void);
    int db_close(void);
    typedef struct test_st{
         char * buffer;
         struct test_st * next;
    } TEST_ST;
    int db_save_to_test(){
         char               sql_str[512];
         ub4                    typep;
         ub4                    piec_status;
         ub1                    in_outp;
         ub4                    rownum;
         ub4                    arr;
         sb2                    indp;
         ub2                    r_code;
         int                    t_buff_len;
         int                    total_len=15;
         int                    buffer_pos=0;
         TEST_ST * content, * t;
         content=(TEST_ST *) malloc(sizeof(TEST_ST));
         content->buffer= (char *) malloc(5);
         strcpy(content->buffer,"1234");
         content->next=(TEST_ST *) malloc(sizeof(TEST_ST));
         content->next->buffer= (char *) malloc(5);
         strcpy(content->next->buffer,"5678");
         content->next->next=(TEST_ST *) malloc(sizeof(TEST_ST));
         content->next->next->buffer= (char *) malloc(5);
         strcpy(content->next->next->buffer,"9012");
         content->next->next->next=NULL;
         if(!_ora_OK){
              return 0;
         printf("-------------------------\n");
         printf("[db]save to mc_test..\n");
         printf("total: %d bytes\n",total_len);
         /* create sql */
         sprintf(sql_str,"insert into mc_test(id,message)values(1,:x)");
         //printf("%s\n",sql_str);
         rc = OCIStmtPrepare(p_sql, p_err, sql_str,
              (ub4) strlen(sql_str), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT);
         checkerr(p_err,rc);
         rc = OCIBindByPos(p_sql, &p_bnd, p_err, (ub4) 1,
                   (dvoid *) content->buffer, total_len, SQLT_CHR, (dvoid *) 0,
                   (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DATA_AT_EXEC);
         checkerr(p_err,rc);
         rc = OCIStmtExecute(p_svc, p_sql, p_err, (ub4) 1, (ub4) 0,
              (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT);
         checkerr(p_err,rc);
         if(rc == OCI_NEED_DATA){
              printf("[pw] start........\n");
              // insert next pieces
              t=content;
              printf("%d bytes total.\n",total_len);
              while(t!=NULL){
                   if(t==content){
                        piec_status=OCI_FIRST_PIECE;
                        t_buff_len=strlen(t->buffer);
                        buffer_pos=t_buff_len+1;
                        printf("ready for first piece: %d bytes\n",t_buff_len+1);
                        printf("__________________\n%s\n__________________\n",t->buffer);
                   }else if(t->next==NULL){
                        piec_status=OCI_LAST_PIECE;
                        t_buff_len=strlen(t->buffer);
                        buffer_pos+=t_buff_len+1;
                        printf("ready for last piece: %d bytes\n",t_buff_len+1);
                        printf("__________________\n%s\n__________________\n",t->buffer);
                   }else{
                        piec_status=OCI_NEXT_PIECE;
                        t_buff_len=strlen(t->buffer);
                        buffer_pos+=t_buff_len+1;
                        printf("ready for next piece: %d bytes\n",t_buff_len+1);
                        printf("__________________\n%s\n__________________\n",t->buffer);
                   t_buff_len++;
                   rc = OCIStmtSetPieceInfo((dvoid *)p_bnd,
    (ub4)OCI_HTYPE_BIND, p_err, (dvoid *)t->buffer,
    & t_buff_len, piec_status, (dvoid *) 0, &r_code);
                   checkerr(p_err,rc);
                   rc = OCIStmtExecute(p_svc, p_sql, p_err, (ub4) 1, (ub4) 0,
                        (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT);
                   checkerr(p_err,rc);
                   t=t->next;
              if(rc==OCI_SUCCESS){
                   printf("All insert OK\n");
              printf("-------------------------\n");
              return 0;
         }else if(rc==OCI_SUCCESS){
              printf("Simple inserted.\n");
              printf("-------------------------\n");
              return 1;
         }else{
              checkerr(p_err,rc);
              printf("-------------------------\n");
              return 0;
    int main(){
         db_init();
         db_open();
         db_save_to_test();
         db_close();
    int db_close(){
         rc = OCILogoff(p_svc, p_err); /* Disconnect */
         rc = OCIHandleFree((dvoid *) p_sql, OCI_HTYPE_STMT); /* Free handles */
         rc = OCIHandleFree((dvoid *) p_svc, OCI_HTYPE_SVCCTX);
         rc = OCIHandleFree((dvoid *) p_err, OCI_HTYPE_ERROR);
         oraOK=0;
         return rc;
    int db_open(){
         /* Connect to database server */
         rc = OCILogon(p_env, p_err, &p_svc, orausername, strlen(_ora_username), orapassword, strlen(_ora_password), oraserver, strlen(_ora_server));
         if (rc != 0) {
         OCIErrorGet((dvoid *)p_err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
         printf("Error - %.*s\n", 512, errbuf);
         return(8);
         /* Allocate SQL */
         rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_sql,
              OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0);
         checkerr(p_err,rc);
         oraOK=1;
         return rc;
    int db_init(){
         rc = OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0, /* Initialize OCI */
              (dvoid * (*)(dvoid *, size_t)) 0,
              (dvoid * (*)(dvoid *, dvoid *, size_t))0,
              (void (*)(dvoid *, dvoid *)) 0 );
         /* Initialize evironment */
         rc = OCIEnvInit( (OCIEnv **) &p_env, OCI_DEFAULT, (size_t) 0, (dvoid **) 0 );
         /* Initialize handles */
         rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_err, OCI_HTYPE_ERROR,
              (size_t) 0, (dvoid **) 0);
         rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_svc, OCI_HTYPE_SVCCTX,
              (size_t) 0, (dvoid **) 0);
         checkerr(p_err,rc);
         return rc;
    int checkerr(OCIError *errhp, sword status){
         text errbuf[512];
         sb4 errcode = 0;
         switch(status){
              case     OCI_SUCCESS:
                        return 0; break;
              case     OCI_SUCCESS_WITH_INFO:
                        (void) printf("Error - OCI_SUCCESS_WITH_INFO\n");
                        break;
              case     OCI_NEED_DATA:
                        (void) printf("Error - OCI_NEED_DATA\n");
                        break;
              case     OCI_NO_DATA:
                        (void) printf("Error - OCI_NODATA\n");
                        break;
              case     OCI_ERROR:
                        (void) OCIErrorGet((dvoid *)errhp, (ub4) 1, (text *) NULL, &errcode,
                                       errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
                        (void) printf("Error - %.*s\n", 512, errbuf);
                        break;
              case     OCI_INVALID_HANDLE:
                        (void) printf("Error - OCI_INVALID_HANDLE\n");
                        break;
              case     OCI_STILL_EXECUTING:
                        (void) printf("Error - OCI_STILL_EXECUTE\n");
                        break;
              case     OCI_CONTINUE:
                        (void) printf("Error - OCI_CONTINUE\n");
                        break;
              default:
                        break;
         return 1;
    ref: http://www.oracle.com.cn/onlinedoc/appdev.920/a96584/oci05bnd.htm#427755

    On Windows, the Flash player plugin DLL is under C:\Windows. When everything is working correctly, Firefox finds the Flash player by checking entries under a registry key. I don't know whether this check takes place every time Firefox restarts, or at other intervals.
    Other plugins may install differently, e.g., copying a DLL into a folder under c:\Program Files (x86). It's rare for a plugin to be profile-specific.
    If your plugin list is not updating, the pluginreg.dat file that stores plugin information might be corrupted. This article has a section on how to delete that file so Firefox will regenerate it: [https://support.mozilla.org/en-US/kb/troubleshoot-issues-with-plugins-fix-problems#w_re-initializing-the-plugins-database]. Does that help?

  • Error With Insert Into From Select

    Hello,
    I have a problem with this query in pl sql developer with oracle 10G:
    insert into ca_nrj_rem(imsi,id_gamme_vente,domaine,date_topage,id_produit)
    (select a1.* from (select d.imsi, 1, 4, trunc(sysdate - 1), 'NRJ003'
    from ca_evenement_vsim a, ca_forfait b, ca_forfait c, ca_vsim_associe d
    where a.id_action = 'CP1'
    and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'ancienCode') = b.code_forfait
    and b.code_gamme = 2
    and bao.Lecture_Parametre_XML_V2(a.valeur_parametres, 'nouveauCode') = c.code_forfait
    and c.code_gamme = 6
    and date_trace > sysdate - 6
    and a.vsimid = d.vsimid
    and d.date_fin is null
    group by d.imsi, trunc(sysdate - 1)) a1, ca_nrj_rem n
    where a1.imsi=n.imsi(+) and n.imsi is null);
    The select statement return X (163) values but the insert statement inserts Y (540) values
    Can you help me please ?
    Thanks You

    user511447 wrote:
    The select statement return X (163) values but the insert statement inserts Y (540) valuesNot possible if the select statements are identical.
    You'll have to provide more evidence and example output (format it on the forum by putting {noformat}{noformat} before and after it), so we can see exactly what you are doing.
    Are you sure that the table you are inserting into has no rows initially or that you are counting the rows correctly?
    Show us exactly what you are doing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Is it possible to insert data into a MySQL database with Java?

    Hello everyone!
    I would like to know, if it's possible to insert data into a MySQL database, with a JFrame inside a servlet?
    When the JFrame is first created it calls this method:
         * Connects the servlet with the MySQL database.
        private void connect(){
            try{
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/data", "root", "omfg123");
            }catch(ClassNotFoundException cnfe){
                cnfe.printStackTrace();
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }Then, when you click the "Add" button, it executes this code:
                add.addActionListener(new ActionListener(){
                    @Override
                    public void actionPerformed(ActionEvent ae){
                        String employee = employeeName.getText();
                        String[] args = employee.split(" ");
                        firstName = args[0];
                        lastName = args[1];
                        execute();
                });And this is my "execute()" method:
         * Connects the servlet with the MySQL database.
         * - And executes the SQL queries.
        private void execute(){
            try{
                PreparedStatement statement = connection.prepareStatement("insert" +
                        " into employees values(" + firstName + ", " + lastName
                        + ")");
                ResultSet result = statement.executeQuery();
                String fullName = firstName + " " + lastName;
                printer.write("Employee " + fullName + " added.</br>");
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }But when I click the "Add" button, nothing happens.

    This is what I use to insert into mysql. It works on windows.
    try {
                Class.forName("com.mysql.jdbc.Driver");
                String connectionUrl = "jdbc:mysql://" + loadip + "/custsig?" +
                        "user=root&password=";
                Connection con = DriverManager.getConnection(connectionUrl);
                newproc = jTextField1.getText();
                newsoft = jTextField2.getText();
                newdeb = jTextField3.getText();
                newcust = jTextField4.getText();
                if (newcust.equals("")) {
                    errorsig12 = 1;
                    jLabel1.setForeground(new java.awt.Color(255, 0, 0));
                } else if (newsoft.equals("")) {
                    errorsig12 = 1;
                    jLabel2.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newproc.equals("")) {
                    errorsig12 = 1;
                    jLabel3.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newdeb.equals("")) {
                    errorsig12 = 1;
                    jLabel4.setForeground(new java.awt.Color(0, 0, 0));
                if (errorsig12 == 0) {
                    PreparedStatement ps = con.prepareStatement("insert into customer set cust_name = ?,  software = ?, processor = ?, debit = ?");
                    ps.setString(4, newdeb);
                    ps.setString(3, newproc);
                    ps.setString(2, newsoft);
                    ps.setString(1, newcust);
                    int rs = ps.executeUpdate();
            } catch (SQLException eg) {
                System.out.println("SQL Exception: " + eg.toString());
            } catch (ClassNotFoundException cE) {
                System.out.println("Class Not Found Exception: " + cE.toString());
            }

  • How to convert Smart Form into PDF format and return the result in BAPI?

    I want to convert a Smart Form into PDF format and return the result in BAPI.
    can anyone tell me how it can be done with related example
    regards
    pranay

    hi,
    smart form to pdf--
    All you have to do is call your SF to get OTF and then concert it to PDF. Works like charm:
    DATA: p_output_options TYPE ssfcompop,
    p_control_parameters TYPE ssfctrlop.
    p_control_parameters-no_dialog = 'X'.
    p_control_parameters-getotf = 'X'.
    CALL FUNCTION v_func_name "call your smartform
    EXPORTING
    output_options = p_output_options
    control_parameters = p_control_parameters
    IMPORTING
    job_output_info = s_job_output_info.
    call function 'CONVERT_OTF_2_PDF'
    tables
    otf = s_job_output_info-otfdata
    lines = t_pdf
    and if u need more u can check below links also
    Check the below links..
    Re: Smartforms to PDF
    Re: smartform (otf) as pdf and sending as email-attachment
    VISIT THIS LINK
    Re: Smartforms to PDF
    PLZ REWARD POINTS IF IT HELPS YOU
    rgds
    anver

  • How [Insert|Add] Image into Opening PDF file with Acrobat SDK.

    Hi Guys,
    I'm trying to insert|add image file into opening PDF file with specified location (X|Y) and scale (Width|Hight) but got many of troubles
    If use third party like iTextSharp or something else thing become simple but i want to use Acrobat SDK to do this
    Any suggestion or idea?
    Any help appreciated.

    Thank for your interested.
    I use VB.NET and Acrobat
    Here is some my code:
    Try
       If File.Exists(T(0)) Then
       Dim AcroAVDoc As AcroAVDoc = Ap.GetActiveDoc
       Dim AcroPDDoc As AcroPDDoc = AcroAVDoc.GetPDDoc
       Dim AcroPDPage As Acrobat.AcroPDPage = AcroPDDoc.AcquirePage(Integer.Parse(T(3)))
       Dim data() As String = T(1).Split("^")
       Dim imgX = data(0)
       Dim imgY = data(1)
       Dim imgWidth = data(3)
       Dim imgHight = data(4)
       'TODO: insert into opening PDF file
       Return 1
       End If
       Catch ex As Exception
       End Try
    I don not know what to do next to insert an image (JPEG, PNG, ..) into PDF file.
    Can you show me or suggest some solution, idea?
    Thank in advance.

  • DIServer insert operations for sales orders with error

    DIServer insert operations for sales orders with
    That even though the insert is inserted DocDueDate DocDueDate it says error.
    Subtracting the value of the format 'yyyy-mm-dd', 'yyyy/mm/dd', 'mm-dd-yyyy', 'mm/dd/yyyy' put all reporting
    When the input is entered DocDueDate ShipDate also put together ... but I get an error.
    The error message 'env: Receiver-10Enter due date [ORDR.DocDueDate] 171AddObject2EEE7D98-AB71-464A-93AB-933F0AD3D4DC'
    Purchase order entered into the normal value because the xml is missing or wrong with you.
    Please answer all the possibilities that can be resolved
    This Xml used.
    "<BOM>" +
    "<BO>" +
    "<AdmInfo>" +
    "<Object>oOrders</Object>" +
    "</AdmInfo>" +
    "<QueryParams>" +
    "<DocEntry />" +
    "</QueryParams>" +
    "<Documents>" +
            "<row>" +
            "<DocType>I</DocType>" +
            "<DocDate>2012-01-11</DocDate>" +
            "<DocDueDate>2012-01-11</DocDueDate>" +
            "<CardCode>CD00001</CardCode>" +
            "<Address>Anymode</Address>" +
            "<DocCurrency>KRW</DocCurrency>" +
            "<Comments>[sales orders] LGU TEST</Comments>" +
            "<TaxDate>2012-01-11</TaxDate>" +
            "<JournalMemo>JournalMemo</JournalMemo>" +
            "<Address2>Addr</Address2>" +
            "<BPL_IDAssignedToInvoice>1</BPL_IDAssignedToInvoice>" +
            "</row>" +
    "</Documents>" +
    "<Document_Lines>" +
            "<row>" +
            "<ItemCode>ACDT0100ET</ItemCode>" +
            "<Quantity>1</Quantity>" +
            "<Price>5000</Price>" +
            "<DiscountPercent>10</DiscountPercent>" +
            "<WarehouseCode>A100</WarehouseCode>" +
            "<VatGroup>A2</VatGroup>" +
            "</row>" +
    "</Document_Lines>" +
    "</BO>" +
    "</BOM>";

    I had the same error change the Date to the format yyyymmdd, and problem solved.

  • Strange results with Insert statement having select query

    Hi all,
    I am facing a strange issue with Insert statement based on a select query having multiple joins.
    DB- Oracle 10g
    Following is the layout of my query -
    Insert into Table X
    Select distinct Col1, Col2, Col3, Col4, Function(Col 5) from Table A, B
    where trunc(updated_date) > = trunc(sysdate-3)
    and join conditions for A, B
    Union
    Select Col1, Col2, Col3, Col4, Function(Col 5) from Table C, D
    trunc(updated_date) > = trunc(sysdate-3)
    and join conditions for C, D
    Union
    .... till 4 unions. all tables are residing in the local Database and not having records more than 50,000.
    If I execute above insert in a DBMS job, it results into suppose 50 records where as if I execute the select query it gives 56 records.
    We observed following things-
    a) no issue with size of tablespace
    b) no error while inserting
    c) since query takes lot of time so we have not used Cursor and PLSQL block for inserting.
    d) this discrepancy in number of records happens frequently but not everytime.
    e) examined the records left out from the insert, there we couldn't find any specific pattern.
    f) there is no constraint on the table X in which we are trying to insert. Also tables A, B, C....
    I went through this thread -SQL insert with select statement having strange results but mainly users are having either DB Links or comparison of literal dates, in my case there is none.
    Can somebody explain why is the discrepancy and what is the solution for it.
    Or atleast some pointers how to proceed with the analysis.
    Edited by: Pramod Verma on Mar 5, 2013 4:59 AM
    Updated query and added more details

    >
    Since I am using Trunc() in the where clause so timing should not matter much. Also I manually ruled out records which were updated after the job run.
    >
    The first rule of troubleshooting is to not let your personal opinion get in the way of finding out what is wrong.
    Actually this code, and the process it represents, is the most likely CAUSE of the problem.
    >
    where trunc(updated_date) > = trunc(sysdate-3)
    >
    You CANNOT reliably use columns like UPDATED_DATE to select records for processing. Your process is flawed.
    The value of that column is NOT the date/time that the data was actually committed; it is the date/time that the row was populated.
    If you insert a row into a table right now, using SYSDATE (8am on 3/5/2013) and don't commit that row until April your process will NEVER see that 3/5/2013 date until April.
    Here is the more typical scenario that I see all the time.
    1. Data is inserted/updated all day long on 3/4/2013.
    2. A column, for example UPDATED_DATE is given a value of SYSDATE (3/4/2013) in a query or by a trigger on the table.
    3. The insert/update query takes place at 11:55 PM - so the SYSDATE values are for THE DAY THE QUERY BEGAN
    4. The data pull begins at 12:05 am (on 3/5/2013 - just after midnight)
    5. The transaction is COMMITTED at 12:10 AM (on 3/5/2013); 5 minutes after the data pull began.
    That data extract in step 4 will NEVER see those records! They DO NOT EXIST when the data pull query is executed since they haven't been committed.
    Even worse, the next nights data pull will not see them either! That is because the next pull will pull data for 3/5/2013 but those records have a date of 3/4/2013. They will never get processed.
    >
    Job timing is 4am and 10pm EST
    >
    Another wrinkle is when data is inserted/updated from different timezones and the UPDATED_DATE value is from the CLIENT pc or server. Then you can get even more data missed since the client dates may be hours different than the server date used for the data pull process.
    DO NOT try to use UPDATED_DATE type columns to do delta extraction or you can have this issue.

  • How to insert data into two tables linke with foreign key..

    I have two tables
    1)EMP(emp_ID,username,emp_type_code)
    emp_ID is primary key, emp_type_code is a foreign key references emptype table.
    2)emptype(emp_type_code,emp_type_descripton)
    emp_type_code is primary key
    Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..

    CREATE TABLE "CATDB"."DWDIMUSER"
    "USER_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_ID" NUMBER(10,0),
    "FULLNAME" VARCHAR2(20 BYTE),
    "FNAME" VARCHAR2(20 BYTE),
    "LNAME" VARCHAR2(20 BYTE),
    "USER_SUBTYPE" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
    CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
    CREATE TABLE "CATDB"."DIMSPECIALTY"
    "SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_NAME" VARCHAR2(100 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
    SELECT DISTINCT
    Engineer AS FullName,
    regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
    regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
    'Engineer'
    FROM EMPLOYEELOOKUP;
    INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
    SELECT DISTINCT SPECIALITY
    FROM EMPLOYEELOOKUP;
    COMMIT;
    CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
    CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
    "EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
    "ENGINEER" VARCHAR2(25 BYTE),
    "SPECIALTY" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    DATA IN EMPLOYEELOOKUP
    Engineer, Specialty,
    John, Dow, Electronis,
    Dow, Jons, Technician
    Stan Smithers Sales
    Mark, Richards Marketing
    Jenny, Lane Marketing
    John, Lee Sales
    I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
    BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY.

  • Inserting blanks into a NOT NULL CHAR column

    How do you insert a value of blank/spaces into a NOT NULL CHAR column. Oracle 9i interprets the space as a NULL and the insert fails because the column does not allow NULLS. Thanks in advance.

    Hi,
    19:07:13 topgun>create table t1(c1 varchar2(10) not null);
    Table created.
    19:07:33 topgun>insert into t1 values (' ');
    1 row created.
    19:07:42 topgun>select * from t1;
    C1
    19:07:46 topgun>select count(*) from t1;
      COUNT(*)
             1
    19:07:53 topgun>select * from V$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production- Pavan Kumar N

  • Null pointer Exception with removeRowWithKey operation

    Hii experts,,,
    I am using JDevelepor 11.1.2.1.0 Version
    I Am new in ADF ,
    In My sample application i select row in iterator by findIterator() method
    then get the specified row by getCurrentRow();
    then i get the rowKey By row.getKey() method..
    I put rowKey as parameter to removeRowWithKey operation
    I have get null pointer Exception with removeRowWithKey operation
    java.lang.NullPointerException
         at oracle.jbo.server.ViewRowSetImpl.prepKeyForFind(ViewRowSetImpl.java:5352)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:5394)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:5296)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:5290)
         at oracle.jbo.server.ViewObjectImpl.findByKey(ViewObjectImpl.java:11536)
         at oracle.adf.model.binding.DCIteratorBinding.removeRowWithKey(DCIteratorBinding.java:3748)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1598)
    how can solve this???

    thanks Timo
    through this URL i get possible deletion methods...
    pls give more Information about the concept of removeRowWithKey, setCurrentRowWithKey, setCurrentRowWithKeyValue operation.... Just For Knowledge....
    Edited by: NZL on Mar 2, 2012 9:37 AM
    Edited by: NZL on Mar 2, 2012 9:42 AM

  • Why does the Java method ServletContext.getResourceAsStream return null with a know good path to an xsl file?

    iPLANET ISSUE
    Why does the Java method ServletContext.getResourceAsStream return null with a know good path to an xsl file?
    CODE
    ServletContext context = mpiCfg.getServletConfig().getServletContext();
    // Debugging
    out.print(context.getServerInfo());     // Get server info
    out.print(&#8220;getRealPath = &#8221; + context.getRealPath("WEB-INF/xsl/RedirectToAcs.xsl"));
    String strXslName = "RedirectToAcs.xsl";
    InputStream is = context.getResourceAsStream("WEB-INF/xsl/"+ strXslName);
    TRACE FROM THE LOG
    [26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]getServerInfo() = iPlanet-WebServer-Enterprise/6.0, getRealPath() = C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl\RedirectToAcs.xsl
    [26/Jul/2002:08:23:15] info ( 2868): [0][][ClearCommerceCcpaMpi][]strXslName = RedirectToAcs.xsl, is = null
    [26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][16]ResourceAsStream is null
    [26/Jul/2002:08:23:15] info ( 2868): [1][][ClearCommerceCcpaMpi][30]Problem reading XSL file.
    DIRECTORY DUMP
    C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl>dir
    Volume in drive C has no label.
    Volume Serial Number is 9457-EBF4
    Directory of C:\iPlanet\Servers\web-apps\ccpa\WEB-INF\xsl
    07/22/2002 05:54p <DIR> .
    07/22/2002 05:54p <DIR> ..
    07/22/2002 05:54p 3,086 RedirectToAcs.xsl
    07/22/2002 05:54p 3,088 Response.xsl
    2 File(s) 6,174 bytes
    2 Dir(s) 1,797,405,696 bytes free

    I think there's supposed to be a forward slash before WEB-INF.
    InputStream is = context.getResourceAsStream("/WEB-INF/xsl/"+ strXslName);

  • Help Export TABLE Records into Flat File with INSERTs - error

    Hi,
    When i'm trying to run this procedure I got this error:
    ORA-00932:inconsistent datatypes: expected - got -
    Can anybody tell me why?
    Thanks
    CREATE OR REPLACE PROCEDURE generate_stmt(prm_table_name IN VARCHAR2,
    prm_where_clause IN VARCHAR2,
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2) IS
    TYPE ref_cols IS REF CURSOR;
    mmy_ref_cols ref_cols;
    mmy_column_name VARCHAR2(100);
    mmy_column_data_type VARCHAR2(1);
    mmy_col_string VARCHAR2(32767);
    mmy_query_col_string VARCHAR2(32767);
    V_FILE_HNDL UTL_FILE.file_type;
    begin
    OPEN mmy_ref_cols FOR
    SELECT LOWER(column_name) column_name
    FROM user_tab_columns
    WHERE table_name = UPPER(prm_table_name)
    ORDER BY column_id;
    LOOP
    FETCH mmy_ref_cols
    INTO mmy_column_name;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_col_string := mmy_col_string || mmy_column_name || ', ';
    mmy_query_col_string := mmy_query_col_string || ' ' || mmy_column_name || ',';
    END LOOP;
    CLOSE mmy_ref_cols;
    V_FILE_HNDL := UTL_FILE.FOPEN('TEST','TESST.TXT', 'W');
    mmy_col_string := 'INSERT INTO ' || LOWER(prm_table_name) || ' (' ||
    CHR(10) || CHR(9) || CHR(9) || mmy_col_string;
    mmy_col_string := RTRIM(mmy_col_string, ', ');
    mmy_col_string := mmy_col_string || ')' || CHR(10) || 'VALUES ( ' ||
    CHR(9);
    mmy_query_col_string := RTRIM(mmy_query_col_string,
    ' || ' || '''' || ',' || '''' || ' || ');
    dbms_output.put_line(mmy_column_name);
    OPEN mmy_ref_cols
    FOR ' SELECT ' || mmy_query_col_string ||
    ' FROM ' || prm_table_name ||
    ' ' || prm_where_clause;
    loop
    FETCH mmy_ref_cols
    INTO mmy_query_col_string;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_query_col_string := mmy_query_col_string || ');';
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_col_string);
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_query_col_string);
    end loop;
    end;

    Buddy,
    Try this..
    CREATE OR REPLACE PROCEDURE generate_stmt
    (prm_table_name IN VARCHAR2,
    prm_where_clause IN VARCHAR2,
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2) IS
    TYPE ref_cols IS REF CURSOR;
    mmy_ref_cols ref_cols;
    mmy_column_name VARCHAR2(100);
    mmy_column_data_type VARCHAR2(1);
    mmy_col_string VARCHAR2(32767);
    mmy_query_col_string VARCHAR2(32767);
    V_FILE_HNDL UTL_FILE.file_type;
    begin
    OPEN mmy_ref_cols FOR
    SELECT LOWER(column_name) column_name
    FROM user_tab_columns
    WHERE table_name = UPPER(prm_table_name)
    ORDER BY column_id;
    LOOP
    FETCH mmy_ref_cols
    INTO mmy_column_name;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_col_string := mmy_col_string || mmy_column_name || ', ';
    mmy_query_col_string := mmy_query_col_string || ' ' || mmy_column_name || ',';
    END LOOP;
    CLOSE mmy_ref_cols;
    mmy_col_string := 'INSERT INTO ' || LOWER(prm_table_name) || ' (' ||CHR(10) || CHR(9) || CHR(9) || mmy_col_string;
    mmy_col_string := RTRIM(mmy_col_string, ', ');
    mmy_col_string := mmy_col_string || ')' || CHR(10) || 'VALUES ( ' ||CHR(9);
    mmy_query_col_string := RTRIM(mmy_query_col_string,' || ' || '''' || ',' || '''' || ' || ');
    V_FILE_HNDL := UTL_FILE.FOPEN('TEST','TESST.TXT', 'W');
    OPEN mmy_ref_cols FOR 'SELECT ' || mmy_query_col_string ||' FROM ' || prm_table_name ||' ' || prm_where_clause;
    loop
    FETCH mmy_ref_cols INTO mmy_query_col_string;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_query_col_string := mmy_query_col_string || ');';
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_col_string);
    UTL_FILE.PUT_LINE(V_FILE_HNDL, mmy_query_col_string);
    end loop;
    UTL_FILE.FCLOSE(V_FILE_HNDL);
    END;
    This would work for table with one and only one column.
    Look at the line below:
    FETCH mmy_ref_cols INTO mmy_query_col_string;
    mmy_query_col_string has been declared as string...So it would hold single value only.That's the reason when you try this block on table with more than one column,mmy_query_col_string would've to hold a table row type data which it would not...
    Good luck!!
    Bhagat

Maybe you are looking for

  • Please help with Ipad calendar app

    Everyday when I open my calendar app in day view, it always show the last date when I view the calendar. It does not automatically switch to Today's date. In other words, if I open the calendar yesterday dec 24, when I open this morning dec 25 the da

  • Leopard killed my mini... HELP!  :_(

    After many years of faithful service, I decided to give my mini (intel solo) a well deserved upgrade. I got Leopard from the Apple Store, installed, upgraded to the latest version (10.5.4), played with it throughout the weekend, and then, as I sat to

  • I have a MBP 5.1 and I get the following kernel panics:

    MBP 2,4 GHz Intel Core 2 Duo, 8 GB 1333 MHz DDR3 ram and I am running Maveriks and eversince I have upgraded to Maveriks I have kernel panics. I have deleted a few apps that cause some of the panics and it seemed to solve it for a day or two. But I a

  • How to determine old price

    Hi, My client sends material from manufacturing plant to depots. While such stock transfer they have one price, say 1000. Now material is received at depot and lies there. After some time price is changed, say from 1000 to 2000. Now again this materi

  • [SOLVED]Wine 1.0

    ok I downloaded Wine 1.0 source stuff and then took a million years to compile, makeinstall, and then it install. Well I don't think it really installed because none of the wine commands work. such as Wine and winecfg. I did uninstall wine 9.6 before