Bulck of variable form XMLType insert stored procedure and registry failed in another table

Hi, I use: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production and I'm trying to create a procedure to insert an XML save the registry defective inserts and return them.


In the main procedure of , I analyze the XML and call the function to insert the line. If I get a FAKE, I want to do an insert into a table called InsertEmballagFailed:


It is not parsing correctly I do not know why?


CREATE OR REPLACE PROCESS INSERT_PALET_WITH_XML ( )

v_Palet IN VARCHAR2,

v_XML IN XMLType)

IS 

v_numemb varchar2 (9);

v_typemb varchar2 (1);

v_prefix varchar2 (2);

v_anyo number 4;

v_mes NUMBER (2);

v_poidsbrut NUMBER (8);

v_qte NUMBER (8);

v_date_creation varchar2 (10);

v_heure_creation varchar2 (8);

v_numlot varchar2 (8);

v_numord varchar2 (8);

v_typenumct varchar2 (20);

v_flagano NUMBER (5);

v_cnuf varchar2 (8);

v_resultinsert boolean;

v_resultinsertStr varchar2 (5);

START 

FOR r IN

SELECT ExtractValue (Value (p),' / ROW/NUMEMB / text () '() as v_numemb

ExtractValue (Value (p),' / ROW/TYPEMB / text () '() as v_typemb

ExtractValue (Value (p),' / ROW/PREFIX / text () '() as v_prefix

TO_NUMBER (ExtractValue (Value (p),' / ROW/ANYO / text () ')) as v_anyo

TO_NUMBER (ExtractValue (Value (p),' / ROW/MY/text () ')) as v_mes

TO_NUMBER (ExtractValue (Value (p),' / ROW/POIDSBRUT / text () ')) as v_poidsbrut

TO_NUMBER (ExtractValue (Value (p),' / ROW/QTY / text () ')) as v_qte

ExtractValue (Value (p),' / ROW/DATE_CREATION / text () '() as v_date_creation

ExtractValue (Value (p),' / ROW/HEURE_CREATION / text () '() as v_heure_creation

ExtractValue (Value (p),' / ROW/NUMLOT / text () '() as v_numlot

ExtractValue (Value (p),' / ROW/NUMORD / text () '() as v_numord

ExtractValue (Value (p),' / ROW/TYPENUMCT / text () '() as v_typenumct

TO_NUMBER (ExtractValue (Value (p),' / ROW/FLAGANO / text () ')) as v_flagano

ExtractValue (Value (p),' / ROW/CNUF / text () '() as v_cnuf

DE TABLE(XMLSequence (extract (v_XML,' / LINES/LINES '))) p

) LOOP

v_resultinsert: = INSERT_ROW_IN_EMBALLAG)

v_numemb, v_typemb, v_prefix, v_anyo, v_mes, v_poidsbrut, v_qte, v_date_creation,

v_heure_creation, v_numlot, v_numord, v_typenumct, v_flagano, v_cnuf);

v_resultinsertStr: = BOX

WHEN v_resultinsert THEN 'True ' 

WHEN Not v_resultinsert THEN 'False'

END

END LOOP; 

ENGAGE

EXCEPTION

TypeNumCt Varchar2 (20).

PRIMARY KEY (Palet_Id, NumEmb)); 

WHEN Others THEN 

ROLLBACK

RAISE_APPLICATION_ERROR (-20001, 'an error occurred-'|) SQLCODE: "- ERROR -" || SQLERRM); 

END INSERT_PALET_WITH_XML; /


The secondary function called from the beginning. And give a 'false' if he can't. (This part is ok).


CREATE OR REPLACE FUNCTION INSERT_ROW_IN_EMBALLAG ( )

v_numemb IN VARCHAR2,

v_typemb IN VARCHAR2,

v_prefix IN VARCHAR2,

v_anyo IN NUMBER,

v_mes IN NUMBER,

v_poidsbrut IN NUMBER,

v_qte IN NUMBER,

v_date_creation IN VARCHAR2,

v_heure_creation IN VARCHAR2,

v_numlot IN VARCHAR2,

v_numord IN VARCHAR2,

v_typenumct IN VARCHAR2,

v_flagano IN NUMBER,

v_cnuf IN VARCHAR2) RETURN Boolean

IS 

v_resp boolean;

START 

INSERT IN package ( )

NumEmb, TypEmb, prefix, Anyo, my, PoidsBrut, ETA, Date_Creation, Heure_Creation,

NumLot, NumOrd, TypeNumCt, FlagAno, CNUF)

VALUES

v_numemb, v_typemb, v_prefix, v_anyo, v_mes, v_poidsbrut, v_qte, v_date_creation,

v_heure_creation, v_numlot, v_numord, v_typenumct, v_flagano, v_cnuf);

ENGAGE

RETURN TRUE

EXCEPTION

WHEN Others THEN 

ROLLBACK

RETURN FALSE

END INSERT_ROW_IN_EMBALLAG; 

/


To try, I make this appeal:


CALL INSERT_PALET_WITH_XML ('570002217', XMLType(' ))

< Rowset > 

< LINE > 

< NUMEMB > 570002217 < / NUMEMB > 

< TYPEMB > 1 </ TYPEMB > 

< The PREFIX > 56 < / the PREFIX > 

< ANYO > 2013 </ ANYO > 

< MY > 4 </ MES > 

< POIDSBRUT > 29120 < / POIDSBRUT > 

< QTY. > 8 </ QTE > 

< DATE_CREATION > 27/04/2013 </ DATE_CREATION > 

< HEURE_CREATION > 09.58.17 < / HEURE_CREATION > 

< NUMLOT > 55555 < / NUMLOT > 

< NUMORD > 77777779 < / NUMORD > 

< TYPENUMCT > 0 < / TYPENUMCT > 

< FLAGANO > 0 </ FLAGANO > 

< CNUF > 8411061 < / CNUF > 

</ LINE > 

</ Rowset > 

'));


Thanks for any help.

Joel

You're not (wrongly) referring to values of implicit cursor what records were not properly inserted. So I changed the code and given below. Please check and let me know in case of any problems.

CREATE OR REPLACE PROCEDURE INSERT_PALET_WITH_XML)

v_Palet IN VARCHAR2,

v_XML IN XMLType)

IS

/ * v_numemb varchar2 (9);

v_typemb varchar2 (1);

v_prefix varchar2 (2);

v_anyo number 4;              -No need... Then removed-

v_mes NUMBER (2);

v_poidsbrut NUMBER (8);

v_qte NUMBER (8);

v_date_creation varchar2 (10);

v_heure_creation varchar2 (8);

v_numlot varchar2 (8);

v_numord varchar2 (8);

v_typenumct varchar2 (20);

v_flagano NUMBER (5);

v_cnuf varchar2 (8); */

v_resultinsert boolean;

v_resultinsertStr varchar2 (5);

BEGIN

FOR (IN) r

SELECT ExtractValue (Value (p),'/ ROW/NUMEMB/text () ') as v_numemb

, ExtractValue (Value (p),'/ ROW/TYPEMB/text () ') as v_typemb

, ExtractValue (Value (p),'/ ROW/PREFIX/text () ') as v_prefix

, TO_NUMBER (ExtractValue (Value (p),'/ ROW/ANYO/text () ')) as v_anyo

, TO_NUMBER (ExtractValue (Value (p),'/ ROW/MY/text () ')) as v_mes

, TO_NUMBER (ExtractValue (Value (p),'/ ROW/POIDSBRUT/text () ')) as v_poidsbrut

, TO_NUMBER (ExtractValue (Value (p),'/ ROW/QTY/text () ')) as v_qte

, ExtractValue (Value (p),'/ ROW/DATE_CREATION/text () ') as v_date_creation

, ExtractValue (Value (p),'/ ROW/HEURE_CREATION/text () ') as v_heure_creation

, ExtractValue (Value (p),'/ ROW/NUMLOT/text () ') as v_numlot

, ExtractValue (Value (p),'/ ROW/NUMORD/text () ') as v_numord

, ExtractValue (Value (p),'/ ROW/TYPENUMCT/text () ') as v_typenumct

, TO_NUMBER (ExtractValue (Value (p),'/ ROW/FLAGANO/text () ')) as v_flagano

, ExtractValue (Value (p),'/ ROW/CNUF/text () ') as v_cnuf

TABLE (XMLSequence (Extract(v_XML,'/ROWSET/ROW'))) p

)

LOOP

-Reference values such as r.v_numemb (r.columnname).

v_resultinsert: = INSERT_ROW_IN_EMBALLAG)

r.v_numemb, r.v_typemb, r.v_prefix, r.v_anyo, r.v_mes, r.v_poidsbrut, r.v_qte, r.v_date_creation,

r.v_heure_creation, r.v_numlot, r.v_numord, r.v_typenumct, r.v_flagano, r.v_cnuf);

v_resultinsertStr: = BOX

WHEN v_resultinsert THEN 'True '.

WHEN Not v_resultinsert THEN 'False. '

END;

END LOOP;

COMMIT;

EXCEPTION

TypeNumCt - Varchar2 (20), - deleted... Something here-

(--A KEY primary SCHOOL (Palet_Id, NumEmb));

WHILE OTHERS THEN

ROLLBACK;

RAISE_APPLICATION_ERROR (-20001, 'an error occurred' - |) SQLCODE |' - ERROR - ' | SQLERRM);

END INSERT_PALET_WITH_XML;

/

Post edited by: 000000

Tags: Database

Similar Questions

  • Call the stored procedure, and bind parameters by name

    Hello

    I use the Oracle ODBC 12 c driver to pass values from one Interface to our database Oracle 11.2. The Interface software collects data from modbus protocoll and calls a stored procedure. Right now my syntax to call the stored procedure looks like this:

    CALL procedure-name ('STRING', 'Timestamp as String', numValue1);

    It works very well. Now, I have to add a default setting to my procedure. To stay flexible to make other changes, I want to call the procedure and bind the parameters by name. Release 10.2.0.1.0 ISC ODBC Notes:

    Added support for the named parameter, binding the parameters by name. ODBC Oracle driver now allows the application to specify the parameters of a stored procedure by name, in the procedure call. Named parameters are to be used in calls to stored procedures and should not be used in other SQL statements.

    So, it shouldn't be a problem to use named notation, but how do I do this in ODBC? I tried like this, but oracle returns an ora-00936 error of missing expression:

    call procedure-name (paramName1 = > 'STRING',= paramName2 > 'Timestamp as String',paramName3 = > numValue1).


    Thank you for your help.

    Finally, I was able to find the error. The syntax of the statement was very good. The problem was caused by another declaration that I edited before and the error has not attracted Attention immediately.

    Thanks for reading and looking for an answer.

  • How to query the DDL lock functions or stored procedures and packages?

    Hello!

    The subject says it all: how to display existing DDL locks on the functions or stored procedures and packages?

    While running a procedure, it cannot be deleted or replaced, so there must be a DDL lock on it. The information does not seem to be in V$ LOCK or V$ LOCKED_OBJECTS.

    Thank you!
    Marcus

    Published by: David on November 21, 2009 15:43

    Hello

    You have the DBA_DDL_LOCKS view.

    Best regards
    Jean Valentine

  • stored procedure and in the app engine peoplecode

    Hey all,.
    I want to call a stored procedure in peoplecode using sqlexec. I guess that the syntax is correct.
    SqlExec ("exec sp_name');

    My question is
    the peoplecode will wait until the end of the stored procedure?
    or
    is it just to send the command to the database to run the stored procedure and continue following the instructions after the exec sql.

    Please let me know if I'm not better explain and need an example.

    Please help me.
    Thank you.

    «.. . "will be the peoplecode wait for the completion of the stored procedure.
    Yes.

    Nicolas.

  • Pass parameters to the box of the HTML form to a stored procedure

    I'm always looking for a solution to my problem of forms. For the record, I don't use Express applications to create my application - I use PL/SQL right. I need to know how to pass parameters from the box to my Web form. I welcome people select one or more checkboxes in a form that calls a remove function to delete the selected records. What I read in Oracle of the "Guide to the developer of database applications - Fundamentals" is not useful to me. If someone could tell me some examples, maybe I could see what I'm doing wrong. Here is what I wrote in "the developer of database applications - fundamentals Guide ':

    All the boxes with the same NAME attribute are a group of checkbox. If none of the boxes in a group is selected, the stored procedure receives a null value for the corresponding parameter.

    If a check box in a group is selected, the stored procedure receives a single parameter of VARCHAR2.

    If more than one check box in a group is enabled, the stored procedure receives a parameter with the type of PL/SQL TABLE OF VARCHAR2. You must declare a type like this, or use a pre-defined as OWA_UTIL. IDENT_ARR. To retrieve the values, use a loop:
    CREATE OR REPLACE PROCEDURE handle_checkboxes ( checkboxes owa_util.ident_arr )
    AS
    BEGIN
    ...
    FOR i IN 1..checkboxes.count
    LOOP
    htp.print('&lt;p&gt;Checkbox value: ' || checkboxes(i));
    END LOOP;
    ...
    END;
    /
    SHOW ERRORS;

    I'm not sure that understand what your question is.

    If your web form has the following defined all with the same name:

    one
    two
    three
    

    You create and save a procedure to manage the sending of a form that contains a parameter with the name of attrib type owa_util.ident_arr for example:

    create or replace procedure handle_form(attrib owa_util.ident_arr) as
      iter number;
    begin
      for iter in attrib.first .. attrib.last loop
        -- do something with attrib(iter)
      end loop;
    end;
    /
    

    Now, the only problem with this Manager (or any other), is that if the user selects any of the boxes, or no value for the parameters expected, the Manager called with parameters missing or with on all of the passed parameters, as well as the call will error.

    To move, you need to provide default values for all parameters passed to your handler such as the settings of ident_arr, but with ident_arr settings, it's hard to do with autonomous procedures. If you place your procedure in a package you can define variables of package-level of the appropriate types that can be used as default values:

    create or replace package my_web as
      empty_arr owa_util.ident_arr;
    
      procedure handle_form(attrib owa_util.ident_arr := empty_arr);
    end my_web;
    /
    create or replace package body my_web as
      procedure handle_form(attrib owa_util.ident_arr := empty_arr) as
        iter number;
      begin
        for iter in attrib.first .. attrib.last loop
          -- do something with attrib(iter)
        end loop;
      end;
    end my_web;
    /
    

    now, when you hit in the situation where the user does not select the checkboxes, the call to handle_form will be no reviewable error on due to missing parameters, and the empty_arr will not have all the elements to iterate over so the loop in the body of the procedure will be fine and you will be able to retrieve each value of the checkbox selected attrib table when you iterate on it.

  • Insert a record, call a stored procedure and execute a shell script

    Hello

    I am trying to build a page APEX do these three things in order.

    #1. Insert a new record in a database table (pk, donnees_xml, attr1 and attr2, etc.) and download the XML file to the donnees_xml column

    #2. Save this XML file on a file system

    #3. Parse the XML file on a file system and update the database with the parsed data table

    I can do #1 with a regular shape based on the database table. I can do #2 with a stored procedure.

    I can do #3 with a shell script.

    I wonder how these tasks can be combined into a single action in APEX.

    do #1;

    If successful, do #2;

    If successful, do #3;

    I'd appreciate comments on this.

    Thank you

    Define a process of PL/SQL page submit that runs after the record is inserted, if P1_FILE is not null.

  • Problem with stored procedure and validation

    I have the following stored procedure:

    create or replace PROCEDURE SOME_PROC)

    /*

    Some settings

    */

    ) AS

    NUMBER of errors

    BEGIN

    errors: = FN_CHECK_BUSINESS_RULE_1 (/ * some args * /);

    if(Errors > 0) then

    raise_application_error (ERR_CONSTANTS. SOME_ERROR_NUMBER, ERR_CONSTANTS. SOME_ERROR_MESSAGE);

    end if;

    INSERT INTO une_table (/ * columns * /) VALUES (/ * values * /);

    END SOME_PROC;

    Because the business rule 1 is placed inside the stored procedure I can't check it out without calling the stored procedure.

    I need to call the stored procedure 10 times with a different set of parameters and validation of the changes only after all calls to the stored procedure

    are successful. I want to show the user all the errors that occurred during the stored procedure calls. If for a first example of stored procedure call

    succeeds and a second failure no data has to be stored in a database.

    How to prevent the stored procedure for insert lines until I call the method commit of ApplicationModule?

    Thanks in advance.

    No, other users only see the lines until you commit. The search term is the transaction isolation level. Tom Kite write a paper on this here ask Tom: on transaction isolation levels. This article gives some samples, according to theory, and you should read it.

    Timo

  • Call stored procedures and using its output parameters in a report

    Hello

    I have a procedure defined in a package on the database. This procedure returns a number of output parameters. How to call this procedure and use the output parameters in my report?

    Thank you, Mark

    Depends on the level at which the procedure should be called. If its at the State level, call the form in the trigger-REPORT-BEFORE (or AFTER-PARAMFORM) and store the off-values space reserved columns. These you can use anywhere in your report.

  • Stored procedures and system procedure

    Hello

    using dreamweaver CS on windows XP for ASP VB - websites with MS SQL Server 2005.

    When I try to add a command through the server Berhaviors I d like to access a stored procedure.
    1.) create new Web asp.vb
    2.) click on the 'Application' window and tab "server behaviors".
    3.) click on the "plu" and choosing "Comand".
    4.), adding the name of the command, the checkbox "Recordset" activated, adding the name of the Recordset, chhosing the connection
    5.) choice Type "stored procedure".

    Everthing works fine. But now:

    (6.) by clicking on the '+' next to 'stored procedures '.
    (7.) NOW the dreamweaver becomes a list of all THE stored procedure in the database

    Problem: Sql server has a lot of system procedures. It will never be used in a web application. So DW is on all fours on the server database for all procedures and not only those necessary (added by an ordinary database user / owner.)

    It takes a very, very long time, until the DW has all the names! Up to two minutes. In the old version of dreamweaver, the dreamweaver was just view regular - procedures not system procedures. If dreamweaver has been an excellent tool to develop web applications of high leverage comfortable.

    Now, the time is too long. Whenever I want to add a new command, I have to wait and wait.

    Is there any solution autour (configuration settings, filter setting, what ever) that the dreamweaver receives only regular procedures again?

    Also see the screenshot on http://www.fanclubs.ch/dwcs.jpg

    The solution is here:
    http://KB.Adobe.com/selfservice/viewContent.do?externalId=tn_15720&sliceId=2

    has not resolved by support here. was not solved by the helpline. Has been solved by myself to the research on the everyday life of the website with other disorders and finally found.

  • Stored procedure to remove a number of tables with a common name attribute

    Hi all

    This is my first post so I hope I posted level with enough information. This is my first stored procedure (SP) and Oracle 10.

    I'm trying to write a script to remove 11 paintings and some lines of another 3 tables, which are named with a number I want to enter at the time of the creation of MS below is the script that I wrote and edited. My original was lost by crashing the servers!

    When I run the script, it gives me the following output:

    "WARNING: execution completed with warning.
    procedure ScenarioDelete update"

    MS has not deleted one of these tables and I don't know if it's because my script is poor or because of something else. Any help is greatly appreciated!

    -table remove SP
    --
    -Race start ScenarioDelete ('x'); with the idscenario x

    create or replace procedure ScenarioDelete (ScenarioNo IN varchar2);
    countstable: = "C_". ScenarioNo;
    CHANGETABLE: = "CG_" | ScenarioNo;
    countsinfotable: = 'CI_ ' | ScenarioNo;
    DataTable1: = "D_0_" | ScenarioNo;
    datatable2: = "D_1_" | ScenarioNo;
    datatable3: = 'D_2_ ' | ScenarioNo;
    hietable1: = 'HI_0_ ' | ScenarioNo;
    hietable2: = 'HI_1_ ' | ScenarioNo;
    hietable3: = 'HI_2_ ' | ScenarioNo;
    hielinktable1: = 'HL_1_ ' | ScenarioNo;
    hielinktable2: = 'HL_2_ ' | ScenarioNo;

    AS

    run immediately 'drop table ' | countstable;
    run immediately 'drop table ' | CHANGETABLE;
    run immediately 'drop table ' | countsinfotable;
    run immediately 'drop table ' | DataTable1;
    run immediately 'drop table ' | datatable2;
    run immediately 'drop table ' | datatable3;
    run immediately 'drop table ' | hietable1;
    run immediately 'drop table ' | hietable2;
    run immediately 'drop table ' | hietable3;
    run immediately 'drop table ' | hielinktable1;
    run immediately 'drop table ' | hielinktable2;

    immediately execute "delete from USERACESS where IDSCENARIO = ' |" ScenarioNo;
    run immediately "remove scenario where IDSCENARIO = ' |" ScenarioNo;
    immediately execute "delete from SCENARIOINFO where IDSCENARIO = ' |" ScenarioNo;

    -or-

    run immediately "delete from USERACESS where IDSCENARIO =" | " ScenarioNo | ''';
    run immediately "remove scenario where IDSCENARIO =" | " ScenarioNo | ''';
    run immediately "delete from SCENARIOINFO where IDSCENARIO =" | " ScenarioNo | ''';

    END;

    Hello

    Welcome to the RTO

    If you allow me, I would like to make a suggestion to simplify your code

    Create OR Replace Procedure ScenarioDelete(ScenarioNo IN Varchar2)
    As
       Type t_DropTable Is Table Of Varchar2(30);
       v_DropTable t_DropTable := t_DropTable( 'C_', 'CG_', 'CI_', 'D_0_', 'D_1_', 'D_2_', 'HI_0_', 'HI_1_', 'HI_2_', 'HL_1_', 'HL_2_' );
    
       Type t_DeleteTable Is Table Of Varchar2(30);
       v_DeleteTable t_DeleteTable := t_DeleteTable( 'USERACESS', 'SCENARIO', 'SCENARIOINFO' );
    Begin
       -- Drop tables
       For i IN v_DropTable.First .. v_DropTable.Last Loop
          Execute Immediate 'DROP TABLE ' || v_DropTable(i) || ScenarioNo;
       End Loop;
    
       -- Delete tables
       For i IN v_DeleteTable.First .. v_DeleteTable.Last Loop
          Execute Immediate 'DELETE FROM ' || v_DeleteTable(i) || ' WHERE SCENARIOID = ' || ScenarioNo;
       End Loop;
    End;
    

    Kind regards

    Christian Balz

  • Difference between stored procedure and procedure

    Hello

    could you please let me know what is the difference between the procedure and the stored procedure PL/SQL.

    Thank you.

    Best regards
    Mohan

    Published by: user10469960 on November 21, 2008 18:33

    There is no difference. The two terms are synonymous. Intrinsically, a PL/SQL procedure is stored in the Oracle data dictionary.

    Justin

  • two related issues: to call the stored procedure and passing in an array of elements using htmldb_Get

    I need to save items of ApEx generated dynamically via AJAX.  I use the APEX_ITEM API to generate the elements.  At runtime, I have no idea how much of elements are generated on the page, but I know that they're all separate and discreet 'name' attributes, i.e. f01, f02, f03, etc..  As a basic example, if I have to generate a selection list, I know that the parameter "p_idx" of the APEX_ITEM call is to say '3', so select all lists that get generated have a "name" attribute in "f03" DOM, all text elements will be "f01", etc.

    I want to record these data in the database using AJAX.  It is common to call the javascript htmldb_Get function that is standard for the use of an application process, but I am interested in the use of the rarely called upon 'internal' and queryString"options of this javascript function so that I can build the query string to the fly according to what is on the DOM when it tries to save the data they have entered into these items generated by APEX_ITEM.  Someone at - there are good examples of the use of the 'procedure' and 'queryString' the javascript htmldb_Get function parameters?

    I have found a handful of some blogs, messages, etc. online linked to this, but just for most people regurgitate the documentation.  I found this post (https://forums.oracle.com/thread/2549237), which has had a glimpse of hope to move from a table (which is something I need) as a parameter, but as someone in their right mind would check this before you go this route.

    Shane.

    ApEx 4.2.1

    Shane

    Since you mention that you are on 4.2 APEX I advise to use apex.server.process which is replacing the htmldb_Get officially undocumented documented.

    In the literature, it is that the first parameter is the ajaxidentifier but it's actually the name of the process.

    The data object would be something like

    var lData ={f01 : get_value_array('f01')}
    

    Where is get_value_array

    function get_value_array(pColumnName) {
      var l_values =[];
      apex.jQuery('[name="'+pColumnName+'"]').each(
       function(){
        var l_value;
        l_value = apex.item(this.id).getValue();
        l_values.push(l_value);
       }
      );
      return l_values
    }
    

    For an example see this demo.

    Nicolette

  • Stored procedure and stored function

    Greetings from a newbie,
    Question about procedure and function:
    When we use procedure and function? What is the difference between the two?

    Kind regards
    Valerie

    Published by: Valerie debonair on August 24, 2009 21:27

    When we use procedure and function?

    If you need to compute and value, good idea to use the function to return.
    If you need data DML, good idea to use the procedure...

    What is the difference between the two?

    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE can return one or more values through parameters or may not return at all.

  • stored procedure - insert clob obj - msg error: ORA-01460: unimplemented

    Hi all

    I have a situation where I want to insert an object, clob to my local table using a stored procedure. The clob object stores the large amount of text. The clob data are met to retrieve the content in an external text file. When you run an insert statement in the c# code, the information was inserted successfully. When you run the stored procedure to insert the information, I always "ORA-01460: letter dead or unreasonable conversion requested". I use the StreamReader class ReadToEnd() to extract the context of the external text file. Does anyone know why Oracle is behaving in this way? Thanks for help in advance.



    TABLE DEFINITION FOR CLOB_TEST
    Name       Type         Nullable Default Comments 
    ---------- ------------ -------- ------- -------- 
    PKG_NAME   VARCHAR2(50) Y                         
    PKG_DESC   CLOB         Y                         
    PKG_FAM_ID NUMBER       Y                         
    STORED PROCEDURE
    procedure InsertTempReleaseTable(p_name        in varchar2,
                                       p_description in clob,
                                       p_fam_id      number) is
      begin
        insert into clob_test
          (pkg_name, pkg_desc, pkg_fam_id)
        values
          (p_name, p_description, p_fam_id);
      end InsertTempReleaseTable;
    EXTRACT THE CONTENTS OF A TEXT FILE
    public string GetTextFileContents(string path)
            {
                using (StreamReader sr = new StreamReader(path))
                {                
                      return (sr.ReadToEnd());
                }
            }
    C# CALL THE INSERT STORED PROCEDURE
    using (OracleCommand cmd = (OracleCommand)database.GetStoredProcCommand("pkg_sptbuildstatus.InsertTempReleaseTable"))
                {
                    cmd.Parameters.Add("p_name", OracleType.VarChar, 255).Value = obj.PackageName;  // string   
                    cmd.Parameters.Add("p_description", OracleType.Clob).Value = obj.ChangeDescription; // string
                    cmd.Parameters.Add("p_fam_id", OracleType.Number).Value = obj.FamilyId; // int
    
                    database.ExecuteNonQuery(cmd);
                }
    Published by: user8976335 on January 11, 2010 16:28

    Published by: user8976335 on January 11, 2010 16:59

    Published by: user8976335 on January 11, 2010 16:59

    Published by: user8976335 on January 12, 2010 10:48

    Well, that may (or may not) be useful to you.

    Can you test your routine with CLOB less than 32K in size (and see if this attempt is successful)?

    IF Yes, then it is possible, that's your problem...

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

    "
    they are so NOT to cross a clob, they pass a string.

    In Java or ProC or OIC you can create a clob customer, fill it and pass it.

    My guess is that they use a string and a string is not a clob and a string will be limited
    for 32 k as a variable binding, or 4000 bytes as a literal in a sql statement.
    "

  • Logic of tip insert - using a stored procedure?

    Here's my use case:

    • I have a table called TAGS that has two columns: id (number key, primary) and text (string)
    • the table has a constraint of database set that each text must be unique
    • the table also has a fixed sequence back next id available
    • I created an entity of the DB object and its default View object
    • I also created a page where I display a table read-only based on the View object
    • Finally, I added a text field and a button to the page
    • What I want to achieve is to insert all tags entered in the entry in the table fields, when the button is clicked. Note, however, that the entry field is a comma-separated list of tags, moreover, I have to insert only those tags that are new (to respect the constraint of database), and finally, I would like to use the sequence in insert or orders. Once completed, the page should also be updated.

    My first question is whether a stored procedure is the right way to perform such a step insert logical. If not, what other means must be used in the ADF.

    My second question is to know how to call the stored procedure and pass it the value of the input as a parameter field. I found this article http://andrejusb.blogspot.cz/2011/04/invoking-stored-procedures-and.html, but miss me a few transition points:

    1. How the callGreetingsFunction method call (I just get it that it's a method of the EO generated Java class?) after that the button is clicked?
    2. How to pass the value of the input field in this method as a parameter?

    Thanks in advance for your help.

    Now, what happens if I run it like this:

    A. the procedure is executed after a click on the button

    (B) the page is not updated (I had to do the research to get the new lines are visible in the table)

    C. the constraint is ignored (after discounting there were several lines with unique identification number, but pr is - empty)

    D. nothing has been committed to the database - if I closed the application window and it start again, the lines have disappeared from the table, but addition of new lines used number of increased seq

    E. Similarly, if I did directly inserts into the database, these lines did not appear until I transferred the application

    B. told it page to refresh. And that's usually enough to refresh your ViewObject with: viewObject.executeQuery)

    C. Si the constraint is not enforced for null values. And this has nothing to do with the adf, this is related to oracle db.

    D. you're calling commit.

    E. you must re-run your view object (viewObject.executeQuery ())

    Nevertheless, here is my rookie questions:

    There there a simple way to refresh the page (or just the table containing the data)?

    -How to validate changes (immediately after execution of the procedure)?

    -How is the constraint has been ignored? I am sure it would fail on validation, but I thought that it will be considered even for adding data to the table.

    -Are there a way to update the original Version of the database every time that the page is opened or refreshed?

    -Drag and drop operation Execute like button on your page (or call vo.executeQuery () by program)

    -Drag and drop the operation of posting as a button on your page (or invoke it by programming on the DBTransaction object)

    -ignored for what values? for null values? It is expected, because each null is "unique."

    -Yes, but you probably shouldn't do that for performance reasons, see this: Andrejus Baranovskis Blog: Cache results for ADF iterator property

    Read also this: Andrejus Baranovskis Blog: job ADF and PL/SQL Invocation changes side effect

    Dario

Maybe you are looking for