passing BOLB or CLOB parameters in stored procedures

Hi all
I have this procedure for the insertion of the data:
 create or replace procedure procedure_employee( pname in varchar2, ppicture in blob) is begin insert into employee (name, picture) values (pname, ppicture);
end;
/ 
.
How can I insert images while creating an employee? Can I have an example of performing my procedure?
Kind regards
SQL> CREATE TABLE pdm(dname VARCHAR2(30),sname VARCHAR2(30),fname VARCHAR2(30),iblob BLOB);

Table created.

SQL> CREATE OR REPLACE PROCEDURE load_file(pdname IN VARCHAR2,
  2                                        psname IN VARCHAR2,
  3                                        pfname IN VARCHAR2) IS
  4
  5    src_file BFILE;
  6    dst_file BLOB;
  7    lgh_file BINARY_INTEGER;
  8  BEGIN
  9    src_file := bfilename('TEMP', pfname);
 10
 11    INSERT INTO pdm
 12      (dname, sname, fname, iblob)
 13    VALUES
 14      (pdname, psname, pfname, EMPTY_BLOB())
 15    RETURNING iblob INTO dst_file;
 16
 17    DBMS_LOB.OPEN(src_file, dbms_lob.file_readonly);
 18    lgh_file := dbms_lob.getlength(src_file);
 19    DBMS_LOB.LOADFROMFILE(dst_file, src_file, lgh_file);
 20    dbms_lob.close(src_file);
 21    COMMIT;
 22  END load_file;
 23  /

Procedure created.

SQL> CREATE OR REPLACE DIRECTORY TEMP AS 'c:\';

Directory created.

SQL> EXECUTE load_file('Test pdname','Test psname','extract.jpg');

PL/SQL procedure successfully completed.

SQL> SELECT dname,sname,fname,DBMS_LOB.getlength(iblob)
  2  FROM pdm;

DNAME                          SNAME
------------------------------ ------------------------------
FNAME                          DBMS_LOB.GETLENGTH(IBLOB)
------------------------------ -------------------------
Test pdname                    Test psname
extract.jpg                                         2111

SQL> 

NOTE: The path to the 'TEMP' directory object exists already physically in the server database NOT in the local computer.

Tags: Database

Similar Questions

  • Pass complex Types with chains to stored procedures: become null

    Hello

    I would like to pass an array of strings or a type of custom to a PL/SQL stored procedure object, you use the JDBC thin driver. It is possible if the tables or object types contain integers. With strings (resp. varchar2) However, I encountered a repetitive problem, no matter what I tried: the varchar2 field seems to be null in the stored procedure.

    There is something special with the passage of short strings?

    I tested with Oracle version server 10.2.0.3, 10.2.0.4 and 11.1.0.7.0.
    JDBC Thin drivers used are ojdbc14.jar is of 10.2.0.4 and ojdbc5.jar 11.1.0.7.0.
    I use Java 5.

    Tested approaches include:
    -oracle.sql.StructDescriptor, preparedStatement.setSTRUCT, or setStruct
    -Pass a Java type that implements the SQLData with preparedStatement.setObject
    -Pass a Java type that implements ORAData and ORADataFactory

    I tested it with an example of metalink (Doc ID 458572.1), and as I said, this example shows the same problem: strings passed appear as null - in three versions of Oracle that I tested. The example has been changed only with respect to the scheme name.
    ()Doc ID 458572.1 refers to a bug that shows the behavior I describe here, but this bug should be fixed in 10.2.0.4 and 11).

    I can paste some of my source code, but I feel that the solution could be found elsewhere, such as problems, version mismatch, the character set...

    Any ideas on the specialties with passage of strings in types of objects or paintings? My strings are null. (For tables, I get the right amount of NULL values).
    I even checked that I can pass a string argument simple to a procedure that worked indeed.

    Kind regards
    Carsten

    There is something special with the passage of short strings?

    Yes, this is a common problem. You must include orai18n.jar classpath. BTW it is documented here and here.

  • NLS parameters in stored procedure

    Hello

    I've struggled for some time with the release of one of my SPs
    It goes like this:
    Begin
    Declare the cursor as a query
    loop and write lines in a file
    end

    It is, I can't seem to be able to set the NLS settings correctly. I need the dates out as YYYY-MM-DD HH24:MI:SS, but it doesn't seem to work at all. The columns are the DATE data type, but no matter what I do (of course I do something wrong!) I'm not able to get output only HH24:MI:SS AAAA-MM-JJ.

    I tried to use TO_DATE DBMS_SESSION in the query, the immediate execution of the ALTER SESSION SET NLS_DATE.... SET_NLS. Nothing seems to work, any help is appreciated (maybe I lost the DMBS_SESSION.) SET_NLS or something?).

    Example code:
    CREATE OR REPLACE PROCEDURE TEST  (parameters.. ) AS 
    /*variables*/
       
    BEGIN 
      DECLARE CURSOR c_AICTT IS 
              SELECT TO_DATE(DATE1,'YYYY-MM-DD HH24:MI:SS'), DATE2 FROM DATES; 
    .
    .
    .
    Thanks in advance,
    NACEUR

    Looks like what you want is not TO_DATE, TO_CHAR.

    Don't change the NLS settings; they "belong" to the customer, not to your code.

    To_char will make an explicit conversion, the NLS settings does not come into play.

  • Stored procedure to add a record do not add record

    I have never successfully added a record via a stored procedure, but I managed with adding records through behaviors using recordsets with stored procedures and server, so I know that connections work. I have the data to MS SQL Server and ColdFusion web page. When I enter data and click 'Submit', it does absolutely nothing. When I check the SQL table, no record has been added. Any help would be greatly appreciated. Here are my stored procedure:


    Replace:



    Null value

    With:

    I provide each form with a value variable by default so that a value will always exist for each variable.

    Use the null attribute, if the value is 'yes', WHAT NULL value will be passed to the parameter of the stored procedure, if the content of the attribute value will be used

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/help.HTML?content=Tags_p-q_14.html#1102102

  • 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('<p>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.

  • Passing parameters to the query to extract in a stored procedure

    How pass us in a parameter of a query retrieves in a stored procedure?

    Because for example I: -.

    FOR SheikYerbouti in company

    LOOP

    SELECT extract (response,'/ list/hwid [@name = "Tom"] / descendant::node () / address) employee where id = 9506;

    END OF LOOP

    Instead of TOM, I want to pass a variable because I use the stored procedure. The variable is emp_rec.name

    SELECT extract (response,'/ list/hwid [@name = emp_rec.name]/descendant::node()/address) employee where id = 9506; does not work?

    The XPath expression is of type string, concatenate the value:

    extract (answer, "/ List/hwid[@name="' |) emp_rec. Name | ([""] descendant::node () ')

    However, depending on your version of the database, there may be better alternatives, so if you can give us a little more explanation on your requirement, we would be able to offer other options.

  • 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.
    "

  • 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.

  • [BC] Call a stored procedure taking parameters of table

    Hello!

    I currently have a request of the OIC that makes thousands of calls per second stored procedure. The stored procedure runs a business logic that I want my client application to stay informed.  I want to reduce the cat of the database and instead to call the stored procedure from thousands of times per second, call the procedure (for example) once per second, but with values of one mile.

    I used OCIBindArrayOfStruct successfully to perform inserts bulk, where my OCI application executes a () INSERT INTO using the function "iters" and it might be possible to do something similar with the stored procedure, but I want to do something slightly different, because the procedure stored something like this:

    * If a specific condition is set, call a secondary stored procedure

    * If another special condition is set, insert a row into a table of some

    I so wanted to do was to pass a table (or a series of tables) in the stored procedure, then the stored procedure to use optimal methods that are available, such as FORALL, to perform each of the tasks, the more effectively.

    So I thought to create a type, such as a TABLE OF VARCHAR2, or a VARRAY and possessing of the parameters for the stored procedure based on this type, something like:

    create or replace TYPE 'NTT_VARCHAR2' AS TABLE OF VARCHAR2 (32700);

    create or replace FUNCTION bulk_process_values)

    p_error_message OUT NOCOPY VARCHAR2,

    p_module_context_name OUT NOCOPY VARCHAR2,

    p_sql_error OUT NOCOPY VARCHAR2,

    p_count in NUMBERS

    p_non_array_var_1 IN VARCHAR2,

    p_non_array_var_2 IN VARCHAR2,

    p_array_var_1 IN NTT_VARCHAR2,

    p_array_var_2 IN NTT_VARCHAR2,

    p_array_var_3 IN NTT_VARCHAR2

    < etc. for all the variables in table >)

    RETURN NUMBER

    .. .but I am struggling to find an example of how call the procedure "bulk_process_values" stored, and even if I use a TABLE OF VARCHAR2 or a VARRAY as a parameter type.

    I searched the Internet and found this: OIC - how to bind an array to a stored procedure? - and binding table of the structs (OCIBindArrayOfStruct) sample code

    - but they take different approaches and a bit confused (the second example spoke of OTT).

    I think that the first approach is more likely to be the solution I need - but I can't help thinking - it is a bunch of stuff to move if it does not end up significantly improve performance!

    My questions are:

    * Moves to a call-SP-thousands-of-times-per-second to call-SP-fewer-times-but-with-array-parameters sensitive?

    * Should the table or VARRAY, TABLE OF VARCHAR2 parameters or something else?

    * Should I use for my case OTT?

    Samples I found are both very old - and the second example indicators that the optimal approach evolves with the OCI versions - I'm on 11.2, what is the optimal approach these days?

    * < added later > why is there no official useful example?

    Thank you very much

    Much appreciated. https://community.oracle.com/message/4528528#4528528 has actually worked, with VARRAY, with a proof of concept. Now I just need to shake a little and then get my PL/SQL for optimal PC experts. I think I was really discouraged by the lack of official documents, with the Community (Paradise) is the only way to get real results.

    Thank you JJ.

    I intend me to use the binding enforcement of the table and the table and avoid N back and forth, but I do not then get the opportunity to do something clever in the PL/SQL.

    In the PL/SQL, there is no logic occurring - I don't call the same SP tons of times, but then I want to be able to use PL/SQL optimizations such as FORALL, BULK COLLECT, reduce the number of validations and others.  There is a commit after each SP run, because otherwise the nature of demand means that the application hangs occur; However, there is a way (I think) be smart on the part that is likely to deadlock (making a shape on the Bay First, then applying the updates in the order sorted and then failed to get a blocking theoretically), and then FORALL insert for the second part of the stored procedure.

    I guess I may apply the single return, passing a table (to a commit in the SP)-which will reduce back and forth, so gain in performance, but it will not reduce the number of validations that I do - and Oracle said that commits too frequent is not good for performance. I already have code in my framework that does - by making a simple INSERT INTO.

    Good to hear that OTT is not explicitly required - and VARRAY resembles the approach to try first.

  • Call to the stored procedure parameter passing script

    Hello

    I have a database on linux server. On the same server, there is a shell script which takes 3 parameters.

    Now I want to do a procedure (stored procedure) that will have 3 parameters pass and run this script with these settings.

    I had created object directory pointing to the correct directory granted all privileges on it (I hope).

    Now, I wondered how the code of procedure?

    I also did a program within the database which takes 3 parameters, but I don't know how to operate it. I don't know if I can use work to run the program, because

    It is a multi user thing and I think that this will not work as expected if 2 or more users run it.

    In any case, I was hoping that I can solve this problem by creating the procedure that will run the script that is provided with 3 parameters, that I need.

    I hope I'm clear on what I want to do.

    Please if you have an idea how to Edifier post your ideas.

    Thank you!

    Hello

    first I want to thank you for the reply.

    option 1... I don't want not to use java or c because I have no skills in programming languages.

    option 2 you mentioned dbms_scheduler.

    If I understand the procedure should go like that.

    I create whitin database program. Then I create a job which runs this program. And whenever I want to run my shell script, I'll do the work.

    WHA happen if 2 different users will want to run the script at the same time?

    Thank you for your response.

  • How to pass an array as a parameter to a stored procedure

    Hi all
    I want to pass the name of a table as a parameter in a stored procedure, which will be used for cursors, etc..
    But when I pass the parameter and I compile the S.P. he gives me error (error: table exist not...)

    Any help?

    Thanks in advance, Marco

    Cannot open a cursor explicit when it comes to the dynamic table names or parameters. This is because the explicit and implicit cursors seek real table names since they are static.
    Here your name of the table is dynamic, so u need to use dynamic that is ref cursor to and not static cursor.

    I made the correction in the code below. Run it and check the result!

    CREATE OR REPLACE PROCEDURE "P_1" ( TAB1 VARCHAR2)
    AS
    field1 CHAR(5);
    field2 CHAR(5);
    
    c1 sys_refcursor;
    
    begin
    
    l_str := 'select a,b,c from '||tab1||' INNER JOIN tab2 ON a = .......';
    open c1 from l_str;
    
    /*OPEN C1;
    CURSOR C1
    IS
    SELECT a, b , c
    FROM TAB1
    INNER JOIN
    tab2
    ON a = .......
    OPEN C1;*/
    
    LOOP
    FETCH C1
    INTO ..... 
    
    EXIT WHEN C1%NOTFOUND;
    .....
    END;
    END LOOP;
    
    CLOSE C1;
    
    EXCEPTION
    WHEN OTHERS
    .....
    END;
    
  • How to pass an object of the stored procedure?

    Hello.

    After reading the documentation online 'The JDBC Oracle9i developer reference Guide' how to use oracle.sql.STRUCT to pass the java classes to database objects and how do the same thing in the sense opposite, I still don't know how to do what I need, I would like to know a few resourse online where I could find more examples.
    I guess it must be quite easy to do.

    I learned to create a java class that will be used to call a stored procedure (9i database) that has a single input/output parameter whose type is a user-defined object.

    I'm trying to do something similar, by I was not able. This is my essay:

    CREATE OR REPLACE TYPE                  FERNANDO.TIPOBD AS OBJECT (   ID INTEGER,   NOMBRE VARCHAR2(50),   HORA TIMESTAMP ); / CREATE OR REPLACE PACKAGE FERNANDO.prueba_java AS   PROCEDURE prueba (objetoJava IN OUT TIPOBD); END prueba_java; / CREATE OR REPLACE PACKAGE BODY FERNANDO.prueba_java AS   PROCEDURE prueba (objetojava IN OUT TIPOBD)   AS   BEGIN       NULL;   END prueba; END prueba_java; /
    import java.sql.*; //import oracle.sql.*; import oracle.jdbc.*; import oracle.sql.*; public class Prueba { public static void main(String[] args) { Connection conexion = GestorConexion.getConexion(); if (conexion != null) {   try {     DatabaseMetaData meta = conexion.getMetaData();     System.out.println("JDBC driver version is " + meta.getDriverVersion()); int num = 0; String consulta = "select 1 from dual"; PreparedStatement ps = conexion.prepareStatement(consulta); ResultSet rs = ps.executeQuery(); if (rs.next()) { num = rs.getInt(1); } System.out.println("num == "+num); ObjetoOracle oo = new ObjetoOracle(1, "Fernando", new Timestamp(1) ); System.out.println("id: "+oo.getId()+"; nombre: "+oo.getNombre()); // Se llama al procedimiento almacenado String llamada = new String(); llamada += "BEGIN "; llamada += "  FERNANDO.prueba_java.prueba(?)"; llamada += "END;"; StructDescriptor structdesc = StructDescriptor.createDescriptor("FERNANDO.TIPOBD", conexion); STRUCT struct = new STRUCT(structdesc, conexion, null); OracleCallableStatement ca = (OracleCallableStatement)conexion.prepareCall(llamada); //ca.setObject(1, oo); ca.setObject(1, null); ca.registerOutParameter(1, OracleTypes.JAVA_OBJECT); ca.execute(); } catch (SQLException sqle) { System.out.println(sqle.toString()); } } else { System.out.println("CONEXIÓN con bd nula"); } } }

    My if intend to create an oracle.sql.STRUCT object that I'll pass to the procedure and then get back to the procedure, but I can not even create the StructDescriptor.
    It is the output that I get:

    Conexión con BD ok JDBC driver version is 9.2.0.8.0 num == 1 id: 1; nombre: Fernando java.sql.SQLException: Tipo no definido: get_next_type

    Any help would be welcome. Thanks in advance.

    You must add the name of the type of your call registerOutParameter (.).
    ca.registerOutParameter ("", OracleTypes.JAVA_OBJECT, FERNANDO. TIPOBD);

    You can consider using OracleTypes.STRUCT instead of JAVA_OBJECT.

    You must also change your call set *;.
    ca.setObject ("", FERNANDO of the object. TIPOBD, OracleTypes.STUCT);

    You can use the same string parameter "" to the two parameters or
    You can use the same parameter INT for both parameters.

    You cannot combine parameters named and numbered together. I was using both for a single method or both using the other.
    The syntax may be different according to the method you in order to verify the Java Doc.

  • How to access the xml stored procedure clob?

    Hello
    I am producing what appears to be a simple bit of code (just a simple report in the form of a web page), while what I've tried so far only does not work. I come back kind of clob broken by the stored procedure, so I feel it's almost right, but who knows at this point. TIA

    Here is an excerpt from Oracle:

    -p_XMLReport ON CLOB,
    -qryCtx DBMS_XMLGEN.ctxHandle;
    -sql_stmt VARCHAR2 (32767).

    qryCtx: = DBMS_XMLGEN.newContext (sql_stmt);
    p_XMLReport: = DBMS_XMLGEN.getXML (qryCtx);

    Here's a snippet of VB:

    Conn = New OracleConnection
    Dim cmd As New OracleCommand
    Dim rs As OracleDataReader
    Try
    Connection group conn cmd.
    Conn. Open()
    cmd.CommandText = "GETDATA".
    cmd.CommandType = CommandType.StoredProcedure
    cmd. Parameters.Add (New OracleParameter ("p_XMLReport", OracleDbType.Clob)). Direction = ParameterDirection.Output
    cmd. Parameters.Add (New OracleParameter ("p_Conditions", OracleDbType.Clob)). Value = "'" + conditions + "'."
    cmd. Parameters.Add (New OracleParameter ("p_Fields", OracleDbType.Clob)). Value = "'" + fields + "'."
    RS = cmd. ExecuteReader()
    xmlDoc = New XmlDocument
    CLOB Dim As String
    CLOB = (cmd. Parameters ("p_XMLReport"). (Value). Value ' kind of work...
    Response.Write ("< pre >")
    Response.Write (clob)

    Usually you would call ExecuteReader only if you use a query or a proc that returns a ref cursor

    See if that helps,
    Greg

    /*
    create or replace procedure getxmlclob(v1 out clob) as
    qryCtx DBMS_XMLGEN.ctxHandle;
    sql_stmt VARCHAR2(32767);
    begin
    sql_stmt := 'select * from all_objects';
    qryCtx := DBMS_XMLGEN.newContext (sql_stmt);
    v1 := DBMS_XMLGEN.getXML(qryCtx);
    end;
    /
    */
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    
    class Program
    {
        static void Main(string[] args)
        {
            using (OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl"))
            {
                con.Open();
                using (OracleCommand cmd = new OracleCommand("", con))
                {
                    cmd.CommandText = "getxmlclob";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("foo", OracleDbType.Clob, ParameterDirection.Output);
                    cmd.ExecuteNonQuery();
                    Console.WriteLine(((OracleClob)cmd.Parameters["foo"].Value).Value.ToString());
                }
            }
        }
    }
    
  • Get the EXIT and the RETURN of a stored procedure parameters

    I have a stored procedure (SQL Server 2008 R2 MS) as in the following example.

    Thanks to the connectivity of database I get OUTPUT parameters, but I can't get the game DATA RECORDS and RETURN value.

    Someone knows how to do this?

    CREATE PROCEDURE [dbo]. [TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR (20), @STATUS INT OUTPUT, OUTPUT OF NVARCHAR (500) OF @ERRO)

    AS

    BEGIN
    DECLARE THE TABLE @TABLE (CODE INT, DESCRIPTION VARCHAR (30))

    INSERT VALUES INTO @TABLE (51, 'A')
    INSERT VALUES INTO @TABLE (52, 'B')

    INSERT VALUES INTO @TABLE (53, 'C')

    SELECT * FROM @TABLE

    SET @STATUS = 1

    SET @ERRO = "Nenhum erro!

    RETURN 0

    END

    I finally found what was wrong... He had a line in the stored procedure only aditional. It should be like this:

    CREATE PROCEDURE [dbo]. [TS_Teste] (@T057_S_NOMEMAQUINA VARCHAR (20), @STATUS INT OUTPUT, OUTPUT OF NVARCHAR (500) OF @ERRO)

    AS

    BEGIN
    SET NOCOUNT ON;                                                                                               -NEW LINE!

    DECLARE THE TABLE @TABLE (CODE INT, DESCRIPTION VARCHAR (30))

    INSERT VALUES INTO @TABLE (51, 'A')
    INSERT VALUES INTO @TABLE (52, 'B')

    INSERT VALUES INTO @TABLE (53, 'C')

    SELECT * FROM @TABLE

    SET @STATUS = 1

    SET @ERRO = "Nenhum erro!

    RETURN 0

    END

  • SQL stored procedure input and output parameters

    Hello Gang,

    My dead end trying to call a stored procedure in SQL Server 2008 with the LV database tool.

    for purposes of experimentation, I've created a small procedure with an input parameter that returns an integer as return value.  It works describing a query, but all attempts at LV produce an error-2147217900 when executing query VI.  I did find examples of that.

    Sending a bunch of parameters to a stored procedure and checking the value of return seems to be pretty common stuff.

    I'll appreciate any help.

    Thank you

    Roger

    Hi Roger,

    There are a few prerequisites which I will list below. If you have not checked these things, so don't hesitate, as your hiccups can be there.

    Prerequisites:

    1. Ensure that you can read from a table in the database to verify that you can access the database (user permissions) and ensure that your login details are correct. Among other things, make sure that the. DSN switches to the correct database. (See the simple example below, SQL Select.vi)
    2. Make sure that your user (if you use SQL authentication) has permissions to run the STORED procedure by running the procedure in SQL Server Management Studio (you seem to have already done this)

    Example by calling a procedure without parameters (attached as SPROC_No_Parameters.vi):

    Example by calling a procedure with parameters (attached as SPROC_Parameters.vi):

    An article on the execution of stored procedures is here:

    http://digital.NI.com/public.nsf/allkb/07FD130746083E0686257300006326C4

    Don't forget to download the example VI since it includes the cases where you want an output parameter of the procedure rather than a table.

    I tested these against two very simple SPROCs and it worked fine (on SQL Server 2005, but 2008 should be the same).  Stored procedures have been:

    CREATE PROCEDURE [dbo]. [GetContacts]

    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT * FROM Contacts
    END

    and

    CREATE PROCEDURE [dbo]. [MultiplyAges]
    @param1 INT = 1
    AS
    BEGIN
    -SET NOCOUNT ON added to avoid additional results sets from
    -interfering with SELECT statements.
    SET NOCOUNT ON;

    -Controls insert for procedure here
    SELECT (age * @param1) OF Contacts
    END

    I would like to know if these examples work for you or if you have any other questions.  Don't forget to go through this KB article and articles related to it, they should cover other situations.

    Matt

Maybe you are looking for

  • Play HTML5 video with JavaScript does not hide the overlay dimming video

    I googled this problem and found nothing useful and also checked the area of support here and still nothing. I'm creating a webpage with HTML5 video. I made a layer with the video object that is hidden with CSS, until the user clicks on a link. When

  • Drive necessary recovery for Qosmio F60

    Hello A friend went to the laptop.HDD is cactus!This means the recovery partion is... cactus! Ive looked everywhere, to the ends of the world and almost fell off the edge. Because of the power Toshiba recovery disks, and if so, where the frack do I g

  • Page "save under" appears when I try to print from Firefox

    When I use my Verizon DSL and Firefox (this doesn't happen if I use Explorer int.) and I wish to print information from the internet, I do a Ctl P for print. Instead of print, I get a page "save under" I can not help to appear. The page includes: "sa

  • Application of the Dock car

    When I look at the running applications (start |) Menu | Manage Apps | Running tab) I see an application called CarDock running. I do not see this application in the application list and can't access it any way. Does anyone know how to do?

  • How to make a recovery disk partition?

    I have an acer aspire one notebook. He had a recovery partition where I could reinstall windows by pressing Alt + F10 during post (D2D recovery). This partition has been deleted by formatted the disc on a windows installation 8. Now, I want to make a