Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table which has one column with string datatype name as ITEM_NO.

I have a function, in which i have passed the item number one by one and test that item number. After testing that item numbers i want to store it in an array (String datatype) which is dynamic in size.

My question is, how i will insert the column value into that array using pl/sql?

Example:
ITEM_NO = '980124', '970125', '781202', '874562', '9234567'.
Posted
Updated 12-Nov-15 0:05am
v2
Comments
George Jonsson 12-Nov-15 5:34am    
Please provide a bit more info, such as where you want to insert the data?
What is your table structure? (I hope you do not have only one column in your table where you will store the array.)
How does the user enter the values?
Bittu14 12-Nov-15 6:07am    
I have modified the question. Is this is ok for you?
George Jonsson 12-Nov-15 6:56am    
So you want to store all the values in the array in one column?
Bittu14 12-Nov-15 6:57am    
Yes.

1 solution

Storing an array of data in a single column is not the greatest idea there is.
See the First Normal Form (1NF)[^]
And then look into the Second Normal Form (2NF) and 3NF.

Rather you should create a second table where you store the item numbers together with a key from the first table.

Table1
ID   Column1   Column2
1    Hello     World
2    Eat       Spaghetti


Table2
ID    ITEM_NO   Table1_ID
1     980124    1
2     970125    1
3     781202    1
4     874562    1
5     9234567   1
6     1233456   2
7     2344556   2
8     5667789   2
9     980124    2    -- Same ITEM_NO as in row 1 


When you want to get all the item numbers for a certain ID in Table1 just do like this:
SQL
SELECT ITEM_NO FROM Table1 WHERE Table1_ID = 1;


It is also easy to add or remove a single item number.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900