How to declare a table type while executing a Procdure??
Hi All,
I'm facing a problem that i'm not able to call a type as an input to a proc.
My proc has two inputs as table type and other normal inputs.
I'm using these table type to insert value into another table.
But when i try and execute the procedure in a DECLARE - BEGIN - END block, i'm not able to define the type properly.
Please help mw put on this??
Thnx in advance!!!
Are you trying to create stored procedure with table type parameter? If so, you either needto declare table type in sql or in a PL/SQL package. For example:
SQL> create or replace
2 type tbl_type
3 as table of number
4 /
Type created.
SQL> create or replace
2 procedure p1(
3 p_tbl tbl_type
4 )
5 is
6 begin
7 for i in 1..p_tbl.count loop
8 dbms_output.put_line(p_tbl(i));
9 end loop;
10 end;
11 /
Procedure created.
SQL> set serveroutput on
SQL> begin
2 p1(tbl_type(1,3,5,99));
3 end;
4 /
1
3
5
99
PL/SQL procedure successfully completed.
SQL> create or replace
2 package pkg1
3 is
4 type tbl_type is table of number;
5 end;
6 /
Package created.
SQL> create or replace
2 procedure p2(
3 p_tbl pkg1.tbl_type
4 )
5 is
6 begin
7 for i in 1..p_tbl.count loop
8 dbms_output.put_line(p_tbl(i));
9 end loop;
10 end;
11 /
Procedure created.
SQL> set serveroutput on
SQL> begin
2 p2(pkg1.tbl_type(1,3,5,99));
3 end;
4 /
1
3
5
99
PL/SQL procedure successfully completed.
SQL> SY.
Similar Messages
-
How to handle the table control While working with LSMW?
How to handle the table control While working with LSMW?
its possible in lsmw,
Hi,
LSMW will have a Indicator for headr and itam, i do not remember the correct field, but it will have an indicator, check the fields, there will be a single charecter lenght field, that should be the indicator, and using that we can write the logic.
check that single charecter field, it that is X that means the header record is processed, and do the items.
and, this is another way, try this out also
YOu can do this in "Define Source Structures" step,
the HEADER is defined first,
then the DETAIL below the HEADER.
add the fields to the structures.
Both should have some common key field
Please take care that the name of the common field is the same.
Once you do this it is linked. The you have a header and item corresponding to that header. then run the LSMW as you would.
Thanks -
How/ where to check output type while saving sales order for confirmation
Hi All,
Could you anyone pls let me know How/ where to check output type while saving sales order for confirmation.
Present scenario : when the Sales Order is created the Order confirmation is sent irrespective of credit block of the sales order.
Requirement : Order confirmation ZA00 sent to the partner only for those Sales orders which does not have credit block and ZCLE sent to the partner if the order has credit block.
Now i want to know where exactly to check the output types "ZA00" and 'ZCLE' based on the credit block to send the confirmation to partener.
Quick help highly appreciated......
PreethamHi Santosh,
Thanks for the info. But here in this case I have to send the confiramation based on credit limit check. If credit limit check exceeds "ZCLE' should go as confirmation else 'ZA00' should go as confirmation.
Where can we check the credit limit whether it exceeded or not. My doubt is whether it is config issue or do we need to write code user exit or routine to send the specific output type for confirmation.
Thanks & Regards,
Preetham -
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
How to declare Dynamic table in Tables Parameters of a Function Module...
Hi Gurus,
I would like to Know how to declare a Dynamic table in Tables parameters of a Function Module.
so that it should be able to hold any table data ....
I have tried all possible ways of trying to assign fields-symbol like declarations which doesnt allow here ...
plz Dont reply with the basics of creating dynamic internal tables, coz my case is not an Internal table it is FM table parameter declaration.....Hi,
If you are requirement is to create a function module with tables parameter having a generic line type i.e. no specific line type
just declare it with a name under Parameter name with out specifying the type.
A reference function module with such parameter, i would quote is the standard GUI_UPLOAD/ GUI_DOWNLOAD where the parameters specified under TABLES are generic.
If you want to process the values passed to these parameters in the source code of function module, field symbols would be a preferable option.
Regards,
Sharath Panuganti -
How to declare internal table in BADI with variable name beginning with 0..
Gurus,
How to declare an internal table within a BADI. I have to implement a BADI UC_TASK_CUSTOM for BCS to BW load and there i have to declare an internal table like:
TYPES: BEGIN OF t_cube_data,
0cs_version TYPE /bi0/oics_version,
0sem_cgcomp TYPE /bi0/oisem_cgcomp,
bcs_vers TYPE /bic/oibcs_vers,
bcs_lcus TYPE /bic/oibcs_lcus,
bcs_ldch TYPE /bic/oibcs_ldch,
bcs_invcom TYPE /bi0/oibcs_invcom,
bcs_litem TYPE /bic/oibcs_litem,
bcs_llob TYPE /bic/oibcs_llob,
bcs_lmay TYPE /bic/oibcs_lmay,
0move_type TYPE /bi0/oimove_type,
pcompany TYPE /bi0/oipcompany,
bcs_lprg TYPE /bic/oibcs_lprg,
figlxref3 TYPE /bic/oifiglxref3,
fiscyear TYPE /bi0/oifiscyear,
fiscper3 TYPE /bi0/oifiscper3,
fiscvarnt TYPE /bi0/oifiscvarnt,
curkey_gc TYPE /bi0/oicurkey_gc,
unit TYPE /bi0/oiunit,
cs_trn_gc TYPE /bi0/oics_trn_gc,
cs_trn_qty TYPE /bi0/oics_trn_qty,
END OF t_cube_data
But with this declaration it gives a error saying that u cannot have a variable beginning with 0...like 0cs_version....
but i have to do it for my functionality to wrk...
Please help me do it....
how can i declare a internal table that allows me to have variable names that start with 0....
Please help....Its URGENT....
Thanks
SamMurali,
I need to have 0 before the variable name in the declaration of the internal table....how can i attain that....
Please suggest...
Thanks
Sam -
How to Populate a table type variable from a cursor
Hi
I have a stored procedure (P1) that returns a ref cursor as the output.
Another procedure (P2) receives this ref cursor (C).
In this procedure (P2), I want to do a Bulk Collect from this ref cursor (C) in
a table type variable that has been declared locally in the procedure P2. I have created appropriate Object Type and Table Types at the database level.
Please advise how to do it. I tried to do it in different ways, but was not able to do it - each time I faced incompatible data-type related issues.
Regards
MadhupWhat I wrote was unclear. Syntactically it is valid and does something. But consider the advantage of a decent design.
SQL> create or replace procedure p1 (o out sys_refcursor) as
2 begin
3 open o for select * from emp;
4 end p1;
5 /
Procedure created.
SQL> create or replace procedure p2(i sys_refcursor) as
2 type emp_tab is table of emp%rowtype;
3 l_emp_tab emp_tab;
4 begin
5 fetch i bulk collect into l_emp_tab;
6 close i;
7
8 for i in 1..l_emp_tab.count loop
9 NULL;
10 end loop;
11 end p2;
12 /
Procedure created.
SQL> CREATE OR REPLACE PROCEDURE p3 IS
2
3 TYPE myarray IS TABLE OF emp%ROWTYPE;
4 l_data myarray;
5
6 CURSOR r IS
7 SELECT * FROM emp;
8
9 BEGIN
10 OPEN r;
11 LOOP
12 FETCH r BULK COLLECT INTO l_data;
13
14 FOR j IN 1 .. l_data.COUNT
15 LOOP
16 NULL;
17 END LOOP;
18
19 EXIT WHEN r%NOTFOUND;
20 END LOOP;
21 CLOSE r;
22 END p3;
23 /
Procedure created.
SQL> set serverout on
SQL> set timing on
SQL> declare
2 r sys_refcursor;
3 begin
4 FOR i IN 1 .. 10000 LOOP
5 p1(r);
6 p2(r);
7 END LOOP;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.71
SQL> begin
2 FOR i IN 1 .. 10000 LOOP
3 p3;
4 END LOOP;
5 end;
6 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.21
SQL> Again sorry for being less than clear. -
How to create a table type context node
Hi,
I am trying to create table type context node. While creating, in the wizard no where I can see the option for this.
Could you please let me know how can I do this?
In one standard component: SRQM_INCIDENT_H, I can see multiple table type context nodes. Not sure how and why?
Thanks,
SandeepHI Sandeep,
When you right click on context node and create , a wizard will open. In that Wizard in one sreen it will ask for type of view. There you have to select Table View.
Regards,
Lakshmi.Y -
How pass date parametet in procedure while executing
I am written procerdure in which I have to pass parameter the datatype is date how can I am able to pass the date while executing
please help meya its from the cient application but I am checking that procedure is executing properly or not so I passing it through prompt.
I am executing in tha same format given by u, its displaying following error
BEGIN HANGER_FAILURE_PROCEDURE (to_date('01-jan-05','dd-mon-yy') ); END;
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at "SYSTEM.HANGER_FAILURE_PROCEDURE", line 62
ORA-06512: at line 1
===============================
And my procedure is
CREATE OR REPLACE PROCEDURE HANGER_FAILURE_PROCEDURE (startDate IN FRIT_HANGER.AGING_START_TIME%TYPE ) IS
shiftDescription SHIFT.DESCRIPTION%TYPE;
failure_number HANGER_FAILURE.FAILURE_NUMBER%TYPE;
failure HANGER_FAILURE.FAILURE_NUMBER%TYPE;
fritID LVT_TEST.FRIT_ID%TYPE ;
lvt_description LVT.DESCRIPTION%TYPE;
test_time LVT_TEST.TEST_TIME%TYPE ;
mikr LVT_TEST.MIKR%TYPE;
mikr_res LVT_TEST.MIKR_PASSED%TYPE;
mikg LVT_TEST.MIKG%TYPE;
mikg_res LVT_TEST.MIKG_PASSED%TYPE;
mikb LVT_TEST.MIKB%TYPE;
mikb_res LVT_TEST.MIKB_PASSED%TYPE;
coe2r LVT_TEST.COE2R%TYPE;
coe2r_res LVT_TEST.COE2R_PASSED%TYPE;
coe2g LVT_TEST.COE2G%TYPE;
coe2g_res LVT_TEST.COE2G_PASSED%TYPE;
coe2b LVT_TEST.COE2B%TYPE;
coe2b_res LVT_TEST.COE2B_PASSED%TYPE;
grparameter AGING_TEST.GR%TYPE;
ccr VTS_TEST.CCR%TYPE;
ccg VTS_TEST.CCG%TYPE;
ccb VTS_TEST.CCB%TYPE;
aging_hangerId AGING_HANGER.AGING_HANGER_ID%TYPE;
aging_start_time FRIT_HANGER.AGING_START_TIME%TYPE;
failure_type HANGER_FAILURE_TYPE.HANGER_FAILURE_TYPE_ID%TYPE;
CURSOR result_lvt(sdate FRIT_HANGER.AGING_START_TIME%TYPE) IS
SELECT
AGING_HANGER.AGING_HANGER_ID,
LVT.DESCRIPTION,
FRIT_HANGER.AGING_START_TIME,
LVT_TEST.FRIT_ID,
LVT_TEST.TEST_TIME,
LVT_TEST.MIKR,
LVT_TEST.MIKR_PASSED,
LVT_TEST.MIKG,
LVT_TEST.MIKG_PASSED,
LVT_TEST.MIKB,
LVT_TEST.MIKB_PASSED,
LVT_TEST.COE2R,
LVT_TEST.COE2R_PASSED,
LVT_TEST.COE2G,
LVT_TEST.COE2G_PASSED,
LVT_TEST.COE2B,
LVT_TEST.COE2B_PASSED
FROM LVT_TEST,LVT,FRIT_HANGER,AGING_HANGER
WHERE LVT_TEST.LVT_ID=LVT.LVT_ID
AND
FRIT_HANGER.AGING_HANGER_ID=AGING_HANGER.AGING_HANGER_ID
AND LVT_TEST.FRIT_ID=FRIT_HANGER.FRIT_ID
AND FRIT_HANGER.AGING_START_TIME>sdate
ORDER BY FRIT_HANGER.AGING_START_TIME;
BEGIN
IF result_lvt%ISOPEN THEN
OPEN result_lvt(startDate);
END IF;
LOOP
FETCH result_lvt
INTO aging_hangerId, lvt_description, aging_start_time, fritID, test_time, mikr, mikr_res, mikg, mikg_res, mikb, mikb_res, coe2r, coe2r_res, coe2g, coe2g_res, coe2b, coe2b_res;
exit when result_lvt%NOTFOUND;
SELECT GR INTO grparameter
FROM AGING_TEST
WHERE
TEST_TIME = (SELECT MAX(TEST_TIME) FROM AGING_TEST WHERE FRIT_ID = fritID);
SELECT CCR, CCG, CCB INTO ccr,ccg,ccb
FROM VTS_TEST
WHERE TEST_TIME = (SELECT MAX(TEST_TIME) FROM VTS_TEST WHERE FRIT_ID = fritID);
SELECT DESCRIPTION INTO shiftDescription
FROM SHIFT
WHERE START_TIME=TRUNC( aging_start_time);
IF( mikr_res=0 OR mikg_res = 0 OR mikb_res = 0 )
THEN
SELECT MAX(FAILURE_NUMBER) INTO failure
FROM HANGER_FAILURE
WHERE AGING_HANGER_ID=aging_hangerId
AND TO_DATE(AGING_START_TIME) = TO_DATE(aging_start_time)
AND
SHIFT_DESCRIPTION = shiftDescription;
failure_number:=failure+1;
SELECT HANGER_FAILURE_TYPE_ID INTO failure_type
FROM HANGER_FAILURE_TYPE
WHERE DESCRIPTION='MIK';
INSERT INTO HANGER_FAILURE (HANGER_FAILURE_ID, HANGER_FAILURE_TYPE_ID, AGING_HANGER_ID,
SHIFT_DESCRIPTION, AGING_START_TIME, FAILURE_NUMBER, LVT_DESCRIPTION,FRIT_ID,TEST_TIME, MIKR, MIKG, MIKB, COE2R, COE2G, COE2B, GR,CCR, CCG ,CCB ) VALUES(HANGER_FAILURE_ID_GENERATOR.NEXTVAL, failure_type, aging_hangerId, shiftDescription,aging_start_time,failure_number ,lvt_description, fritID,test_time, mikr,mikg,mikb,coe2r,coe2g,coe2b,grparameter,ccr,ccg,ccb);
ELSE
DBMS_OUTPUT.PUT_LINE('Doesn''t occur any MIK failure');
END IF;
IF (coe2r_res = 0 OR coe2g_res = 0 OR coe2b_res = 0)
THEN
SELECT MAX(FAILURE_NUMBER) INTO failure
FROM HANGER_FAILURE
WHERE AGING_HANGER_ID=aging_hangerId
AND TO_DATE(AGING_START_TIME) = TO_DATE(aging_start_time)
AND
SHIFT_DESCRIPTION = shiftDescription;
failure_number :=failure+1;
SELECT HANGER_FAILURE_TYPE_ID INTO failure_type
FROM HANGER_FAILURE_TYPE
WHERE DESCRIPTION='COE2';
INSERT INTO HANGER_FAILURE (HANGER_FAILURE_ID,HANGER_FAILURE_TYPE_ID,AGING_HANGER_ID,
SHIFT_DESCRIPTION,AGING_START_TIME ,FAILURE_NUMBER, LVT_DESCRIPTION,FRIT_ID,TEST_TIME,MIKR,MIKG,MIKB,COE2R,COE2G,
COE2B,GR ,CCR,CCG ,CCB ) VALUES(HANGER_FAILURE_ID_GENERATOR.NEXTVAL, failure_type, aging_hangerId, shiftDescription,aging_start_time,failure_number ,lvt_description, fritID,test_time, mikr,mikg,mikb,coe2r,coe2g,coe2b,grparameter,ccr,ccg,ccb);
ELSE
DBMS_OUTPUT.PUT_LINE('Doesn''t occur any COE2 failure');
END IF;
END LOOP;
CLOSE result_lvt;
END;
plz help me -
How to insert into table type variables
hi all,
how to assingn values to table type variable, i am getting error.
declare
dept1 dept%rowtype;
begin
dept1:=(100,'SHIPPING','HYDERABAD');
end;
ERROR at line 4:
ORA-06550: line 4, column 8:
PLS-00382: expression is of wrong type
regards,
Sri Ram.You can do like this
declare
dept1 dept%rowtype;
begin
dept1.deptno := 10;
dept1.dname := 'IT';
end;
/ -
How to change the document type while creating a PO by ME59N
Hi,
I have 2 groups of PR's, for group one the document type is picked as NB and PO is created and for the group 2 it should pick as XYZ and PO should be created using ME59N tcode.
How to change the document type for group 2 in ME59N? Which user exists to use to change the document type while creating PO in ME59N?
Can any one suggest me.Hi,
There a config area, where you can define default PO doc types for a particular Pr doc type. If you maintain the settings properly there, then your requirement can be fulfilled.
SPRO->IMG->MM->Purchasing->Purchase requisation->Define doc types.
This will serve your purpose.
Thanks,
Srinu -
HR abap : how to declare internal table to fetch data from 0585 infotype
Hi all ,
I am able to fetch the data from pa0585 infotype for set of employee no , but the problem is as the fields in pa0585 (like Contr to ULIP , NSC , Medical Treatment,Contribution to Certain Pension Funds so on ..) will be changed dynamically and will be displayed based on the amount value in descending order iam not able to store the values of the fileds into internal table . I dont understand how to declare the internal table ..Please help in if u have solved this kind of problem.
I shld get the output in this way ...
Emp No Name Medical treatment Contr to ULIP ....... so on
101 abc 10000 150000 .......so on
102 xyz 12000 150000 .......so on
My header shld be fixed and I shld display values in this way .... I can use write statement to display directly .
Thanks ....Hi
Decalre INFOTYPE
Goto SE37 - Find FM -
READINFOTYPE* -
How to access the table type field in the structure
Hi All,
I have a BADI CRM_MKT_ADR_SEARCH and a method CHANGE_SEARCH_RESULTS in this method I have a parameter CT_BP_CP_CHANNEL .This parameter has type CRMT_BP_CP_CHANNEL_TAB(this is table type) this has the line type CRMT_BP_CP_CHANNEL(this is structure) in this line type we have one field addrnumber.How to access this field in my method?Please help me in this regard.data lw_tab type CRMT_BP_CP_CHANNEL.
loop at CRMT_BP_CP_CHANNEL_TAB into lw_tab.
lv_field = lw_tab-addrnumber.
<further processing>
endloop. -
How to change partition table type
I want to change my windows 7 partition table type, but I don't know anything about computer, is there any simple ways to do that? Someone recommend me Easeus partition master, which is a free partition software, but I don't know this kind of software,
any advice?Hi,
You can use diskpart command to convert partition table type.
Change a GUID Partition Table (GPT) Disk into a Master Boot Record (MBR) Disk:
http://technet.microsoft.com/en-us/library/cc725797.aspx
Convert a MBR Disk to a GPT Disk:
http://www.sevenforums.com/tutorials/26193-convert-mbr-disk-gpt-disk.html
Note Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.
Thanks!
Andy Altmann
TechNet Community Support -
How to use nested table types with XDK
Im using Oracles XDK (xml development kit) to create xml-documents from data in database.4
Problem: I need to use nested tables but when trying to create nested table types I get error: A Table type may not contain a nested table type or VARRAY.
Hope I make myself clear! Are there any solutions or workarounds to this problem?
Help appreciated, thanks!Jesper,
I asked similar question last year (search for Tapsell, you will see my posting). Under 8.1.7 the "nesting" seems restricted to one level down. Thus you cannot create a type using another object that itself includes a nested table. Under Oracle 9, against which most current examples seem based, this limitation is removed making things easier. Under 8.1.7 the workaround I have used is to use the CAST syntax. This is not as neat, but it works.
Maybe you are looking for
-
Can't login with my apple ID to purchase music
i had to create a new password a little while ago & succeeded in purchasing 2 albums with no trouble, but then when i was about to purchase a 3rd itunes asked me to log in with my apple id again and wouldn't let me log on. no matter how many times i
-
Does anyone know how to group songs by album, and then by artist. Essentially I say this because of compilations. Generally I like to keep things sorted by artist. The only problem with this is the fact that I have several compilations, so sorting by
-
Report viewer 2010 show blank page (with params loaded)
Hi, I have an infrastructure RS with a web server with an ASP.NET application with Report Viewer and a second server with an installation of RS 2008 R2. My web application (ASP.NET in C #) uses the ReportViewer 2010 component to show the report. I
-
Changing meta data when burning CD
I just burned a CD that had only song title, artist, time and year in the Playlist. When the CD mounted after burning, it had artist, album, genre and time. What happened? Are these defaults and if so, how can they be changed?
-
Use param for SQL statement...
Hi, all, Thanks for the help. I have a select statement working in sqlplus: SELECT A.addressid FROM JOHNDOE.tb_Address A, JOHNDOE.tb_Address B WHERE B.Addressid = 1 AND SDO_WITHIN_DISTANCE(A.Location, B.location, 'DISTANCE = 12.8 UNIT = MILE') = 'TRU