User-defined datatypes as IN variables in stored procedures
Hello,
I'm trying to write a stored procedure which will accept a custom data type as an IN variable. Using the information here: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm I've set up a procedure which looks like this:
CREATE OR REPLACE PROCEDURE EDEPOSIT.merch_acct_proc_method_insert
arg_ALL_PROC_METHODS IN proc_array
IS
TYPE proc_array IS TABLE OF VARCHAR2 INDEX BY VARCHAR2;
BEGIN
arg_METHOD := arg_ALL_PROC_METHODS.first;
while (arg_METHOD is not null)
loop
--processing code
end loop;
END;
but I'm running into a problem where it seems that the data type needs to be defined before the parameters block (Error(3,27): PLS-00201: identifier 'PROC_ARRAY' must be declared), but a DECLARE block won't co-exist with the CREATE OR REPLACE command (PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin function pragma procedure subtype type <an identifier>).
What am I missing?
Thanks in advance!
Hi,
Welcome to the forum!
877369 wrote:
... CREATE OR REPLACE PROCEDURE EDEPOSIT.merch_acct_proc_method_insert
arg_ALL_PROC_METHODS IN proc_array
IS
TYPE proc_array IS TABLE OF VARCHAR2 INDEX BY VARCHAR2;
BEGIN
arg_METHOD := arg_ALL_PROC_METHODS.first;
while (arg_METHOD is not null)
loop
--processing code
end loop;
END;
but I'm running into a problem where it seems that the data type needs to be defined before the parameters block (Error(3,27): PLS-00201: identifier 'PROC_ARRAY' must be declared), but a DECLARE block won't co-exist with the CREATE OR REPLACE command (PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: begin function pragma procedure subtype type <an identifier>).I'm not sure what you mean by "parameters block".
Whoever is going to call the procedure will have to create a proc_array first. If proc_array is defined inside the procedure, then it can't be referenced from outside the procedure.
A common way to define types is to do so in a package. Procedures normally belong to pacages anyway. You can define a TYPE and a procedure that uses it in the same package, like this:
CREATE OR REPLACE PACKAGE merch_acct_pkg
AS
TYPE proc_array IS TABLE OF VARCHAR2 (30) INDEX BY VARCHAR2 (30);
PROCEDURE merch_acct_proc_method_insert
arg_ALL_PROC_METHODS IN proc_array
END merch_acct_pkg;
SHOW ERRORS
CREATE OR REPLACE PACKAGE BODY merch_acct_pkg
AS
PROCEDURE merch_acct_proc_method_insert
arg_ALL_PROC_METHODS IN proc_array
IS
BEGIN
arg_METHOD := arg_ALL_PROC_METHODS.first;
while (arg_METHOD is not null)
loop
--processing code
end loop;
dbms_output.put_line ('Hello');
END merch_acct_proc_method_insert;
END merch_acct_pkg;
SHOW ERRORSYou can call the procedure like this:DECLARE
foo merch_acct_pkg.proc_array;
BEGIN
merch_acct_pkg.merch_acct_proc_method_insert (foo);
END;
/
Similar Messages
-
Some DB objects like User-defined datatypes being missed out?
Dear all.
I create an Oracle model for a captured SQL Server model and then right click -> click on 'Generate' to create the DB creation script.
(1) But few objects like user-defined datatypes are missed out in the script.
(2) Also, a simple stored proc as defined below missed out:
CREATE PROCEDURE [SalesLT].[SayHi]
AS
SELECT 'Hi I am a job scheduler'
GO
Rgds, AbhiHello,
An OracleDI Dataserver connection to an RDBMS is, most of the time, defined with a single set of parameters: a user account name, a password and a URL.
OracleDI may need to access numerous tables on the RDBMS which may not all be stored in the same database schema, catalog, library, ...and for which access privileges may not be identical.
For this reason, it is necessary to ensure that the RDBMS user account has sufficient access privileges for these schema, catalog, librairies ...
The user account should have at least read/right access permission for any OracleDI Physical Schema referenced for the concerned Dataserver (depending on the project within which it is used, a Physical Schema may store both source and/or target tables).
Moreover, for project requirements, it may be necessary to use/create/drop certain RDBMS
components such as stored procedures, views, temporary tables, system tables ...
For this reason, make sure the user account referenced in the dataserver connection parameters is attributed sufficient privileges to any object it may manipulate with OracleDI.
2nd point: you can use any logical name for the data server Name. -
Hello,
Is there any way we can make user defined datatypes in oracle as we do in Microsoft SQL / Sybase ASE.
I tried using Abstract TYPE but using it changes the Select query. I need to migrate some Sybase code to Oracle and also need to implement the user defined datatypes for tables.
Any clue on as to how I can create this in oracle.
Regards
SuchetanThanks for your replies.
Here is how we use UDD in sybase and also how the queries change when TYPE is used in Oracle.
Eg:-
***************** Sybase **************************
sp_addtype 'name10','varchar(10)'
go
Type added.
(return status = 0)
create table TEST
usrname name10)
go
sp_help TEST
go
Name Owner
Object_type
TEST dbo
user table
(1 row affected)
Data_located_on_segment When_created
default Jan 17 2007 9:43AM
Column_name Type Length Prec Scale Nulls Default_name
Rule_name Access_Rule_name Identity
usrname name10 10 NULL NULL 0 NULL
NULL NULL 0
(return status = 0)
INSERT INTO TEST VALUES('SUC') /* Insert is like any table created without
UDD */
GO
(1 row affected)
SELECT usrname FROM TEST
GO
usrname
SUC
(1 row affected)
******************************** Sybase End ***********************
********************** ORACLE *******************************
create or replace type name10
ss object
name10 varchar(10))
Type created.
create table test
( usrname name10)
Table created.
desc test
Name Null? Type
USRNAME NAME10
INSERT INTO TEST VALUES('SUC')
INSERT INTO TEST VALUES('SUC')
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected SYSTEM.NAME10 got CHAR
INSERT INTO TEST VALUES(NAME10('SUC'));
1 row created.
SELECT USRNAME FROM TEST
USRNAME(NAME10)
NAME10('SUC')
SELECT USRNAME.NAME10 FROM TEST
SELECT T.USRNAME.NAME10 FROM TEST T
USRNAME.NA
SUC
********************* ORACLE END **********************************
Thanks
Suchetan Shetty -
OC4J and Oracle9i and user defined datatypes over SOAP.
Does OC4J and Oracle9i, that comes with JDeveloper9i-rc, support user defined datatypes over SOAP?
If I invoke the EJB over RMI it is working fine.
But if I try to invoke it over SOAP I get this fault:
500 Internal Server Error: Servlet error: Error building response envelope: java.lang.IllegalArgumentException: No Serializer found to serialize a 'mypackage.myObj' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
I have written the Deployment descripter like this:
<?xml version = '1.0'?>
<isd:service
id="urn:mypackage.EJB2"
type="rpc"
xmlns:isd=" " target="_new">http://xmlns.oracle.com/soap/2001/04/deploy/service"> <isd:provider
id="stateless-ejb-provider"
methods="getData"
scope="Request">
<isd:option key="JNDILocation" value="EJB2"/>
<isd:option key="DeploymentName" value="EJB2"/>
</isd:provider>
<isd:faultListener class="org.apache.soap.server.DOMFaultListener"/>
<isd:mappings>
<isd:map
encodingStyle="http://schemas.xmlsoap.org/soap/encoding" xmlns:x="http://glo2158" qname="x:mypackage.myObj"
javaType="mypackage.myObj"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
</isd:mappings>
</isd:service>AFAIK this is not possible with the Oracle 8i implementation. This is my main gripe about Oracle's so called objects - you can't define your own constructors, you can't put check constraints on them and you can't use them in triggers.
In other words you can put any old scheisse in an object and you can't populate them with derived or default values.
I'm on a 9i New Features course as I type and I'm hoping to hear that Oracle have added some features to objects that will make them worth using.
regards, APC -
User Defined datatypes dont work
URGENT HELP REQUIRED! SOS!
I had installed PO 8.0 on one of my machines, but when tried to create user defined datatypes, it says 'Object Type Not Enabled'. Does that mean we can ENABLE creation of user defined datatypes in PO 8.0? If so, please guide as to where i can find this option.
Secondly, when I install Oracle 8.1.6 and forms6i on my Server (windows NT environment), I find that although tyopes can be defined in sql8.0, the same is shown as UNDEFINED in sql3.3. Is it a bug or am i missing out something? Please guide.
Thanks, in anticipation!Thanks for your replies.
Here is how we use UDD in sybase and also how the queries change when TYPE is used in Oracle.
Eg:-
***************** Sybase **************************
sp_addtype 'name10','varchar(10)'
go
Type added.
(return status = 0)
create table TEST
usrname name10)
go
sp_help TEST
go
Name Owner
Object_type
TEST dbo
user table
(1 row affected)
Data_located_on_segment When_created
default Jan 17 2007 9:43AM
Column_name Type Length Prec Scale Nulls Default_name
Rule_name Access_Rule_name Identity
usrname name10 10 NULL NULL 0 NULL
NULL NULL 0
(return status = 0)
INSERT INTO TEST VALUES('SUC') /* Insert is like any table created without
UDD */
GO
(1 row affected)
SELECT usrname FROM TEST
GO
usrname
SUC
(1 row affected)
******************************** Sybase End ***********************
********************** ORACLE *******************************
create or replace type name10
ss object
name10 varchar(10))
Type created.
create table test
( usrname name10)
Table created.
desc test
Name Null? Type
USRNAME NAME10
INSERT INTO TEST VALUES('SUC')
INSERT INTO TEST VALUES('SUC')
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected SYSTEM.NAME10 got CHAR
INSERT INTO TEST VALUES(NAME10('SUC'));
1 row created.
SELECT USRNAME FROM TEST
USRNAME(NAME10)
NAME10('SUC')
SELECT USRNAME.NAME10 FROM TEST
SELECT T.USRNAME.NAME10 FROM TEST T
USRNAME.NA
SUC
********************* ORACLE END **********************************
Thanks
Suchetan Shetty -
Help needed for User-Defined Datatype
Hi All,
I have one table which has User-defined Column Datatype.
Now Client wants us to rename the User-Defined Datatype for some Standardization process.
How to do rename of it, coz Rename old to new doesnt work in Oracle 10.2.0.4G for TYPES.
So we re-created it with the new names. Now our Problem is how do i re-assign the column datatype with the New User-Defined DataType.
Regards,
PrathameshThe Only Solution that i could found was - Create a new column with new User-Defined Datatype, copy the old column values to New Column, then drop the old column and rename the new Column to Old Column
ORA-22859: invalid modification of columns
Cause: An attempt was made to modify an object, REF, VARRAY, nested table, or LOB column type.
Action: Create a new column of the desired type and copy the current column data to the new type using the appropriate type constructor. -
Pass BPC SSIS variable to stored procedure
Dear All
We have a ssis package in which there is data flow task. There
is a OLEDB source which uses “Data access mode” as sql command. We used OLEDB data source instead of execute sql task as the outuput is table format generated in Stored proc which is used in following task
This task calls a stored procedure with a input parameter which will be appset name. [EXEC ProcName '@BPCAPPSET']
The stored procedure is executing fine without any issues.But when I pass variable containing appset name to that stored procedure its not taking properly and package ending successful.
The variable is “BPCAPPSET” it contains appset name which
will be taken front end.
However to test if this value is taken by stored procedure
or not, I tried to hardcode and pass appset name to stored procedure. i.e exec
ProcName Appset1.
Appset1 is existing appset. It worked fine. But we want to
put this package in all land scapes, such that whenever it is triggered it will
take the appset as parameter and does the calculation in stored procedure.
Please advice how to pass this variable to stored
procedure.
regards
PrasadHi Roberto
Thanks for your mail.
I have tried, but I am getting error that @BPCAPPSET scalar
variable must be defined.
I believe that @BPCAPPSET is system defined variable which
will be passed from Data manager package. May be this is the reason it is not
recognizing this variable?
If so, should I define a variable in SSIS. How can we
assign value of @BPCAPPSET to the newly defined variable?
Please advise. Attached screenshot. -
BIND VARIABLES IN STORED PROCEDURES
I find out that the cause of the decreasing of the Shared_pool in my database is for the sql area.
1* SELECT * FROM V$SGASTAT where name like 'sql%'
SQL> /
POOL NAME BYTES
shared pool sql area 7671024
SQL> R
1* SELECT * FROM V$SGASTAT where name like 'sql%'
POOL NAME BYTES
shared pool sql area 8147424
SQL> R
1* SELECT * FROM V$SGASTAT where name like 'sql%'
POOL NAME BYTES
shared pool sql area 8262016
I flush the shared pool and it increases fastly.
According to my research I have to use bind variables in SQL Statement to avoid this and apart from that modify the init parameter CURSOR_SHARING.
Somebody can help me with a simple example about how to use bind variables in Stored Procedures.
thanksAccording to my research I have to use bind variables in SQL Statement to avoid this and apart from that modify the init parameter CURSOR_SHARING.I would not want to change the CURSOR_SHARING. As for use of bind variables in PL/SQL stored procedures, they come in naturally if you use pl/sql variables in your queries:
l_empno EMP.EMPNO%TYPE ;
SELECT <columns> INTO <local storage>
FROM emp
WHERE
empno = l_empno ; /* pl/sql automatically binds for you here */
.Please post a small sample of type of queries that you are submitting to the database from within these pl/sql blocks for us to see if there is a possibility of improvements. -
How to check which user has the privilege to execute a stored procedure?
I am using Oracle 7 and I would like to check which user has the privilege to execute a stored procedure. How can I check it? Is there any view I can query for?
Alex HungPlease check DBA_SYS_PRIVS.
SQL> select * from dba_sys_privs
2 where grantee='HARY';
GRANTEE PRIVILEGE ADM
HARY EXECUTE ANY PROCEDURE NO
.... -
User defined report with bind variable
How can I create an user defined report using a bind variable?
We currently do not support bind variables in User Defined Reports. We are looking at adding that function before production but I can't promise.
-- Sharon -
Dynamic webservice client for User-defined datatypes
Hi All,
I have a webservices with user-defined datat types. I want to write a dynamic client that will work even if there are any changes in the wsdl, so that I do not want to recompile the client or make any changes on the client side.
I tried using DII but we need to modify the custome objects and recompile the same. Suggest me any alternative.
Regards,
SanjayRob, unfortunately not. If I ever come across the solution, I will post it here.
The reason I wanted to use weblogic webservices was to take advantage of the asynchronous webservice functionality. I ended up using xfire instead for my webservices, as we already had that in place in the application, and then using polling clients to get the response. Not an ideal solution, but it works very good anyway.
regards,
Marcus -
How to convert Oracle User defined datatype to SQL Server 2014 using SSMA Version 6.0
I am trying to convert Oracle 11g OE schema to SQL Server 2014, using SSMA version 6.0
Getting an error in converting the Oracle View to SQL Server
CREATE OR REPLACE VIEW OC_CUSTOMERS OF OE.CUSTOMER_TYP WITH OBJECT IDENTIFIER (customer_id) AS
SELECT c.customer_id, c.cust_first_name, c.cust_last_name, c.cust_address,
c.phone_numbers,c.nls_language,c.nls_territory,c.credit_limit,
c.cust_email,
CAST(MULTISET(SELECT o.order_id, o.order_mode,
MAKE_REF(oc_customers,o.customer_id),
o.order_status,
o.order_total,o.sales_rep_id,
CAST(MULTISET(SELECT l.order_id,l.line_item_id,
l.unit_price,l.quantity,
MAKE_REF(oc_product_information,
l.product_id)
FROM order_items l
WHERE o.order_id = l.order_id)
AS order_item_list_typ)
FROM orders o
WHERE c.customer_id = o.customer_id)
AS order_list_typ)
FROM customers c
* SSMA error messages:
* O2SS0461: Conversion of object view is not supported.
* OF OE.CUSTOMER_TYP
* WITH OBJECT IDENTIFIER (customer_id)
CREATE VIEW dbo.OC_CUSTOMERS
AS
/*Generated by SQL Server Migration Assistant for Oracle version 6.0.0.*/
* SSMA error messages:
* O2SS0481: Conversion of statement containing user defined type column 'c.cust_address' not supported.
* O2SS0481: Conversion of statement containing user defined type column 'c.phone_numbers' not supported.
* O2SS0430: Conversion of multiset conditions is not supported.
* CAST(MULTISET
* SELECT
* o.order_id,
* o.order_mode,
* MAKE_REF(oc_customers, o.customer_id),
* o.order_status,
* o.order_total,
* o.sales_rep_id,
* CAST(MULTISET
* SELECT
* l.order_id,
* l.line_item_id,
* l.unit_price,
* l.quantity,
* MAKE_REF(oc_product_information, l.product_id)
* FROM order_items l
* WHERE o.order_id = l.order_id
* ) AS order_item_list_typ)
* FROM orders o
* WHERE c.customer_id = o.customer_id
* ) AS order_list_typ)
SELECT
c.CUSTOMER_ID,
c.CUST_FIRST_NAME,
c.CUST_LAST_NAME,
c.cust_address,
c.phone_numbers,
c.NLS_LANGUAGE,
c.NLS_TERRITORY,
c.CREDIT_LIMIT,
c.CUST_EMAIL,
NULL
FROM dbo.CUSTOMERS AS c */
Any suggestion on converting this view would be helpful.
Kind regards.Thanks Lydia Zhang for your reference urls.
Please let me know if you come across any reference articles related to
Creating a SQL Server table and View with columns as SQL Server TVP similar to Oracle UDT like
CREATE TABLE "OE"."CUSTOMERS"
( "CUSTOMER_ID" NUMBER(6,0),
"CUST_FIRST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_FNAME_NN" NOT NULL ENABLE,
"CUST_LAST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_LNAME_NN" NOT NULL ENABLE,
"CUST_ADDRESS" "OE"."CUST_ADDRESS_TYP" ,
"PHONE_NUMBERS" "OE"."PHONE_LIST_TYP" ,
"NLS_LANGUAGE" VARCHAR2(3 BYTE),
And also creating a SQL Server TVP inside an another SQL Server TVP as in Oracle
create or replace TYPE customer_typ
AS OBJECT
( customer_id NUMBER(6)
, cust_first_name VARCHAR2(20)
, cust_last_name VARCHAR2(20)
, cust_address cust_address_typ
, credit_limit NUMBER(9,2)
, cust_email VARCHAR2(30)
, cust_orders order_list_typ
NOT FINAL;
Kind regards.
Venkatesha -
Variables in stored procedures
Please help me I am trying to get some coding standards set up in the shop that I work in for the DBA group. The problem is that they feel that it is not important to put a prefix or a suffix to variable in a stored procedure.
What is important to me is having either a prefix or a suffix for variables that are passed in, out, and ones that are local to the stored procedure.
They do not feel it will be beneficial and want me to prove the importance. How I would like to prove this is by having as many people reply to this post as possible.
Please let me know what you think. The more replies I get the better the case that I can make to the other people in the group.
Thank you,I support you, Mr.().It is very important to have a well defined convention, if you want to escape from all those abuses while modifying the script.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Marco ([email protected]):
Hello unknown person,
The importance of a prefix (or a suffix) in my opinion is that you van tell by the name of the variable its type and origin (parameter, global, local etc) without the need to search for its definition. I find this usefull when you must change code that somebody else wrote cetainly if you work in an object oriented environment.<HR></BLOCKQUOTE>
null -
Pass PL/SQL Record variable to Stored procedure in Java
Can some one please give me a code snippet for passing a Record Type variable returned by Stored Procedure. Following is the scenario.
A record type variable REC_VAR is made of three columns of a table as follows
EmpNo Number, Empname Varchar2(50), Zip_Code Varchar2(5).
I am populating this variable in Java code and passing it to Stored Procedure.
Can I referance Record Type variable in a Oracle package from Java code.
How would I define these variables as per tables column type and pass to SP in a java program.
Thanks,58838,
The following entry -- from the Ask Tom Web site may be helpful (assuming you haven't already seen it):
how to access variable
If it doesn't help, you can always search the site.
Good Luck,
Avi. -
Using &variable in stored procedure
Is there any way to use &variable or something like this in stored procedure.
I need procedure that is stored, called from SQLPlus and can read-get values through typical keyboard input.Like this?
SQL> create or replace procedure getEmp (pEmpNo integer, pOutout out sys_refcursor)
2 as
3 begin
4 open pOutout for select * from emp where empno = pEmpNo;
5 end;
6 /
Procedure created.
SQL> var rc refcursor
SQL> exec getEmp(&empNo, :rc)
Enter value for empno: 1
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO Employee Name JOB MGR HIREDATE SAL COM DEPTNO
1 SHYAM MANAGER 02-APR-13 12975 0 50
SQL>
Maybe you are looking for
-
I imported my old iPhoto library into my new Aperture 3 library....when i try to sync my iPhone 4 with Aperture, I choose to sync the last 20 projects. It seemingly picks 20 random events, both from events/projects created in Aperture and events crea
-
I do not know the user name and password
My brother died. Worked his survey data and when Enter Me does not accept. What is the solution.?
-
All Text : 'flashes ' brightly, becomes 'hazy' or 'blurry'...
hi, just wondering if anyone else if having this problem... When I use Safari 4 to scroll up/down web pages, either with the bars at the side or the scroll arrows etc, the text gets brighter up to a point where it almost blends in with the white back
-
Hi ! Is it possible to use a table of object types when using the AQ-adapter ? I'm doing this: create or replace type samband_t as object( create or replace samband_table_t as varray(100) of samband_t; and creating the queue table as exec dbms_aqadm.
-
OrdImageDomain could not be found
Hi, I tried to deploy Order Entry bc4j to o8i, but I got ORA-29521: referenced name oracle/ord/im/OrdImageDomain could not be found message. There seems to be a problem with OrdImage column. How can I resolve this problem? I use jdev3.2 and o8.1.7. T