Integrate the Table function in the package
Hey everybody,
I had a problem with my table function. I don't have it created in a package as a function table on the database. Now I have to integrate it in my package,
but it does not work. What I have to put the type and Assembly in the package_spec? I always get the error: "each cursor or subprogramm in the package_spec statement must have a corresponding definition in the package body.
But I already joined the funtion in the body. Maybe someone can help me? I would be very grateful!
It's my spec package: (sorry, I don't know how to insert the code in this forum, maybe you can tell me)
The search_type is declared, but so far not in the package:
----------------------------------------
create or replace package test is
TYPE search_set IS TABLE OF THE schema.search_type;
function search (.)
Return search_set;
end test;
----------------------------------------
create or replace package test body is
function search (.)
return search_set
pipelined is
..
search for late;
----------------------------------------
create or repplace type search_type as object
(..);
---------------------------------------
If I lump the search_type package specifications, it will not accecpt the 'object '.
It would be great if you can help me! I would also like to update my post I have someone tell me how to integrate the code correctly in this post.
Many thanks!
In your message the definition of function in the SPECIFICATION does not PIPELINED keyword, but your BODY plan has it.
Tags: Database
Similar Questions
-
Hello
This question might be already on the forum, but I couldn't find anything about him.
My question is: how to debug the service table.
For example I have function in package
Function Get_States (P_Parameter_1 In Number , P_Parameter_2 In Number ) Return Collection_type Pipelined ;
And inside the function that I have piping line algorithms say some calculations. When I try to debug, it gives me error.
Please guide me how to debug this function.
Here, I found the solution.
When I start debugging. It shows like this.
So I just change
DECLARE P_OWNER VARCHAR2(200); v_Return BIAS.DEBUG_TEST_PKG.T_PIPEROW; BEGIN P_OWNER := NULL; SELECT * bulk collect into v_Return FROM TABLE(DEBUG_TEST_PKG.DEBUG_PIPELINED_FUNCTION( P_OWNER )); /* Legacy output: DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return); */ --:v_Return := v_Return; --rollback; END;
But before that, I noticed a few points.
1 - whenever I update to the new version, I simply import preferences from the previous version (but this time, I DID NOT import. just do fresh install and configure the debugger on step.). I don't know but this import was somehow me gives error.
2. just after the creation of new features in the package, it is not in the list of choices debugging functions, so I restart SQL developer.
Thank you.
-
pipeline function and type inside the package
Hi all
I'm sorry for the inconvenience, I tried to google my question before asking here...
The question is:
I can't compile type in the same package as my function in the pipeline?
I have an example of a function in the package, everything works fine.
SELECT using function statement:CREATE OR REPLACE PACKAGE ZOO.pkg_cl_risk_eval AS FUNCTION sample (p_date date, p_indicatorid number, p_ismodel number) return cl_risk_act pipelined; END; / CREATE OR REPLACE PACKAGE BODY pkg_cl_risk_eval is FUNCTION sample (p_date date, p_indicatorid number, p_ismodel number) return cl_risk_act pipelined IS v_obj cl_risk_type := cl_risk_type(NULL,NULL,NULL,NULL); BEGIN FOR e IN ( select trunc(sysdate) as adate, 0 as cid, 0 as indicatorid, case when p_ismodel = 0 then 0 else 1 end as value from dual ) LOOP v_obj.adate := e.adate; v_obj.cid := e.cid; v_obj.indicatorid := e.indicatorid; v_obj.value := e.value; PIPE ROW (v_obj); END LOOP; RETURN; end; end; /
I can't compile type in the same package as my function in the pipeline?select * from table(zoo.pkg_cl_risk_eval.sample(date '2011-09-30',4, 0))
Currently, it is outside the package:
As far as I can read from this source, it is impossible, but this information can be updated.DROP TYPE cl_risk_type FORCE; CREATE OR REPLACE TYPE cl_risk_type AS OBJECT ( adate date, cid number(10), indicatorid number(5), value number(5) ) / CREATE OR REPLACE TYPE cl_risk_act AS TABLE OF cl_risk_type /
http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:4447489221109
Oracle version: 11g
UPD:
I'm sorry, I'm not paying attention... It is possible as noted in the response to my similar question:
function in pipeline work in the package? (Oracle 11g)
Published by: marco on December 15, 2011 07:40As the following State messages, my post was wrong. I withdraw without reservation.
Published by: APC on December 15, 2011 15:30
-
Error creating features in the packages - unknown command FUNCTION
Hello
I usually identify with the diagram of the system via the SQL command line and run my sql files. I have the database below and the test package. But I get the error:
Order unknown start "FUNCTION p...» ' - the rest of the ignored line
This is the database I load previously:
DROP TABLE Judete CASCADE CONSTRAINTS;
CREATE TABLE Judete
(
JD CHAR (2) PRIMARY KEY.
NumeJud char(10) NOT NULL UNIQUE,
Regiune CHAR (15) by default "Moldova" CHECK (Regiune IN ('Moldova', 'Transilvania', 'Banat'))
);
DROP TABLE Localitati CASCADE CONSTRAINTS;
CREATE TABLE Localitati
(CodPostal NUMBER (8) PRIMARY KEY,)
NumeLoc NON NULL, char (15)
Judet (2) tank,
FOREIGN KEY (Judet) made REFERENCE Judete (JD)
);
DROP TABLE Persoane CASCADE CONSTRAINTS;
CREATE TABLE Persoane
(NOC NUMBER PRIMARY KEY (15),)
NumePers NON NULL char (20)
PrenPers NON NULL char (20)
CodPostal NUMBER (10),
Such NUMBER (12) NOT NULL,
FOREIGN KEY (CodPostal) made REFERENCE to Localitati (CodPostal)
);
DROP TABLE Produse CASCADE CONSTRAINTS;
CREATE TABLE Produse
(CodProdus NUMBER (10) PRIMARY KEY,)
NumeProdus NON NULL, char (15)
Loan NUMBER (8) NOT NULL
);
DROP TABLE Vanzari CASCADE CONSTRAINTS;
CREATE THE Vanzari TABLE
(CodV NUMBER (8) PRIMARY KEY,
CodProdus NUMBER (10),
PersCNP Number (15),
DataV DATE NOT NULL,
NrProduse NUMBER (8) NOT NULL,
FOREIGN KEY (PersCNP) made REFERENCE Persoane (NOC),
FOREIGN KEY (CodProdus) makes REFERENCE Produse (CodProdus)
);
INSERT INTO Judete VALUES ('IS', 'Iasi', 'Moldova');
INSERT INTO Judete VALUES ("CJ", "Cluj", "Transilvania");
INSERT INTO Judete VALUES ("TM", "Timis', 'Banat');
INSERT INTO Localitati VALUES (200, "Vaslui", "IS");
INSERT INTO Localitati VALUES (201, 'Targu Frumos', 'IS');
INSERT INTO Localitati VALUES (202, 'Criseni', 'CJ');
INSERT INTO Localitati VALUES (203, "Dealu Botii", "CJ");
INSERT INTO Localitati VALUES (204, "Beba Veche", "TM");
INSERT INTO Localitati VALUES (205, "Blajova", "TM");
INSERT INTO Persoane VALUES (0001, "Ionescu", "Ion", 201, 0332504312);
INSERT INTO Persoane VALUES (0002, "Vasilescu", "Vasile", 203, 0332304612);
INSERT INTO Persoane VALUES (0003, "Ionescu", "Ion", 204, 0322564322);
INSERT INTO Produse VALUES (1, "Limp", 50);
INSERT INTO Produse VALUES (2, 'First', 80);
INSERT INTO Produse VALUES (3, 'Corn', 35);
INSERT INTO Vanzari VALUES (100, 1, 0001, to_date('2011-03-07','yyyy-mm-dd'), 5);
INSERT INTO Vanzari VALUES (101, 3, 0001, to_date('2011-02-07','yyyy-mm-dd'), 2);
INSERT INTO Vanzari VALUES (2, 102, 0002, to_date('2011-01-08','yyyy-mm-dd'), 7);
INSERT INTO Vanzari VALUES (1, 103, 0002, to_date('2011-03-08','yyyy-mm-dd'), 15);
INSERT INTO Vanzari VALUES (3, 104, 0003, to_date('2011-02-19','yyyy-mm-dd'), 9);
INSERT INTO Vanzari VALUES (105, 1, 0003, to_date('2011-03-29','yyyy-mm-dd'), 1);
the package is:
CREATE or REPLACE PACKAGE pachet_lab2
IS
FUNCTION prod_bine_vandut RETURN NUMBER;
END pachet_lab2;
/
CREATE OR REPLACE pachet_lab2 BODIES
FUNCTION prod_bine_vandut RETURNS the NUMBER IS
DECLARE
v_sale NUMBER (6);
V_nume char (15);
v_cod NUMBER (10);
BEGIN
SELECT max(p.pret * v.NrProduse) IN the v_sale DE Produse p, Vanzari v
WHERE the p.CodProdus = v.CodProdus;
SELECT p.numeProdus INTO v_nume Produse p, Vanzari v
WHERE p.CodProdus = v.CodProdus AND v_sale = p.pret * v.NrProduse;
SELECT p.codProdus INTO v_cod Produse p, Vanzari v
WHERE p.CodProdus = v.CodProdus AND v_sale = p.pret * v.NrProduse;
Return v_cod;
END prod_bine_vandut;
END pachet_lab2;
/
I need to change the schema that I use? How can I do?
Thank you
PaulCREATE OR REPLACE PACKAGE BODY pachet_lab2 IS --you misse keyword PACKAGE FUNCTION prod_bine_vandut RETURN NUMBER IS -- DECLARE is not allowed here v_sale NUMBER(6); -- ...
Good bye
DPT -
How to use a function inside the package?
Hello
You will need to convert weight unit of kilogram kips when filling out the weight values into a temporary table. In our database, schema there is a function called convert_units is available.
How could I use this feature in my package? My package is also resides in the same database schema.
Here, I pasted the function.
convert_units ( in_base_unit_id NUMBER, in_conversion_unit_id NUMBER, in_value NUMBER ) RETURN NUMBER AS CURSOR unit_cur IS SELECT * FROM units_conversion WHERE base_unit_id = in_base_unit_id AND conversion_unit_id = in_conversion_unit_id; unit_rec unit_cur%ROWTYPE; BEGIN OPEN unit_cur; FETCH unit_cur INTO unit_rec; IF unit_cur%NOTFOUND THEN unit_rec := NULL; END IF; CLOSE unit_cur; RETURN (in_value+unit_rec.pre_adjust_add)*(unit_rec.rate); END convert_units;
Hello
It seems that the first two arguments of this function are ID in the units_conversion table. If you know this id = 1234 means kilograms, 9876 means kips, then you can do things like:
wt_kips := convert_units (1234, 9876, wt_kilograms);
or
INSERT INTO tmp_table ( ..., weight_val, ...) VALUES ( ..., convert_units (1234, 9876, wt_kilograms), ...);
I can't just look at the code which could be any valid ID. I'm not even sure of the order of the arguments. I hope you have instructions on how to use the function.
If the function is in a package named pk_xyz (a different package to the one in which you call it), add the name of the package, like this
wt_kips := pk_xyz.convert_units (1234, 9876, wt_kilograms);
-
table does not exist (when I try to compile the package)
Hi all
I can choose from table1 using simple script.
But when I try to compile the package with select from it table1 I get the message:
PL/SQL: ORA-00942: table or view does not exist
Please help me understand how this is possible.
What additional information should I place them here for you to help me?
Thanks in advance.
UPD: The object name is SYS. V_$ PROCESS
I choose him by using script, so I need all grants.
But what is the problem when I try to do in the package?
2788367 wrote:
Hi all
I can choose from table1 using simple script.
But when I try to compile the package with select from it table1 I get the message:
PL/SQL: ORA-00942: table or view does not exist
Please help me understand how this is possible.
What additional information should I place them here for you to help me?
Thanks in advance.
It is very likely that you've got access to the table via a role. This allows you to use SQL to access.
With packages, the grant must be directly to your schema, bypassing a role.
-
Changing table via the package with immediate execution (problem)
Hello
I have a unusual problem. I have a package that contains the procedure that via execute immediate statement, creates a table on which he performs different actions for example:
-alter table some_owner.dummy_table noparallel
-create index some_owner.idx_name on some_owner.dummy_table (column)...
But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.
Note If call these commands outside the package (a simple script) this all done OK.
I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.
I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.
There must be a problem why a package cannot change the table which is owned by the user 'SOME_OWNER '.
All useful responses would be appreciated.
I have a unusual problem.
No - you don't have. This question has been answered SEVERAL times on this forum and others.
But I only managed to run move and create synonym table/public via execute immediate statement. Actions as alter table and create index fails with error ORA-01031: insufficient privileges.
OK - your username doesn't have privileges to do these operations or only received privileges through roles.
Roles are DISABLED in named PL/SQL blocks that use of the AUTHOR's rights.
Note If call these commands outside the package (a simple script) this all done OK.
I found a way, where I set the AUTHID CURRENT_USER command create package statement. In this way all the actions executed OK.
Of course - the roles are NOT disabled in named PL/SQL blocks that use the rights of the APPELLANT or in anonymous blocks.
I wonder why I can't change the table via the package with immediate execution on a table that is in the tablespace "SOME_TABLESPACE" and the title of owner "SOME_OWNER", without putting the AUTHID command on the package.
Well now you know!
-
I have photoshop cs6 and want to use the patch tool, but I can't find it anywhere in my program. I tried to download the latest updates, but I'm still not. Fix function is supposed to be part of the package CS6?
Hello Mojo,
Please right-click on the Spot Healing Brush, and you should be able to see the patch tool.
Kind regards
Tanuj
-
Why we need to create the package instead of procedure or function in Oracle
Hello
Recently, I attended an interview, they asked,
why we must create the package instead of procedure or function in oracle. Is a specific advantage, if we create together.
I'm not sure. can u tell me please someone.
Thank you and best regards,
Sanjeev.Hello
A part of the oracle documentation.
What is a PL/SQL Package?
A package is a schema object which includes subroutines, variables, and logically related PL/SQL types. Packages have two parts: a specification (spec) and a body. Sometimes, the body is unnecessary. The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines queries for the sliders and the code for the subprogrammes.Benefits of the PL/SQL Packages
Packages have a long history in software engineering, offering important characteristics for a reliable, maintainable, and reusable code, often in team for large systems development efforts.Modularity
Packages allow you to logically encapsulate Associates types, elements, and subroutines in a module named PL/SQL. Each package is easy to understand, and the interfaces between packages are simple, clear and well defined. This facilitates the development of applications.
Easier application design
When you design an application, all you need initially is the interface information in the package specification. You can code and compile a spec without his body. Stored subprograms that reference the package can then be compiled as well. You should not set the package body entirely until you are ready to complete the application.
Information masking
With packages, you can specify which types, elements, and subprogrammes are (and accessible) public or private (hidden and inaccessible). For example, if a package contains four subprogrammes, three can be public and one private. The package hides the implementation of the subprogramme private so that only the package (not your application) is affected if the application changes. This simplifies maintenance and improvement. Also, by hiding the implementation details of the users, you protect the integrity of the packaging.
Feature added
Sliders and packed public variables persist for the lifetime of a session. They can be shared by all the subprogrammes that are running in the environment. They allow you to manage data in any of the transactions without storing in the database.
Best performance
When you call a subprogram packaged for the first time, the whole package is loaded into memory. Subsequent calls to related subprograms in package require no disk i/o.
Packets stop cascading dependencies and avoid an unnecessary recompilation. For example, if you change the body of a packaged function, Oracle does not recompile other routines that call the function; These routines only depend on parameters and return value that are declared in the specification, so they are recompiled only if the specification changes.
-
Function within the package error
Hi friends,
I have a package called xxhw_ams_utils with a function inside get_salary
When I tried to run this function in the package as below average way, im getting error as
ORA-00904: "XXHW_AMS_UTILS." "" GET_SALARY ": invalid identifier
where there are 1072 is the assignment IM id to the objective test.select apps.xxhw_ams_utils.get_salary(1072) from dual
This is the actually the get_salary function located in the package xxhw_ams_utils of coding
Suppose that if I performed as the way to way below, I get the correct resultFUNCTION get_salary (p_asg_id IN NUMBER) RETURN VARCHAR2 IS l_gross VARCHAR2(20); l_basic VARCHAR2(20); BEGIN select eev.screen_entry_value into l_basic from pay_element_entry_values_f eev, per_pay_bases ppb, pay_element_entries_f pe where ppb.pay_basis_id +0 = 61 and pe.assignment_id = 1072 and eev.input_value_id = ppb.input_value_id and eev.element_entry_id = pe.element_entry_id and sysdate between eev.effective_start_date and eev.effective_end_date and sysdate between pe.effective_start_date and pe.effective_end_date; EXCEPTION WHEN OTHERS THEN RAISE; END;
Suppose if I run as the means below it is back as invalid character error.select eev.screen_entry_value --into l_basic from pay_element_entry_values_f eev, per_pay_bases ppb, pay_element_entries_f pe where ppb.pay_basis_id +0 = 61 and pe.assignment_id = 1072------------------------------------>assignment id (that im passing) and eev.input_value_id = ppb.input_value_id and eev.element_entry_id = pe.element_entry_id and sysdate between eev.effective_start_date and eev.effective_end_date and sysdate between pe.effective_start_date and pe.effective_end_date;
Why might the problem friends.select apps.xxhw_ams_utils.get_salary(1072) from dual
Brgds,
MiniYour function must RETURN a VARCHAR2
-
function defined by the user in the package
Hi all
is it possible to return a value greater than 1 when you use the function defined by the user in the package?You must declare variables US1 and US2 as well. I also modified your code a little more assing numbers directly rather than using select.
First of all,
Your package body and specifications should have the same input parameter names. Your spec is seen cid and your body with ccid. Has changed.
CREATE OR REPLACE PACKAGE creator.marco_function_clienttype IS -- 0 - not found -- 1 - small business -- 2 - corporate -- 3 - individual FUNCTION f_clienttype (ccid number ) RETURN NUMBER; END; /
CREATE OR REPLACE PACKAGE BODY creator.marco_function_clienttype IS FUNCTION f_clienttype (ccid NUMBER) RETURN NUMBER IS us NUMBER; us1 NUMBER; us2 NUMBER; BEGIN --officialtype = 2 - corporate, officialtype = 3 - individual SELECT ct.officialtype INTO us1 FROM contragenttype ct, contragent d WHERE d.ID = ccid AND ct.cid = d.contragenttypeid; --- IF us1 = 3 THEN us := 3; ELSE --ENTERPRISETYPE.id = 910 - small business SELECT dd.enterprisetypeid INTO us2 FROM contragent dd WHERE dd.ID = ccid; IF us2 = 910 THEN us := 1; ELSE us := 2; END IF; END IF; RETURN NVL (us, 0); END; END; /
G.
-
How can I get the name of the package where a table is used
Hello... Hello...
How can I know the name of the package or procedures where a particular table is used?
is there a such sql query, I can get the names?It should work. Not tested.
SELECT * FROM USER_DEPENDENCIES WHERE TYPE LIKE 'PACKAGE%' AND REFERENCED_TYPE = 'TABLE' AND REFERENCED_NAME = 'YOUR_TABLE_NAME' --Replace with the table name you are looking for
G.
Edited by: g. on February 23, 2011 12:42 AM
-
Suggestion: functions to the package level assert at least grabbing FlexUnit 4
AS3 is not as nice as Java 5 imports static method, but we can do the same thing with functions at the level of the package. We could use these to reduce the amount of typing required FlexUnit 4.
I added this to my fork of AsUnit:
http://github.com/robertpenner/AsUnit/commit/bdb293436491792625ddc1f637c81c723986b87d
Example:
package AsUnit . says {Import AsUnit . framework . Assert ;public const assertEquals : function = Assert . assertEquals ;}In the test case, this would be used as follows:
Asunit.asserts import. *;...in the test methodassertEquals (...I totally agree with you. I wish we had static imports as well.
We will talk more about your suggestion, I am certainly open to it.
-
What is the difference between the function declared in the package and the CIP
What is the difference between the definition of a function in the package and package body?
Published by: user10641405 on November 19, 2009 13:29If you describe a package, you will see only the functions declared in the spec.
If you declare only in the body but are not available to other packages (they are private to the package, non-public) -
call a procedure of package DB type complicated if the type defined in the package itself
Hello world
I use jdev 11.1.1.7.0
I defined a package of data with a procedure and internal two types as follows:
Create Or Replace Package Db_Package As Type rec Is Record(Rec_Type Varchar2(10), Rec_Desc varchar2(10) ); Type recordList Is Table Of rec; Procedure Test_Procedure(p_out out recordList); END db_package;
evil
I want to call this procedure in the module of the application. I know how to call a procedure or function db AM,
but in this case that I've defined two types in the package itself and I use one of these types as to the procedure output parameter, I had a problem.
below is the example of code to call the db procedure, but it does not work because the plsqlBlock.registerOutParameter () setting will not
CallableStatement plsqlBlock = null; String statement = "Begin DB_PACKAGE.Test_Procedure(:1); END;"; try { plsqlBlock = getDBTransaction().createCallableStatement(statement, 0); plsqlBlock.registerOutParameter(1, OracleTypes.ARRAY);// it doesn't work plsqlBlock.executeUpdate(); Object object = plsqlBlock.getObject(1); } catch (Exception e) { e.printStackTrace(); }
I know that if I set the types of packets (rec, recordList) as types of oracle (instead of setting in the packaging itself) so I can call the procedure with success, in this case I should use below:
plsqlBlock.registerOutParameter(1, OracleTypes.ARRAY,"Recordlist");
but I wonder how you can call a procedure from the package if the types defined in the package itself.
Kind regards
Habib
JDBC supports the types of oracle level package only from 12 c database and jdbc driver ojdbc7 (which requires java 7).
Dario
Maybe you are looking for
-
Does anyone know how to get radio on sony tv Tune-In widget?
-
When I arrived to Xbox live, I started to play gears of War, I began to level 12 and you have a lot of skins of firearms. What happens with my xbox?
-
Installed XP but Vista SP1 recovery disks are
Another question. The computer came with XP Pro installed, but the recovery dvd's for Vista SP1. The recovery partition will always contain XP Pro if I installed Vista of these CDs?
-
I try to get the free upgrade to windows 10 because im always active on the old windows 7, but when I hit accept I get an error saying that i ' failed to create the files. Please check if you have permission to write to the folder of installation.' d
-
What pot contains the oracle.iam.oil.client.OILConnectionInf class
Hi allwhich jar file contains the oracle.iam.oil.client.OILConnectionInf class?