Pass an array to a procedure stored via SQL more.

Hi, I want to spend multiple records in a table to a store proc, where inside, I'll do some DML (insert update delete etc...)
Later the RECS will be forwarded by my application using VB/ASP etc
Currently, I want to test this backend... I have a package and a proc.
But when I call the proc, I get a wrong number of aruments to proc.


CREATE or REPLACE PACKAGE in the UPD_All_TABs
TYPE Varry_emp IS TABLE EMP % ROWTYPE;
PROCEDURE UPD_emp (SheikYerbouti in Varry_emp);
end UPD_All_Tabs;
/

Package created.

CREATE or REPLACE PACKAGE BODY UPD_ALL_Tabs as
PROCEDURE UPD_emp (SheikYerbouti in Varry_emp) is
Start
I'm looping 1.emp_rec.count
dbms_output.put_line (emp_rec (i) .nvd_zobjdev);
/If otherwise etc here end if * /.
end loop;
END UPD_emp;
/


/ * I made a copy of the emp table and modified data. Now I'm selecting and passing
It internal tmy * /.

declare
Type add_varray IS TABLE OF THE emp % ROWTYPE;
var_add_varray add_varray;
Start
SELECT * COLLECT LOOSE var_add_varray FROM tab_copy_of_emp;
UPD_ALL_Tabs.UPD_emp (var_add_varray);
end;
/
/ * This call proc does not work as a type of arguments * /.

/ * However this sub work... displays all REBS copy table * /.
declare
Type add_varray IS TABLE OF THE emp % ROWTYPE;
var_add_varray add_varray;
Start
SELECT * COLLECT LOOSE var_add_varray FROM copy_of_emp;
FOR pos IN 1.var_add_varray.count LOOP
dbms_output.put_line(pos||) e '|| var_add_varray (POS) .emp_name);
end loop;
end;
/

I have seen 100s of pages & fourms I don't have a simple solution... all use java or speak to the application.
If someone had used sql in addition, the examples show a list of hard coded values.
If there is an example of selection in bulk, its inside the proc is stored.
I want to call the proc as I have used before.
Please guide me what is the problem by calling the proc,
If java is necessary, please give me sample for the above code...
Please please help. I'm totally lost.

Maybe this will help you. He is little syntax errors in your code corrected too, those.

CREATE OR REPLACE PACKAGE UPD_All_TABs AS
TYPE Varry_emp IS TABLE OF EMPLOYEES%ROWTYPE;
PROCEDURE UPD_emp(emp_rec in Varry_emp);
end UPD_All_Tabs;

CREATE OR REPLACE PACKAGE BODY UPD_ALL_Tabs AS
PROCEDURE UPD_emp(emp_rec in Varry_emp) is
begin
for i in 1..emp_rec.count loop
dbms_output.put_line(emp_rec(i).FIRST_NAME);
end loop;
/*if else etc here end if*/
END UPD_emp;
END UPD_ALL_Tabs;

declare
  -- Non-scalar parameters require additional processing
  emp_rec upd_all_tabs.varry_emp;
begin
SELECT * BULK COLLECT INTO emp_rec FROM EMPLOYEES;
  -- Call the procedure
  upd_all_tabs.upd_emp(emp_rec => emp_rec);
end;

Tags: Database

Similar Questions

  • Special characters could not load DB via SQL * MORE

    Hi, I have a pl as .accidentally sets sql script which will insert data in database. The question is there are some records are missing and these missing records contains a special character: Sansao and Strasse. The strange was if I run the script via F5 (Toad), all data can be inserted successfully but run through SQL * MORE (Toad), all records that contain special characters are not inserted.

    Anyone here know why it didn't load these special characters via SQL * MORE?

    Probably because you have given unicode (multi byte charsets) you read with a customer of standard single-byte character set.

    It's SILLY to loading data using SQL * more. It's the wrong tool used for loading the data. It does not support the bind variable. It doesn't support liaison in bulk. It does not support direct path inserts. It is not SQL * Loader.

  • Need to import via SQL more application advice

    Hello


    I have a sql file.
    I need to import the given in a workspace of some, but I have not access to Apex Builder request to do an import wizard.
    Can I please get some directions making this import via SQL Plus, where can I find documentation in this regard so that I can import successfully.

    Thanks in advance,
    Deepa

    Hi Deepa,

    I understand now, thanks.

    To import an application using SQL * Plus, the workspace must exist (with the ID of the same workspace). The best way to ensure that the workspace ID are the same is to export the workspace to one instance and import it in another.

    In addition, you cannot change the ID of the app through SQL * more - so, if you import the application via SQL * more, either one) this application ID cannot exist, or b) if exists, it must exist in the same workspace that you import into.

    Now - with all these conditions are met, the DBA can only run as a normal SQL through SQL script * more.

    Joel

  • Create a procedure stored via CMD

    How can I create stored via cmd procedure? A few reasons, I could not use SQL DEVELOPER or TOAD in the production server, so I create a sql file that contain SP then call sql via cmd file, but it does not work. Here is the sql file

    SET pages 0

    coil D:\SP\LOG\output_log.txt

    Create or Replace procedure TRUNCATE_DATA

    IS

    BEGIN

    RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;

    RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "

    COMMIT;

    END;

    spool off

    output

    user11432758 wrote:

    How can I create stored via cmd procedure? A few reasons, I could not use SQL DEVELOPER or TOAD in the production server, so I create a sql file that contain SP then call sql via cmd file, but it does not work. Here is the sql file

    SET pages 0

    coil D:\SP\LOG\output_log.txt

    Create or Replace procedure TRUNCATE_DATA

    IS

    BEGIN

    RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;

    RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "

    COMMIT;

    END;

    spool off

    output

    COMMIT after that DDL is superfluous.

    You must actually run the code as below by adding a slash on the END following line: statement

    [oracle@localhost ~] $ cat make_it.sql

    coil output_log.txt

    Create or Replace procedure TRUNCATE_DATA

    IS

    BEGIN

    RUN IMMEDIATELY 'TRUNCATE TABLE DONNEES_1;

    RUN IMMEDIATELY 'TRUNCATE TABLE DATA_2. "

    COMMIT;

    END;

    /

    spool off

    output

    [oracle@localhost ~] $ sqlplus User1/User1 @make_it.sql

    SQL * more: Release 11.2.0.2.0-Production on Mon Dec 16 19:56:41 2013

    Copyright (c) 1982, 2010, Oracle.  All rights reserved.

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    Created procedure.

    Disconnected from the database to Oracle 11 g Enterprise Edition Release 11.2.0.2.0 - Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    [oracle@localhost ~] $

  • Calling a procedure stored since SQL * PUS

    Hi all

    I want to call a procedure from SQL * MORE who returns the number, varchar2 and one OUT parameter as table index.
    I can declare a variable for the number and varchar2.
    How can I manipulate the array index passed into the procedure output parameter.

    Thanks, Sandeep

    declare
    a number, varchar2 (20) b;
    type t as table of varchar2 (10) index directory. -identical to your procedure declaration
    c t;
    Start
    procedure (a, b, c);
    end;
    /

  • Call a procedure stored via JDBC with a REF CURSOR * input variable.

    Hello

    S/n of my client has provided me with a stored procedure that I need to call to get information about products prices. Something along the lines of:

    some_package.getPrices (products IN OUT csr_type);

    where csr_type represents a REF CURSOR. This cursor has a product ID column and a price column. The plan is to move the cursor with the populated product id column and have the routine decorate the slider with the prices.

    The setting in this plan is that it seems that it is not possible to go from JDBC REF CURSOR in . However, I'm not sure, since I can only find throw comments on various forums (e.g. http://www.orafaq.com/forum/t/35088/0/), without any reference. If I go back to the client and tell them that their idea will not work, I prefer to be able to point them to a documentation somewhere

    So I guess my questions are:

    1. it is indeed impossible to pass a REF CURSOR type as a variable input on JDBC to a stored procedure?

    2. is there information I can do about my client?

    3. am I on the right track thinking I need to go down the path of an array of objects?

    Thank you very much to anyone who can help
    Peter Svehla.

    Hi Peter,.

    I see it, missed that you actually want to pass in a list of products. Don't think that you can do this with the current procedure. A slider is just a pointer to a result set.
    How the result set is created and what it looks like, is determined when the cursor is opened.

    What does this procedure with the cursor? -It does not have some OPEN TO ; inside?

    Or, perhaps, you are supposed to send in an open cursor (does not much sense to me)?

    Concerning
    Peter

  • call a procedure stored since SQL developer UI

    I have a stored procedure that is created with a date in parameter.

    Then I tried running SQL Developer by right-clicking the stored procedure, then it comes out a parameter window and I tried to enter the value in the entry value field by entering January 1, 2015 "because I know our server date format is DD-MON-RR."

    But it shows a window of incorrect format: Please use date format YYYY-MM-DD,

    Why is this?

    The generated SQL Developer code is less after I ' 2015-01-01'

    DECLARE
    DATE OF P_DATESTORED;
    BEGIN
    P_DATESTORED: = to_date('2015-01-01','yyyy-MM-dd');

    MySproc)
    P_DATESTORED = > P_DATESTORED
    );
    -restoration;
    END;

    I can just use below: for the date, the Server format is DD-MON-RR.

    Begin

    MySproc('01-JAN-2015')

    End;

    Thank you

    We use oracle 11g 2, the window environment.

    The code is generated (SQL Developer) client-side. This code generation, by design, does not count the current NLS_DATE_FORMAT of the session. Instead, it uses the date coded hard YYYY-MM-DD format. It seems to be a design decision.

    If you want to enter this date value in a particular format, use the following snippet directly in the SQL worksheet (F5: run script), modified for your desired date format, or omitted date format - I really discourage the to do.

    DECLARE

    DATE OF P_DATESTORED;

    BEGIN

    P_DATESTORED: = to_date ('& myinput', 'YYYY-MM-DD');

    MySproc)

    P_DATESTORED-ONLINE P_DATESTORED

    );

    -restoration;

    END;

    /

  • Passing an array as a parameter of java (java controls) for the stored procedure

    Hello

    I use java controls (BEA Weblogic Workshop 8.1) to call a stored procedure and send an array as a parameter to the stored procedure of java. The following code throws an exception 'Fail to convert the internal representation.

    Java code
    import com.bea.control.DatabaseControl.SQLParameter;

    Here I create the java
    int [] = {12,13,14} javaArray.

    The code below is used to create the table from sql to oracle for the procedure
    SQLParameter [] params = new SQLParameter [1];
    Object obj0 = javaArray;
    params [0] = new SQLParameter (obj0, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);

    the code below calls the myFunc in file OJDBCtrl.jcx
    String success = dbControl.testFunc (params);

    OJDBCtrl.jcx
    /**
    * @jc: = sql statement ' call CMNT_TST_PROC (?)).
    */
    String Myfunc (SQLParameter [] param);

    The stored procedure that is used:

    SL_tab IS NUMBER TABLE INDEX BY PLS_INTEGER;
    Procedure cmnt_tst_proc (cmnt_tst sl_tab);
    Procedure cmnt_tst_proc (cmnt_tst sl_tab) is
    BEGIN
    dbms_output.put_line ('Hello');
    END;


    I'm getting the following exception

    Failure = Java.Sql.SqlException: Internal failure to convert the representation: [I@438af4 [ServiceException] >]
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
    at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:861)
    at oracle.sql.ARRAY.toARRAY(ARRAY.java:210)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7768)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7449)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7837)
    at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4587)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:244)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl._setParameter(DatabaseControlImpl.jcs:1886)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.getStatement_v2(DatabaseControlImpl.jcs:1732)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.invoke(DatabaseControlImpl.jcs:2591)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:249)
    at com.bea.wlw.runtime.jcs.container.JcsContainer.invoke(JcsContainer.java:85)
    at com.bea.wlw.runtime.core.bean.BaseContainerBean.invokeBase(BaseContainerBean.java:224)
    at com.bea.wlw.runtime.core.bean.SLSBContainerBean.invoke(SLSBContainerBean.java:109)
    at com.bea.wlwgen.StatelessContainer_ly05hg_ELOImpl.invoke(StatelessContainer_ly05hg_ELOImpl.java:153)
    ...

    Can you please let me know, what am I doing wrong and how can I pass an array to a procedure/function using java controls.

    Any help will be much appreciated.



    Published by: user12671762 on February 24, 2010 05:03

    Published by: user9211663 on February 24, 2010 21:04

    Try using an oracle.sql.ARRAY with a nested table or varray instead of a table index. Create the type SQL and Java object as follows

        SQL> create type sl_tab as varray(3) of integer;
        Java:
            ArrayDescriptor ad = ArrayDescriptor.createDescriptor
                (".SL_TAB", java.sql.Connection);
            Object elements = new Object[3];
            elements[0] = new Integer(12);
            elements[1] = new Integer(13);
            elements[2] = new Integer(14);
            oracle.sql.ARRAY array =
                new oracle.sql.ARRAY(ad, oracle.jdbc.OracleTypes.ARRAY, elements);
            SQLParameter[] params = new SQLParameter[1];
            params[0] =
                new SQLParameter(array, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
            String succ = dbControl.testFunc(params);
    

    I don't think that you can pass an array of Java, this is why you have more success using an oracle.sql.ARRAY with a SQL varray. -Michael-

  • Way of array to the procedure in setting

    Hello

    I tried the following code,
    Where my goal is to divide the comma separated values and insert into a table and then pass this array to another procedure in a package
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST AS
     PROCEDURE PROC_SPLIT(IN_LIST  VARCHAR2) ;
     END; 
    
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST AS
     PROCEDURE PROC_SPLIT(IN_LIST  VARCHAR2) ;
     END; 
     
    
    
    CREATE OR REPLACE PACKAGE PAK_SPLIT_TEST
    AS
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2);
    END;
    
    
    CREATE OR REPLACE PACKAGE BODY PAK_SPLIT_TEST
    AS
       PROCEDURE PROC_REM_LIST (p_array l_data)
       IS
       BEGIN
          FOR i IN 1 .. p_array.COUNT
          LOOP
             DBMS_OUTPUT.put_line (p_array (i));
          END LOOP;
       END;
    
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2)
       IS
          TYPE SPLIT_array IS TABLE OF VARCHAR2 (4000)
                                 INDEX BY BINARY_INTEGER;
    
          l_data   SPLIT_array;
          l_txt    LONG := '100,200,300,400,500,600';
          l_str    LONG := IN_LIST || ',';
          l_n      NUMBER;
       BEGIN
          BEGIN
             l_data.delete;
    
             LOOP
                l_n := INSTR (l_str, ',');
                EXIT WHEN NVL (l_n, 0) = 0;
                l_data (l_data.COUNT + 1) := SUBSTR (l_str, 1, l_n - 1);
                l_str := SUBSTR (l_str, l_n + 1);
             END LOOP;
    
             PROC_REM_LIST (l_data);
          END;
       END;
     
     
     SELECT *FROM USER_ERRORS
    I get the error at line n ° 30
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    
       begin end function package pragma procedure form
    Could you please help me in this

    Thank you
    Smile

    This gives a shot:

    CREATE OR REPLACE PACKAGE BODY PAK_SPLIT_TEST
    AS
          TYPE SPLIT_array IS TABLE OF VARCHAR2 (4000)
                                 INDEX BY BINARY_INTEGER;
    
       PROCEDURE PROC_REM_LIST (p_array SPLIT_array)
       IS
       BEGIN
          FOR i IN 1 .. p_array.COUNT
          LOOP
             DBMS_OUTPUT.put_line (p_array (i));
          END LOOP;
       END;
    
       PROCEDURE PROC_SPLIT (IN_LIST VARCHAR2)
       IS
          l_data   SPLIT_array;
          l_txt    LONG := '100,200,300,400,500,600';
          l_str    LONG := IN_LIST || ',';
          l_n      NUMBER;
       BEGIN
          BEGIN
             l_data.delete;
    
             LOOP
                l_n := INSTR (l_str, ',');
                EXIT WHEN NVL (l_n, 0) = 0;
                l_data (l_data.COUNT + 1) := SUBSTR (l_str, 1, l_n - 1);
                l_str := SUBSTR (l_str, l_n + 1);
             END LOOP;
    
             PROC_REM_LIST (l_data);
          END;
       END;
    END pak_split_test;
    /
    

    PROC_REM_LIST expected a type of PL/SQL of L_DATA. You have not set this type anywhere (for example in the specifications of your package, body, or in SQL). I pass the declaration of PROC_SPLIT your body to package and it compiles.

    I hope this helps!

  • Pass a list of values to a pl/sql function

    I would like to pass a list of values to a pl/sql function where the list will be used in an IN clause. Ideally, I would like to do the following:

    CREATE or REPLACE FUNCTION (dept_list in varchar2)
    Start
    Select... where dept in (dept_list);

    use: process_list ('7730,7735,7740,7745');

    I can't find an example to do based on pl/sql, but it seems feasible.
    Is there a way to do this?

    user12088323 wrote:

    I would like to pass a list of values to a pl/sql function where the list will be used in an IN clause.

    use: process_list ('7730,7735,7740,7745');

    The first thing is that you need an appropriate data type for storing a list of numbers. A unique value that look you like a list of numbers, is not actually a list of numbers but a single character value.

    This example uses the built in odcinumberlist data type in a procedure, you can do the same in function

    Re: Pass an array to an Oracle stored procedure

    If you have an older version of the database, you may need to create your own type with the same definition of odcinumberlist.

  • SQL more unable to connect (computers connected via a DSL router)

    Hello!

    I have two computers connected locally via a DSL router. His IP address is 192.168.1.64 IP of the other is 192.168.1.65.
    "I'm trying to connect to 192.168.1.64 via SQL more 192.168.1.66 by running the following command: sqlplus system@"192.168.1.64/orcl.168.1.100 "and receive this error message:" ORA-12170: TNS: Connect timeout occurred. " I thought it was the default Windows Firewall that has caused this and changed the windows firewall settings in 192.168.1.64 adding port 1521 in the list of windows firewall. Now, I get this error: "ORA-12541: listener TNS:no.»

    Published by: totalnewby on June 12, 2010 10:53

    totalnewby wrote:
    Hello!

    I have two computers connected locally via a DSL router. His IP address is 192.168.1.64 IP of the other is 192.168.1.65.
    "I'm trying to connect to 192.168.1.64 via SQL more 192.168.1.66 by running the following command: sqlplus system@"192.168.1.64/orcl.168.1.100 "and receive this error message:" ORA-12170: TNS: Connect timeout occurred. " I thought it was the default Windows Firewall that has caused this and changed the windows firewall settings in 192.168.1.64 adding port 1521 in the list of windows firewall. Now, I get this error: "ORA-12541: listener TNS:no.»

    Published by: totalnewby on June 12, 2010 10:53

    =================================

    Suppose you have the following in your tnsnames.ora:

    Larry =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myhost) (PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = curley)
    )
    )

    Now, when you issue a connect, say like this:

    $> sqlplus scott/tiger@larry

    TNS will appear in your tnsnames.ora for an entry called "larry". Then, tns sends a request to (PORT = 1521) on (HOST = myhost) to aid (PROTOCOL = TCP), requesting a connection to (SERVICE_NAME = curley).

    Where's (HOST = myhost) on the network? When the request is passed to tns to the next layer in the network stack, the name "myhost" resolves to an IP address, either via a file 'hosts' local, through DNS, or possibly other mechanisms being used less. Alternatively, you can hard-code the IP (HOST = 123.456.789.101) in the tnsnames.ora.

    Then, the request arrives at port 1521 myhost. If all goes well, there is a listener on myhost configured to listen on port 1521, and this listener knows SERVICE_NAME = curley. If so, you'll be connected.

    A few important points.

    First, the listener is a process only the side server. It's all in life seeks applications for reception for connections to the databases and set up these connections. Once the connection is established, the listener is out of the picture. It creates the connection. It does not support the connection. A listener, linking an oracle of the House, listening on a single port, use multiple instances of database in several versions of several houses. It is unnecessary complexity to try to have several headphones. It's like the telephone company, to build a separate table for each customer.

    Secondly, the tnsnames.ora file is a client-side problem. Its purpose is to address resolution - the equivalent of the 'hosts' file tns further to the bottom of the network stack. The only reason it exists on a host computer is because this machine also can run client processes.

    What can go wrong?

    First, there may not be an entry for 'larry' in your tnsnames file. In this case, you get "ORA-12154: TNS: could not resolve the connect identifier specified" no need to go looking for a problem on the host, with the listener, etc.. If you cannot place a phone call because you do not know the number (cannot find your phonebook (tnsnames.ora) or can not find the party looking for listed in it (no entry for larry)) you don't look at problems at the switchboard.

    Perhaps the entry for larry was found, but myhost could not be resolved to an IP address (for example there is no entry for myhost in the local hosts file). This will mean by "ORA-12545: Connect failed because target host or object does not exist.

    Maybe there is an entry for MyServer in the local hosts file, but it specified a bad IP address. This will mean by "ORA-12545: Connect failed because target host or object does not exist.

    Maybe the INVESTIGATION period was good, but there is no listener running: "ORA-12541: TNS:no listener.

    Maybe the INVESTIGATION period was good, there is a listener to myhost, but he is listening on a different port. "ORA-12560: TNS:protocol adapter error.

    Maybe the INVESTIGATION period was good, there is a listener to myhost, listening on the specified port, it's unknown SERVICE_NAME = curley. "ORA-12514: TNS:listener is not currently of service requested in connect descriptor.

    =====================================

  • Passing % ROWTYPE array to a stored procedure using JDBC

    Hello

    I have the following code:

    create or replace package PCK_COLLECT_MESSAGES_CSR
    as
    TYPE TY_TA_KPMESSAGE_ROWTYPE IS TABLE OF M_MESSAGECOLLECTION % ROWTYPE;
    procedure insert_messages (messages IN TY_TA_KPMESSAGE_ROWTYPE);
    end PCK_COLLECT_MESSAGES_CSR;

    I would like to pass an array of M_MESSAGECOLLECTION % ROWTYPE to the stored procedure using JDBC, because I want to use the FORALL statement to perform a quick insert in the procedure.

    Is this possible using JDBC? Oracle version is 10g.

    Thank you in advance,
    Kind regards

    Markus.

    % rowtype declarations are native to pl/sql and are not accessible from outside its limits, something to think about when you're designing apis.

    To work around the problem, you can create an anonymous pl/sql block that can access the definitions of % rowtype.

      String sql = "declare r dual%rowtype; begin r.dummy := :x; end;";
    
      CallableStatement cs = conn.prepareCall(sql);
    
      cs.setString(1, "x");
    
      cs.execute();
    
  • 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.

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

  • execution of stored procedure in sql developer/sql more with a table setting?

    Hello

    I create a package with a procedure which has a cursor ref as output and a type as an input parameter.  Here is my definition of the package

    PACKAGE 
    -------
    CREATE OR REPLACE PACKAGE TEST
    As
      TYPE RefCursorType IS REF CURSOR;
      type intTableType is table of varchar2(50) index by binary_integer;
      
      PROCEDURE GETDATA (
              P_RECORDS OUT RefCursorType,           
               YEAR_LIST IN intTableType
      );  
    END;
    
    
    PACKAGE BODY
    -----------------------
    
    SET DEFINE OFF
    CREATE OR REPLACE PACKAGE BODY TEST
    AS 
    PROCEDURE GETDATA
    (
      P_RECORDS OUT RefCursorType,  
      YEAR_LIST IN intTableType  
    )
    AS 
    iYearList  IDTableType;
    BEGIN 
      --GET ARRAY COUNT
      IYEARLIST := IDTABLETYPE();
      IYEARLIST.EXTEND(YEAR_LIST.COUNT);
      
      --LOOP THROUGH LISTS AND POPULATE ARRAY
      FOR I IN YEAR_LIST.FIRST .. YEAR_LIST.LAST
      LOOP
      IYEARLIST(I) := IDTYPE(TO_CHAR(YEAR_LIST(I)));
      END LOOP;
      
       OPEN P_RECORDS FOR 
       SELECT CITHTML AS FORMATTED
        FROM dbTest.FORMATTED_HTML
      WHERE YEAR IN (SELECT * FROM TABLE(IYEARLIST))
      ;
      END GETDATA ;
    END TEST ;
    /
    
    

    I want to perform this procedure from the sql or sql developer more to see if it works properly.   The year field dbTest.FORMATTED_HTML is defined as varchar2 (20 bytes).  He has many years as well as text.

    I've used this in the past with simple stored procedures, but not those with a table setting

    var r refcursor;

    exec GETOLDDATA(:r,40);

    print r;

    How can I modify this to allow him to run my stored procedure?

    Thank you

    Just declare SQL, not type of PL/SQL:

    CREATE OR REPLACE

    TYPE Str50TblType

    AS THE TABLE OF THE VARCHAR2 (50)

    /

    CREATE OR REPLACE

    THE TEST PACKAGE

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    );

    END;

    /

    CREATE OR REPLACE

    TEST OF PACKAGE BODY

    IS

    GETDATA PROCEDURE)

    P_RECORDS ON SYS_REFCURSOR,

    YEAR_LIST IN Str50TblType

    )

    IS

    BEGIN

    OPEN P_RECORDS

    FOR

    SELECT CITHTML AS FORMATTED

    OF dbTest.FORMATTED_HTML

    WHERE YEAR IN)

    SELECT *.

    TABLE (YEAR_LIST)

    );

    GETDATA END;

    END TEST;

    /

    SY.

Maybe you are looking for