Record type error
Hi all
Can someone please tell me what could be the problem in the code below? Get the error message
PLS-00302: component 'COUNT' must be declared.
create table dept (dept_num NUMBER (2),)
dept_name VARCHAR2 (14).
location VARCHAR2 (13));
insert into dept values (10, 'Sales', 'NYC');
insert into dept values (10, 'IT', 'NYC');
-does not
Set serveroutput on
DECLARE
TYPE DeptRec IS (RECORD
dept_num NUMBER (2),
dept_name VARCHAR2 (14).
location VARCHAR2 (13));
dept1_info DeptRec;
dept2_info dept % ROWTYPE;
cursor c1 is select * from dept WHERE dept_num = 10; -Multiple records
BEGIN
Open c1;
LOOP
Fetch c1 in dept1_info;
OUTPUT WHEN c1% NOTFOUND;
END LOOP;
-dept1_info: = dept2_info;
-car me in 1.dept1_info.count
BECAUSE me IN 1.dept1_info.count
LOOP
dbms_output.put_line ('Dept names' | dept1_info (i) .dept_name);
end loop;
END;
/
There is nothing more to say about why your code failed.
the only thing you can do to reuse your registration type is to declare dept1_info_t as
TYPE dept1_info_t IS TABLE OF DeptRec;
hoping that the attributes of the sliders match your type declaration. (I explicitly discourage it!)
Good bye
DPT
Tags: Database
Similar Questions
-
Error creating service with record type as a return type
Hi, I tried the following code to get the nth highest sal using the service and the record type.
The lot above is createdCREATE OR REPLACE PACKAGE pack_rec_cur AS TYPE rec_type IS RECORD ( name EMP.ename%TYPE, sal EMP.sal%TYPE); END;
The above function is errorsCREATE OR REPLACE FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS rec pack_rec_cur.rec_type; CURSOR cur_rec IS SELECT ename,sal FROM emp WHERE sal is not null ORDER BY DESC; BEGIN OPEN cur_rec; FOR i IN 1..n LOOP FETCH cur_rec into rec; EXIT WHEN cur_rec%NOTFOUND; END LOOP; CLOSE cur_rec; RETURN rec; END;
Could you please correct me where I am wrongLINE/COL ERROR -------- --------------------------------------- 4/7 PL/SQL: SQL Statement ignored 7/16 PL/SQL: ORA-00936: missing expression SQL>
Thank you.By clauase missing column name in the order. Is it ename desc?
CREATE OR REPLACE FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS rec pack_rec_cur.rec_type; CURSOR cur_rec IS SELECT ename,sal FROM emp WHERE sal is not null ORDER BY ENAME DESC; ---added ename BEGIN OPEN cur_rec; FOR i IN 1..n LOOP FETCH cur_rec into rec; EXIT WHEN cur_rec%NOTFOUND; END LOOP; CLOSE cur_rec; RETURN rec; END; ------------ -OUTPUT ----------- SQL> SET SERVEROUT ON SQL> SQL> DECLARE 2 rec pack_rec_cur.rec_type; 3 BEGIN 4 rec := fun_rec_cur (6); --you get the 6th record in order of ename desc 5 DBMS_OUTPUT.put_line ('ename::' || rec.NAME || ' sal ::' || rec.sal); 6 END; 7 / ename::MARTIN sal ::1250 PL/SQL procedure successfully completed. SQL>
-
Error using BULK collect with RECORD TYPE
Hello
I wrote a simple procedure to declare a record type & then by a variable of type NESTED table.
I then selects the data using COLLECT in BULK & trying to access it via a LOOP... We get an ERROR.
------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
IS
TYPE rec_type () IS RENDERING
emp_id VARCHAR2 (20).
level_id NUMBER
);
TYPE v_rec_type IS TABLE OF THE rec_type;
BEGIN
SELECT employe_id, level_id
LOOSE COLLECTION v_rec_type
OF portfolio_exec_level_mapping
WHERE portfolio_execp_id = 2851852;
FOR indx IN v_rec_type. FIRST... v_rec_type. LAST
LOOP
dbms_output.put_line ('Emp-' | v_rec_type.emp_id (indx) |) » '|| v_rec_type.level_id (indx));
END LOOP;
END;
-----------------------------------------------------------------------------------------------------------------------------------
Here is the ERROR I get...
-Errors of compilation for the PROCEDURE DOMRATBDTESTUSER. SP_TEST_BULKCOLLECT
Error: PLS-00321: expression "V_REC_TYPE" is not appropriate for the left side of an assignment statement
Online: 15
Text: IN portfolio_exec_level_mapping
Error: PL/SQL: ORA-00904: invalid identifier
Online: 16
Text: WHERE portfolio_execp_id = 2851852;
Error: PL/SQL: statement ignored
Line: 14
Text: COLLECT LOOSE v_rec_type
Error: PLS-00302: component 'FIRST' must be declared
Online: 19
Text: LOOP
Error: PL/SQL: statement ignored
Online: 19
Text: LOOP
------------------------------------------------------------------------------------------------
Help PLZ.and with a complete code example:
SQL> CREATE OR REPLACE PROCEDURE sp_test_bulkcollect 2 IS 3 TYPE rec_type IS RECORD ( 4 emp_id VARCHAR2(20), 5 level_id NUMBER 6 ); 7 TYPE v_rec_type IS TABLE OF rec_type; 8 v v_rec_type; 9 BEGIN 10 SELECT empno, sal 11 BULK COLLECT INTO v 12 FROM emp 13 WHERE empno = 7876; 14 FOR indx IN v.FIRST..v.LAST 15 LOOP 16 dbms_output.put_line('Emp -- '||v(indx).emp_id||' '||v(indx).level_id); 17 END LOOP; 18 END; 19 / Procedure created. SQL> SQL> show error No errors. SQL> SQL> begin 2 sp_test_bulkcollect; 3 end; 4 / Emp -- 7876 1100 PL/SQL procedure successfully completed.
-
Error in passing in the RECORD type in the API
Gurus,
Get the following error when I try and change from one type of RECORD in an API. I am in passage correctly?
Any help is appreciated.
Thank you
-Scott
Here is my error:
fnd_descr_flex_col_usage_pkg.load_row
*
ERROR at line 21:
ORA-06550: line 21, column 4:
PLS-00306: wrong number or types of arguments in the call to 'LOAD_ROW '.
ORA-06550: line 21, column 4:
PL/SQL: Statement ignored
Here is my anon block:
declare
Who_type RECORD TYPE IS
(
created_by NUMBER,
CREATION_DATE DATE,
last_updated_by NUMBER,
last_update_date DATE,
last_update_login NUMBER
);
v_who_type who_type;
date of v_sysdate;
Start
Select sysdate
in v_sysdate
Double;
v_who_type.created_by: = 0;
v_who_type. CREATION_DATE: = v_sysdate;
v_who_type.last_updated_by: = 0;
v_who_type.last_update_date: = v_sysdate;
v_who_type.last_update_login: = 0;
fnd_descr_flex_col_usage_pkg.load_row
(x_application_short_name = > 'SPL',)
x_descriptive_flexfield_name = > 'HR_LOCATIONS ',.
x_descriptive_flex_context_cod = > '441',.
x_application_column_name = > 'ATTRIBUTE5 ',.
x_who = > v_who_type,
x_end_user_column_name = > "District."
x_column_seq_num = > 10,
x_enabled_flag = > 'Y ',.
x_required_flag = > 'n',.
x_security_enabled_flag = > 'n',.
x_display_flag = > 'Y ',.
x_display_size = > 50,
x_maximum_description_len = > 50,
x_concatenation_description_le = > 25,
x_flex_value_set_name = > 50 characters,
x_range_code = > ",
x_default_type = > ",
x_default_value = > ",
x_runtime_property_function = > ",
x_srw_param = > ",
x_form_left_prompt = > "District."
x_form_above_prompt = > "District."
x_description = > ");
...sreese wrote:
Tubby,Im not asking for your help with this error. I want to define my own FILE type that mimics the call package so I can spend in my own variables.
Pretty sure I've described previously, there was a specific question with the answer that you do not understand?
>
The problem with this type of recording is that it contains all the 'who' columns that the application requires. When it is called from a package within the schema, the package has no difficulty arising from these data. When you call the package from an anon block, I have to pull my own values.
You did before declaring a LOCAL record type, then you need to reference to the PACKAGE of type folder, as I showed you... it makes you EF values even as you were in your first post.
I want to define the RECORD type of the manner in which it has been set to 'fnd_flex_loader_apis.who_type', but using my own variable and passing in the parameter. Make sense?
Thank you
ScottHope that helps.
-
frequent blue screens often to internet sites. Blue screen too fast for me to record specific error message. How can I put an end to the blue screen to get the error message?
en blue screen too fast for me to record specific error message. How can I put an end to the blue screen to get the error message?
If your computer is restarted when the BSOD appears, then you must change the by default for what to do in case of system error. It is easy to do, but takes a lot of mouse clicks to get there:
Start | Control Panel | System | Advanced system settings (need for credentials for the administrator to spend here |) Advanced | Startup and recovery / settings.
On this screen, uncheck the box under system failure that says automatically restart. The next time the BSOD appears, your computer will not do anything else until you press the reset button, so you'll have all the time you need to read and copy the error codes. Paste here, verbatim, and someone should be able to point in the right direction.
``````~~~~`````
In the control panel choose reports on problems and Solutions (problem of type in the START search box), go to historical problem, right-click your error and choose check for the Solution. You can also examine the details.
In administrative tools, choose the reliability and performance monitor and click on MonitoringTools then the reliability monitor (type reliability in research on Start). This list is a chart of the software installs, uninstalls, updated Windows and crashes by date. See if your plant has started to happen after you installed or uninstalled something.
It may be useful to eliminate equipment defects
Type of memory in the search box of start and choose Memory diagnosis
In a command prompt (type command in the start search box then right click and choose Run as administrator) type
CHKDSK c: /r
If you have more than one drive replace C: with the other drive letters.
Search for corrupted files by typing at the command prompt
sfc/scannow
You can clean boot troubleshooting http://support.microsoft.com/kb/331796
-
Hi all
create the table wages (a number;
b the number);
--=================================================
declare
type record_salary is record
(rec_salary % rowtype salary,
number of rec_num);
type type_salary_tab is table of the record_salary
index by pls_integer;
tab_rec type_salary_tab;
Start
Select a, b, sum (b)
bulk collect into tab_rec
salary;
end;
get an error: expression tab_rec in the list is of the wrong type...
IF I can create the folder table, and I'm not bulk collect into it so that it uses for?
Thanks in advance
Hello
Please try the below.
DECLARE
Record_salary RECORD TYPE IS
(
rec_salary NUMBER,
rec_num NUMBER,
NUMBER OF SUM_OF_REC
);
TYPE type_salary_tab IS TABLE OF THE record_salary
INDEX BY PLS_INTEGER;
tab_rec type_salary_tab;
BEGIN
SELECT a, b, SUM (b)
LOOSE COLLECTION tab_rec
ON treatment
GROUP BY A, B;
DBMS_OUTPUT. Put_line (tab_rec. COUNT);
END;
1 group by is missing
2 guy's got that two elements
3. has changed the type of line to the number in the type declaration
Kind regards
Cool
-
Hi friends,
Is it possible to use XMLTYPE with record types?
For example, in the following code I expect output voltage
< TY_EMP > < > 1001 EMPNO < / EMPNO > < ADAMS ENAME > < / ENAME > < SAL > 5000 < / SAL > < TASK MANAGER > < / JOB > < / TY_EMP >
The code is...
DECLARE
Ty_emp RECORD TYPE IS
(
EmpNo INTEGER
, ename VARCHAR2 (100)
NUMBER of sal
, VARCHAR2 (100) employment
);
r_emp ty_emp;
BEGIN
r_emp.EmpNo: = 1001;
r_emp. Ename: = "Adams";
r_emp. SAL: = 5000;
r_emp.job: = "MANAGER";
-This line gives the error.
dbms_output.put_line (XmlType (r_emp). GETSTRINGVAL()); -Here, I don't want to talk about all the fields in the record. I just need to specify the name of the record.
END;
p.s. to use object types to generate XML data...
SQL > ed
A written file afiedt.buf1 TYPE to CREATE or REPLACE ty_emp () AS OBJECT
2 empno INTEGER
3, ename VARCHAR2 (100)
4, NUMBER of sal
5, job VARCHAR2 (100)
6* );
SQL > /.Type of creation.
SQL > ed
A written file afiedt.buf1 DECLARE
2 r_emp ty_emp: = new ty_emp (null, null, null, null);
3 BEGIN
4 r_emp.empno: = 1001;
r_emp.ename 5: = "Adams";
6 r_emp.sal: = 5000;
7 r_emp.job: = "MANAGER";
8 dbms_output.put_line (XMLTYPE (r_emp) .getstringval ());
9 * END;
SQL > /.
1001 Adams 5000 MANAGER PL/SQL procedure successfully completed.
SQL >
-
HelloI have a requirement of the company, where I need to return a record type (OUT parameter) for environment call based on the given input value.
Suppose that if the value is correct and corresponding record is found in the table then the return values for this key entry. If matching record is found, then return the exception to the calling environment.
To do this, I created an example of test table and populated records.
create table plch_test(dept_id number,dept_name varchar2(50),cost_centre number); insert into plch_test values(10,'SALES',1010); insert into plch_test values(20,'FINANCE',2010); insert into plch_test values(30,'MKTG',3010); SQL> select * from plch_test; DEPT_ID DEPT_NAME COST_CENTRE ---------- -------------------------------------------------- ----------- 10 SALES 1010 20 FINANCE 2010 30 MKTG 3010
I wrote a simple block and gave a valid key dept_id (10 in this case) to display costcentre for this dept_id and dept_name I said tow types of records, one for valid record and another exception
SQL> DECLARE 2 TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number); 3 l_rec_dept rec_dept; 4 TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300)); 5 l_rec_exception rec_exception; 6 BEGIN 7 SELECT dept_name,cost_centre 8 INTO l_rec_dept 9 FROM plch_test 10 where dept_id=10; 11 dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc); 12 EXCEPTION WHEN NO_DATA_FOUND THEN 13 l_rec_exception.err_code:=sqlcode; 14 l_rec_exception.error_message:=sqlerrm; 15 dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message); 16 END; 17 . SQL> / DEPT_NAME SALES COSTCENTRE 1010 PL/SQL procedure successfully completed. SQL>
Now for invalid dept_id and expose the message by using exception record type I stated.
SQL> ed Wrote file afiedt.buf 1 DECLARE 2 TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number); 3 l_rec_dept rec_dept; 4 TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300)); 5 l_rec_exception rec_exception; 6 BEGIN 7 SELECT dept_name,cost_centre 8 INTO l_rec_dept 9 FROM plch_test 10 where dept_id=40; --Invalid --data is not present 11 dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc); 12 EXCEPTION WHEN NO_DATA_FOUND THEN 13 l_rec_exception.err_code:=sqlcode; 14 l_rec_exception.error_message:=sqlerrm; 15 dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message); 16* END; SQL> / 100 ORA-01403: no data found PL/SQL procedure successfully completed.
Now as you can see I need to include this point in a procedure with an input parameter and output must be a record types which will return
rec_dept if it becomes a key input valid or an exception if she meets a key not valid.
CREATE PROCEDURE test_prc IS(p_in_dept_id IN plch_test.dept_id,p_output ?????? DECLARE TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number); l_rec_dept rec_dept; TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300)); l_rec_exception rec_exception; BEGIN BEGIN SELECT dept_name,cost_centre INTO l_rec_dept FROM plch_test where dept_id=p_ind_dept_id; RETURN l_rec_dept; EXCEPTION WHEN NO_DATA_FOUND THEN l_rec_exception.err_code:=sqlcode; l_rec_exception.error_message:=sqlerrm; RETURN l_rec_exception; END; dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc); END;
Hope that the explanation above help in imposes the requirement
Kind regards
Claudy kotekal
Return a record which can mean two things is complicated; I'm not an experienced myself pl/sql developer, but this looks like a craft.
The idea of exceptions under Sir Thomas of Kyte, is that any treatment must be stopped; You should RAISE an exception to the appellant so that he can figure out what to do with it. What you are saying, this is an exception, but is not a little, cos it's okay, I'll just keep but I will go back to the appellant in any way, but the appellant shall include this registration type is - would it be a record representing a row of the table, or it might be an exception... yuck.
(a) is it really an exception
(b) what do you do with it? You he could log into a table, you could write to a file, you can display an error message on the screen
But really, it's weird to want to pass an exception as return value.
These are all considerations of design, not really anything to do with the pl/sql language in itself.
But hard, if you send a record type a successful being found, registration-based stick to it and don't use it to return a record; do not try to do double duty with her flipping something else. Just save the message put in a table, or print it to the console, or what you want to do with; but as I said, the most important decision is, is this really an exception. And is based on the data model and the expectations of cleanliness of the data etc.
Think about how you call built-in functions. If you send garbage to a built-in function it does not return successfully, leaving you to figure out whether he succeeded or not by inspecting the return value; It goes kaboom, something bad happened. That's what your function should do if something bad happens, that is to say, if you get an exception, it should probably go kaboom.
-
How to use the record type as a parameter IN PL/SQL procedure or package
Hi people,
I need help on the record as the OUT parameter type. I am able to get out a single line as a parameter, but not getting do not idea how to get a multi ranks as output parameter.
I have the code that works very well for a single line. Please see CODE1.
But when I try to get several lines, I'm failing to do. Please see the CODE2. I get the error of compilation as
Error report:
ORA-06550: line 11, column 35:
PLS-00487: Invalid reference to the variable "P_NAME.
ORA-06550: line 11, column 1:
PL/SQL: Statement ignored
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error.
Any help or a sample execution of script would be really useful.
Thanks in advance.
YZ
--------------------------CODE1------------------------------------------
-------------------------Package Spec-------------------------------
CREATE OR REPLACE
PACKAGE xx_sample_pkg as
--
Xx_sample_table_rectype RECORD TYPE IS
(p_name varchar2 (40))
number of p_emp_id
);
PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);
END xx_sample_pkg;
------------------------------Package Body------------------------
create or replace
PACKAGE xx_sample_pkg AS BODY
--
PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS
BEGIN
SELECT ename, empno
IN xx_sample_rec1
FROM scott.emp
WHERE ename = 'SMITH ';.
END xx_sample_prc;
END xx_sample_pkg;
-------------------------------------------Execute----------------------
DECLARE
l_rec_type xx_sample_pkg.xx_sample_table_rectype;
BEGIN
dbms_output.put_line ('xx_sample_prc appeal');
xx_sample_pkg.xx_sample_prc (l_rec_type);
dbms_output.put_line ('YZ' | l_rec_type.p_name |') '|| l_rec_type.p_emp_id);
END;
---------------------------------------------------------------
-------------------------CODE2-------------------------------------------
-------------------------Package Spec-------------------------------
CREATE OR REPLACE
PACKAGE xx_sample_pkg as
--
Xx_sample_table_rectype RECORD TYPE IS
(p_name varchar2 (40))
number of p_emp_id
);
PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);
END xx_sample_pkg;
------------------------------Package Body------------------------
create or replace
PACKAGE xx_sample_pkg AS BODY
--
PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS
BEGIN
SELECT ename, empno
IN xx_sample_rec1
FROM scott.emp;
END xx_sample_prc;
END xx_sample_pkg;
-------------------------------------------Execute----------------------
DECLARE
l_rec_type xx_sample_pkg.xx_sample_table_rectype;
BEGIN
dbms_output.put_line ('xx_sample_prc appeal');
xx_sample_pkg.xx_sample_prc (l_rec_type);
for l_rec in 1.l_rec_type.p_name.count
loop
dbms_output.put_line ('YZ' | l_rec_type.p_name (l_rec) |) » '|| l_rec_type.p_emp_id (l_rec));
end loop;
end;
---------------------------------------------------------------
bb8c573a-6ca3-4d7c-90ed-e55c2df67201 wrote:
But now, my question would be why the record type could not be used? My understanding is missing some concept between use of type type array collection record vs. Please specify.
Do not confuse the folder with the collection.
SY.
-
PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
Hello
Having a little trouble with the following code example provided to http://www.dba-oracle.com/plsql/t_plsql_cursor_variables.htm:
In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.1 DECLARE 2 TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER; 3 c_cursor t_ref_cursor; 4 l_row NUMBER; 5 BEGIN 6 DBMS_OUTPUT.put_line('Strongly typed REF CURSOR using SCALAR type. Expect an error!'); 7 OPEN c_cursor FOR 8 SELECT COUNT(*) cnt 9 FROM cursor_variable_test; 10 LOOP 11 FETCH c_cursor 12 INTO l_row; 13 EXIT WHEN c_cursor%NOTFOUND; 14 DBMS_OUTPUT.put_line(l_row); 15 END LOOP; 16 CLOSE c_cursor; 17* END; 18 / TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER; * ERROR at line 2: ORA-06550: line 2, column 24: PLS-00362: invalid cursor return type; 'NUMBER' must be a record type ORA-06550: line 2, column 3: PL/SQL: Item ignored
Why can't return a value in a column of a row in a NUMBER?
How can I change the SQL code so that I can do this?
Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
Thank you very much
Jason>
TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
*
ERROR on line 2:
ORA-06550: line 2, column 24:
PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
ORA-06550: line 2, column 3:
PL/SQL: Ignored ElementIn the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
Why can't return a value in a column of a row in a NUMBER?
How can I change the SQL code so that I can do this?
>
The exception is in line 2: your cursor statement. And the answer is in the text that you access
>
The return value of a strongly typed REF CURSOR must be a folder that can be defined using % TYPE % ROWTYPE attributes or record structure.
>
You said the CURSOR to return a NUMBER. And as the text says, he must be a 'record '.
>
Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
>
As you said already FETCH retrieves the next line, if any. A query is a request is a request. It returns a result set. A query that uses aggregates returns a result set. A query that does not aggregate returns a result set.Your simple COUNT (*) SELECT query returns a result set that consists of a LINE and a line a ONE COLUMN of type NUMBER. Although there is only one column in the result set, what is returned is a RECORD or a LINE. That's why you have to report your data cursor return type a document using the % ROWTYPE or % TYPE attributes or a record structure.
-
Manufacturers of record Type in packages
I'm having trouble getting this error. Here is an example of my code:create or replace PACKAGE MyPackage AS TYPE MyPerson IS RECORD ( "NAME" VARCHAR2(255 CHAR) ); FUNCTION GetPerson RETURN MyPerson; END MyPackage;
After executing these separately, I get the following errors when executing the BODY of PACKAGE statement:create or replace PACKAGE BODY MyPackage AS FUNCTION GetPerson RETURN MyPerson AS John MyPerson := MyPerson('John'); BEGIN RETURN John; END GetPerson; END MyPackage;
Error (6,10): PL/SQL: ignored element
is there a particular reason, I can't use a type defined in the PACKAGE header?
Error (6.22): PLS-00222: no function with name "MYPERSON" does exist in this scope
Error (8.5): PL/SQL: statement ignored
Error (8,12): PLS-00320: the declaration of the type of the expression is incomplete or incorrect
Select * from V$ Version:database Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
EDIT: formatting and v$ version
PL/SQL Release 11.2.0.3.0 - Production
"CORE 11.2.0.3.0 Production."
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Published by: 961346 Sep 25, 2012 12:39Hello
MyPerson is a record type, and it is not a collection.
The collections have constructors.
Not record.Try like this:
create or replace PACKAGE BODY MyPackage AS FUNCTION GetPerson RETURN MyPerson AS John MyPerson; BEGIN john.name := 'John'; RETURN John; END GetPerson; END MyPackage;
Kind regards
Peter
Published by: Peter vd Zwan Sep 25, 2012 12:56
-
Dynamic SQL with in bulk in the record type
Oracle 10.2 g
I received this Tom
[http://asktom.oracle.com/pls/apex/f?p=100:11:0:NO:]
I'm able to do this without dynamic SQL, but my requirement is to do it in dynamic SQL
There is a work around in 11g, but can we do something in 10g?create table t1 ( x int, y int ); insert into t1 select rownum, rownum+1 from all_users where rownum <= 5; create table t2 ( x int, y int, z int ); declare type array is table of t1%rowtype; l_data array; begin select * bulk collect into l_data from t1; forall i in 1 .. l_data.count execute immediate 'insert into (select x, y from t2) values :x' using l_data(i); end; Error at line 1 ORA-06550: line 9, column 90: PLS-00457: expressions have to be of SQL types ORA-06550: line 9, column 20: PL/SQL: Statement ignored
Thank you
HESH.HESH wrote:
but following does not.
declare type array is table of t1%rowtype; l_data array; begin select * bulk collect into l_data from t1; forall i in 1 .. l_data.count execute immediate 'insert into (select x, y from t2) values :x' using l_data(i); end;
I want just a dynamic SQL code for the insert with FORALL statement would adopt as well as collections.
Doesn't make much sense.
Extract you the data from the SQL engine in the table of the record type. If the output data that cursor SQL must be read in the SQL engine and copied into the memory of PL/SQL engine.
Then, you send that VERY SAME DATA back to the SQL engine to be used by a SQL insert cursor.
Where is the logic behind the extraction of data from SQL in a PL/SQL table structure and then push this same structure table on the SQL engine database? What is the purpose to send data on a detour of underperforming and non-scalale through the PL/SQL engine?
You have any justification (technical or functional wise) to back up this absurd approach?
Why this can be achieved using a single SQL cursor that does both the choice (extraction) and (in bulk) insertion - using the plain old INSERT... SELECT structure?
And if the insert is variable, then what? Create a dynamic INSERT... SELECT cursor and execute it (using bind values). This simple... Right?
-
How to create a type of record and a pl/sql table of this record type in the database
Hello
I want to create a record type, and then I want to create a PL/SQL table in the oracle 9i database.
I did block PL/SQL.
But when I'm doing it in the database it throws me a few errors.
Could you please tell me how can I do?
Concerninguser576726 wrote:
Hello
I want to create a record type, and then I want to create a PL/SQL table in the oracle 9i database.
I did block PL/SQL.
But when I'm doing it in the database it throws me a few errors.
Could you please tell me how can I do?Concerning
RECORD type is only supported in PL/SQL for SQL, you must use the OBJECT type.
-
Hello experts.
create type emp2_obj is object
(
objno number,
objname varchar2(20),
objdept number
);
create type emp2_objarr is table of emp2_obj;and
type emp2_rec is record
(
recno number,
recname varchar2(20),
recdept number
);
create type emp2_recarr is table ofemp2_rec
;Objects and types of records are created similar and have the same similar object. Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice
user13328581 wrote:
the only reason why I ask is because he asked during an interview
-Objects and the types of records are created similar and have the same similar object. Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice
Not at all. You can use record types used with collection types outside. They are a group concept. If you want to group a set of values together (including fields), you can use a record. It may be convenient. You can send documents around proc and functions.
Be aware that the record types are limited to procedures, functions, anonymous blocks and packages (i.e. PL/SQL), while the types of objects are stored in the dictionary of data as a separate Oracle objects (they can also have methods, the records may not). Object types can be used in SQL, as said sol.beach types of records (outside of the intelligent pipeline situations) is for PL/SQL.
-
Record Type in need help package tests
Hello
Please can you help me in the record Type of tests that I defined as:
I said record Type in the package TEST_PART_PKG
CREATE OR REPLACE PACKAGE TEST_PART_PKG AS
TYPE req_line_rec_type () IS RENDERING
PART_NUMBER VARCHAR2 (100),
part_line_num NUMBER,
part_name VARCHAR2 (100),
part_po_number VARCHAR2 (100),
un_number NUMBER,
part_class VARCHAR2 (20).
part_org_name VARCHAR2 (50));
TYPE req_line_tbl IS TABLE OF THE req_line_rec_type
INDEX OF DIRECTORY;
PROCEDURE update_part_line)
IN OUT NOCOPY p_req_line_tbl req_line_tbl,
p_init_msg IN VARCHAR2,
p_req_line_tbl_out OUT NOCOPY req_line_tbl,
p_req_line_err_tbl OUT NOCOPY req_line_tbl,
p_submit_approval IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_error_msg OUT NOCOPY VARCHAR2,
p_commit IN VARCHAR2);
END;
I want to test the procedure in the package passing variables but how to approach to it?
I want to call the procedure packaged using:
DECLARE
BEGIN
TEST_PART_PKG. update_part_line
END;
v_req_line_out and v_req_line_err are the parameters, so they do not need initialization, just definition what is the procedure to put something that is.
We can only guess the purpose of these two parameters. Maybe you need to separate the records updated the destination of those that out wrong for further treatment table and that you are able to present a table of rows to update the destination table, the two parameters must be tables of rows as in general, more a single record can be the source of updated and more than one record can mistake.
Concerning
Etbin
Maybe you are looking for
-
When I try to install command and conquer generals error 1603 rises said that it's a big audio file what it means and how to fix
-
YouCam is black and does not display any image
I have a HP Pavilion g6 Notebood PC product number - A9S02PA #ABG Windows 7 Home Premium 64-bit, Service Pack 1, with a built-in webcam that uses CyberLink YouCam. Everything is up-to-date, the drivers are updated, computer says HP Webcam device WORK
-
We are having some trouble getting OpenAL for work on the Playbook. The first call OpenAL we do is: alcOpenDevice (0); When we call alGetError(), immediately after, it returns AL_INVALID_OPERATION. Although the subsequent alGetError call returns AL_I
-
How do I reboot, I have restart, which do not work
I donnot know how to find restarting computer, I can only find restart and that doesnot work to get out of safe mode, I tried everything, thank you
-
OPM file [subscription goes to trial]
I had the creative cloud adobe for a while now, but recently, it has been in place in recent times. He recently stated that I only had the trial version with 7 days to use each app when I started. Even though I sighed he always says I got the trial v