如何在pl / sql中的动态数组中插入用户输入 [英] How to insert user input in a dynamic array in pl/sql

查看:98
本文介绍了如何在pl / sql中的动态数组中插入用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中一列的字符串数据类型名称为ITEM_NO。



我有一个函数,我已经逐个传递了项目编号并测试该项目编号。在测试了项目编号之后我想将它存储在一个动态大小的数组(String数据类型)中。



我的问题是,我将如何插入列值使用pl / sql进入该数组?



示例:

ITEM_NO ='980124','970125','781202','874562 ','9234567'。

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'.

推荐答案

在一列中存储数据数据并不是最好的主意。

请参阅第一范式(1NF) [ ^ ]

然后查看第二范式(2NF)和3NF。 />


相反,您应该创建第二个表格,将项目编号与第一个表格中的密钥一起存储。



表1

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





表2



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 





当你想要获得Table1中某个ID的所有项目编号都是这样的:



When you want to get all the item numbers for a certain ID in Table1 just do like this:

SELECT ITEM_NO FROM Table1 WHERE Table1_ID = 1;





添加或删除单个项目编号也很容易。



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


这篇关于如何在pl / sql中的动态数组中插入用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆