473,654 Members | 3,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table type parameter to a procedure

151 New Member
HI All



I need help regarding this, i have a procedure that processes some data. I created one more procedure and i am calling the first procedure from the second with some parameters. Out of the available parameters, there are two which should be of table type.

How to pass a table type parameters and how to declare them

please help me out

vamsi
Mar 24 '08 #1
13 41710
amitpatel66
2,367 Recognized Expert Top Contributor
The easiest way should be using a package that contains a TYPE of table, and use the aliases of this table as input parameter types. Check this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE OR REPLACE PACKAGE test_table AS
  3. TYPE emp_data IS TABLE OF emp%ROWTYPE;
  4. END test_table;
  5. /
  6.  
  7. CREATE OR REPLACE PROCEDURE first_proc(a IN NUMBER, emp_dat IN OUT test_table.emp_data NOCOPY) AS
  8. BEGIN
  9. SELECT * BULK COLLECT INTO emp_dat FROM emp;
  10. END first_proc;
  11. /
  12.  
  13. DECLARE
  14. empd test_table.emp_data;
  15. num1 INTEGER;
  16. BEGIN
  17. first_proc(num1, empd);
  18. FOR I IN empd.FIRST..empd.LAST LOOP
  19. DBMS_OUTPUT.PUT_LINE(empd(i).empno);
  20. END LOOP;
  21. END;
  22. /
  23.  
  24.  

Note: I have not tested this code!!
Mar 24 '08 #2
vamsioracle
151 New Member
Thank u ver much, i 'll try that but just check this code which i have written.
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE OR REPLACE PROCEDURE XXBIOUK_STATUS_UPDT_PROC
  3. AS
  4. ===================table type=====================
  5. type v_attributes_category is table of varchar2(1000)
  6. index by binary_integer;
  7. type v_n_attributes_tbl is table of number
  8. index by binary_integer;
  9. type v_d_attributes_tbl is table of date
  10. index by binary_integer;
  11.  
  12. =========== table type ===
  13. v_a v_attributes_category;
  14. v_b v_attributes_category;
  15. v_c v_n_attributes_tbl;
  16. v_d v_d_attributes_tbl;
  17. =====================cursor==================
  18. CURSOR c_lotnumber_cur
  19.   IS
  20.  SELECT
  21.      organization_id,
  22.      inventory_item_id,
  23.      lot_number,
  24.      item_number,
  25.      attribute1,
  26.      expiration_date,
  27.      lot_status
  28.  FROM
  29.   xxbio_lotnumber_status
  30.  WHERE
  31.   org_group_name = 'USA'
  32.   OR org_group_name = 'UK'
  33.   AND lot_status = 'APPROVED'
  34.   OR lot_status = 'REJECT'
  35.   AND erp_extract_flag='N';
  36. ========================================
  37. BEGIN
  38. FOR ln_rec_counter IN c_lotnumber_cur
  39. LOOP
  40. =====calling a package.proc inside loop========
  41. inv_lot_api_pub.update_inv_lot
  42. (
  43. =======passing table type params to proc====
  44. v_a,
  45. v_b,
  46. v_c,
  47. v_d,
  48. 0;
  49. ==============error i get =======
  50.  
  51.  
  52.  PLS-00306: wrong number or types of arguments in call to
  53.  'UPDATE_INV_LOT'
  54.  

what might be the problem
Mar 24 '08 #3
amitpatel66
2,367 Recognized Expert Top Contributor
Can you post the proceudre within your package for reference?

inv_lot_api_pub .update_inv_lot ?
Mar 24 '08 #4
vamsioracle
151 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. PROCEDURE update_inv_lot(
  3.     x_return_status          OUT NOCOPY    VARCHAR2
  4.   , x_msg_count              OUT NOCOPY    NUMBER
  5.   , x_msg_data               OUT NOCOPY    VARCHAR2
  6.   , p_inventory_item_id      IN            NUMBER
  7.   , p_organization_id        IN            NUMBER
  8.   , p_lot_number             IN            VARCHAR2
  9.   , p_expiration_date        IN            DATE
  10.   , p_disable_flag           IN            NUMBER
  11.   , p_attribute_category     IN            VARCHAR2
  12.   , p_lot_attribute_category IN            VARCHAR2
  13.   , p_attributes_tbl         IN            inv_lot_api_pub.char_tbl
  14.   , p_c_attributes_tbl       IN            inv_lot_api_pub.char_tbl
  15.   , p_n_attributes_tbl       IN            inv_lot_api_pub.number_tbl
  16.   , p_d_attributes_tbl       IN            inv_lot_api_pub.date_tbl
  17.   , p_grade_code             IN            VARCHAR2
  18.   , p_origination_date       IN            DATE
  19.   , p_date_code              IN            VARCHAR2
  20.   , p_status_id              IN            NUMBER
  21.   , p_change_date            IN            DATE
  22.   , p_age                    IN            NUMBER
  23.   , p_retest_date            IN            DATE
  24.   , p_maturity_date          IN            DATE
  25.   , p_item_size              IN            NUMBER
  26.   , p_color                  IN            VARCHAR2
  27.   , p_volume                 IN            NUMBER
  28.   , p_volume_uom             IN            VARCHAR2
  29.   , p_place_of_origin        IN            VARCHAR2
  30.   , p_best_by_date           IN            DATE
  31.   , p_length                 IN            NUMBER
  32.   , p_length_uom             IN            VARCHAR2
  33.   , p_recycled_content       IN            NUMBER
  34.   , p_thickness              IN            NUMBER
  35.   , p_thickness_uom          IN            VARCHAR2
  36.   , p_width                  IN            NUMBER
  37.   , p_width_uom              IN            VARCHAR2
  38.   , p_territory_code         IN            VARCHAR2
  39.   , p_supplier_lot_number    IN            VARCHAR2
  40.   , p_vendor_name            IN            VARCHAR2
  41.   , p_source                 IN            NUMBER
  42.   ) IS
  43.  
Mar 24 '08 #5
amitpatel66
2,367 Recognized Expert Top Contributor
I see when you are calling this procedure, ou are passing only 4-6 vales but this procedure has lots of input parameters, that is the reason the error is coming. You need to make the parameters optional in case of avoiding an error or pass all the parameter values when calling that procedure
Mar 24 '08 #6
vamsioracle
151 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. inv_lot_api_pub.update_inv_lot
  3. (
  4. v_inventory_item_id,
  5. v_organization_id,
  6. v_lot_number,
  7. null,--p_expiration_date
  8. null,--p_disable_flag
  9. null,--p_attribute_category
  10. null,--p_lot_attribute_category
  11. v_a ,--p_attributes_tbl
  12. v_b,--p_c_attributes_tbl
  13. v_c,--p_n_attributes_tbl
  14. v_d,--p_d_attributes_tbl
  15. null,--p_grade_code
  16. null,--p_origination_date
  17. null,--p_date_code
  18. null,--p_status_id
  19. null,--p_change_date
  20. null,--p_age
  21. null,--p_retest_date
  22. null,--p_maturity_date
  23. null,--p_item_size
  24. null,--p_color
  25. null,--p_volume
  26. null,--p_volume_uom
  27. null,--p_place_of_origin
  28. null,--p_best_by_date
  29. null,--p_length
  30. null,--p_length_uom
  31. null,--p_recycled_content
  32. null,--p_thickness
  33. null,--p_thickness_uom
  34. null,--p_width
  35. null,--p_width_uom
  36. null,--p_territory_code
  37. null,--p_supplier_lot_number
  38. null,--p_vendor_name
  39. null--p_source
  40. );
  41.  
  42.  


now i am passing all the parameters, still the error persists. is this the correct way to send table type parameter and moreover i didnt take any value into v_a,v_b......, its just declared as table type object.
Mar 24 '08 #7
amitpatel66
2,367 Recognized Expert Top Contributor
You need to pass a variables for the following OUT parameters as well:

Expand|Select|Wrap|Line Numbers
  1.  
  2. x_return_status          OUT NOCOPY    VARCHAR2
  3.   , x_msg_count              OUT NOCOPY    NUMBER
  4.   , x_msg_data               OUT NOCOPY    VARCHAR2
  5.  
  6.  
Mar 24 '08 #8
vamsioracle
151 New Member
i created a table type variable as
Expand|Select|Wrap|Line Numbers
  1.  
  2. create or replace package my_pack as 
  3.  
  4. type v_attributes_category is table of varchar2(1000)
  5. index by binary_integer;
  6.  
  7. v_a v_attributes_category;
  8.  
  9. cusor c_cur is
  10. select  name_varchar_variable from xx_table where condition;
  11.  
  12. for i in c_cur
  13. loop
  14. begin
  15.  
  16. v_a = i.name_varchar;
  17.  
  18.  
  19. package.procedure(
  20. .....
  21. ....
  22. v_a,
  23. .....
  24. )
  25.  
  26.  

in the above example, i have few doubts
1. is that the right way to assign values to v_a inside a loop of cursor
2. is that the right way to pass v_a, which is table type, to procedure
3. can we use v_a(i) := i. name_varchar to assign value


please help me out,

i used the above sample structure and i get

PLS-00382: expression is of wrong type and

PLS-00306: wrong number or types of arguments in call to procedure

thanks in advance
Mar 25 '08 #9
amitpatel66
2,367 Recognized Expert Top Contributor
i created a table type variable as
Expand|Select|Wrap|Line Numbers
  1.  
  2. create or replace package my_pack as 
  3.  
  4. type v_attributes_category is table of varchar2(1000)
  5. index by binary_integer;
  6.  
  7. v_a v_attributes_category;
  8.  
  9. cusor c_cur is
  10. select  name_varchar_variable from xx_table where condition;
  11.  
  12. for i in c_cur
  13. loop
  14. begin
  15.  
  16. v_a = i.name_varchar;
  17.  
  18.  
  19. package.procedure(
  20. .....
  21. ....
  22. v_a,
  23. .....
  24. )
  25.  
  26.  

in the above example, i have few doubts
1. is that the right way to assign values to v_a inside a loop of cursor
2. is that the right way to pass v_a, which is table type, to procedure
3. can we use v_a(i) := i. name_varchar to assign value


please help me out,

i used the above sample structure and i get

PLS-00382: expression is of wrong type and

PLS-00306: wrong number or types of arguments in call to procedure

thanks in advance
2 and 3 are correct. First is incorrect. You cannot assign a value to an array that way. Instead use your point 3 for assiging a value to an array of table.
Mar 25 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2722
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from the start that my knowledge of compiler implementation is very limited. Therefore, my suggestions may have to be rejected because they are difficult or impossible to implement. The proposal is based on the concept of "type similarity". Type...
7
5455
by: john | last post by:
Hi to All I would like to do something similar: class Class1<T1> { } class Class2<T2, T1where T2: Class1<T1>, new() {
1
3425
by: interX | last post by:
Hi I'm new in VC++ and have a question to generics. I have a generic class, which contains an array of the generic type. This array I can pin and then I would like to get an unmanaged pointer to it. Therefore I wanted to creat a class member which represents the pointer to the array. Unfortunately I get the folowring compile error for the code beneath: error C3229: 'DataType *' : indirections on a generic type parameter
2
3731
by: hisham123 | last post by:
hi, I Wrote one stored procedure in which i declare one variable as Table then i stored in that table type variable select * from emp so now my table contain one sql statement by 4 rows now i want to execute the sql statement how (MS SQL SERVER 2000)
4
7668
by: Andrus | last post by:
I tried to use type parameter to call static method but got compile error 'T' is a 'type parameter', which is not valid in the given context. Why this is not allowed ? Should I really use a lot longer ModelGenericBase<T>.test1() ? Andrus.
0
5875
debasisdas
by: debasisdas | last post by:
This thread contains some of the sample code showing the method of executing Oracle stored procedures and functions from VB . Hope the user finds them useful. Oracle Procedure with only IN type as parameter mode. ======================================== CREATE OR REPLACE PROCEDURE DEPTINS ( DNO DEPT.DEPTNO%TYPE, DN DEPT.DNAME%TYPE,
9
802
by: DottingTheNet | last post by:
help plz!! when i try to cretae a table in a procedure like create procedure blah is begin create table..... ...... end;
9
3146
by: tadmill | last post by:
Is it possible to pass a generic parameter of the same class to to its constructor, where the "T" type passed in the constructor is different than the "T" type of the instanced class? ie, public class SomeList<T> { public SomeList(SomeList<TthisSomeList)
2
14650
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how can I pass null value as parameter to the database stored procedure programattically using C#? Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.