【发布时间】:2014-12-16 07:34:52
【问题描述】:
我会尽量说清楚。
我有这 3 张桌子 Customer、Link 和 Customer_link。
我正在使用以下查询从Customer 中检索customer_no 列,该列的值在表Customer_link 的customer_no 中不可用:
SELECT c.customer_no
FROM CUSTOMER c
LEFT JOIN Customer_link cl
ON c.customer_no = cl.customer_no
WHERE cl.customer_no IS NULL
表Customer_link 具有以下列:
ID (generated automatically using a sequence)
Customer_no (linked to Customer table)
Link_no (linked to the Link table)
Maker_id
我要做的是,使用上述查询从Customer 表中获取尚未添加到表Customer_link 中的customer_no(这是一个约束,因为Customer_link 不能有相同的customer_no 两次在表中是唯一的。link_no 也是如此)和类似的查询从Link 表中获取link_no。
然后从各自的结果中使用link_no 和customer_no 然后添加到表Customer_link (已经有一个函数,我需要用我在结果中得到的值调用它)。
我需要在这里使用一个循环,以便在将每个表中的值添加到表 Customer_link 后更新结果,这样我在尝试添加相同的 customer_no 或 @ 时不会出错987654344@两次上桌。
使用光标是我在互联网上找到的一种方法。但这对我来说不是很清楚。
所以我在这里要做的就是从Customer 和Link_no 从Link 获取未使用的customer_no 的结果,并在row1 中插入值是表Customer_link 中的相应列并循环到更新结果并再次获取 row1 中的值,以将它们作为参数添加到我调用的函数中
【问题讨论】:
-
表也都已经创建好了。该函数(我需要调用的函数)的作用是,它获取我提供给它的值,从表(客户和链接)中验证,然后将其与其他必需值一起添加到表 Customer_link 中
标签: sql oracle plsql plsqldeveloper