使用pl / sql在表中插入多行的问题 [英] problem with mutiple row insert in a table using pl/sql

查看:76
本文介绍了使用pl / sql在表中插入多行的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我试图使用PL / SQL在表中插入多行。我有两个程序和两个表。第一个过程从源表中获取数据,对其进行操作,然后将数据发送到第二个过程,该过程将数据插入到目标表中。我这样做,它只在目标表中插入一行。我无法理解问题所在。如果有人能帮助我会很棒。


以下是我使用的逻辑:


第一个程序

- 在光标中选择源表数据。

- 使用for循环我将值传递给目标表的rowtype变量。

- 现在我调用第二个过程从这里传递存储在

行类型中的值。


第二个程序

- 从第一个程序获取值并插入他们进了桌子。


到目前为止,我在源表中有4行,但我只能插入1行。


我猜测问题可能与调用程序有关,但我不确定。


当我尝试打印第一个程序中的值而不调用第二个程序时,它打印所有4行的值。


请帮助。


谢谢,

Nabh4u。



I am trying to insert multiple rows in a table using PL/SQL. I have two procedures and two tables. the first procedure gets the data from the source table, manipulates it and then sends the data to the second procedure which inserts the data into the target table. The way i do it, it inserts only one row into the target table. I am not able to understand what the problem is. It would be great if anyone could help me.

Following is the logic i am using:

First procedure
- select the source table data into a cursor.
- using for loop i pass the values into rowtype variable of target table.
- now i call the second procedure from here passing the values stored in the
rowtype.

Second procedure
- take the values from the first procedure and insert them into the table.

So far, i have 4 rows in the source table, but i am able to insert only 1 row.

I am guessing the problem might be with the calling of the procedure, but m not sure.

When i try to print the values from the first procedure without calling the second procedure, it prints the values for all the 4 rows.

Please help.

thanks,
Nabh4u.

推荐答案

你能不能租借过程1和程序2代码在这里供我们的专家参考?


为什么不在单个程序中执行你想做的任何事情?
Could you please post the procedure 1 and procedure 2 code here for reference of our experts?

Why dont you perform what ever you want to in a single procedure itself??


感谢Amit快速回复。我没有使用单个程序来执行所有操作,因为我将数据插入到不同的表中,如果我将所有内容都包含在一个过程中,那将是一个非常大的过程。我说的问题是最初的问题。


以下是我的尝试:


第一道程序:

Thanks Amit for a quick response. I am not using a single procedure to do everything because i will be inserting data into different tables and if i include everything into one procedure it will be a very huge one. The problem i have stated is the initial one.

Following is what i am trying:

First Procedure:

展开 | 选择 | Wrap | 行号


为什么不简单地调用procedure1中的第二个过程并传递值。
why not simply call the 2nd procedure within procedure1 and pass the values .


这篇关于使用pl / sql在表中插入多行的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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