在pl / sql块中进行一些操作后,我无法将值更新到表中,但是我不知道如何将这些值放回SQL表中。
我猜声明块不是必需的,但是我会抛出我使用的所有代码
t_procent:=t_ud_c/c_faktura;
我想在该FOR循环中逐行将较高的值放入“ procent_alokacji”交易表中,但是我不知道为什么我不能这样做。该怎么做?
Declare
type table_products is table of products.unit_duration_calculation%type;
t_products table_products:= table_products();
type table_clients is table of clients.faktura_suma_cj%type;
t_clients table_clients:= table_clients();
CURSOR c_clients is
Select id_c, faktura_suma_cj, howmuchagreements from clients;
c_id clients.id_c%type;
c_faktura clients.faktura_suma_cj%type;
c_howmuch clients.howmuchagreements%type;
CURSOR c_products is
select id_p, unit_duration_calculation from products;
p_id products.id_p%type;
p_durat products.unit_duration_calculation%type;
CURSOR c_transactions is
Select id_t, id_c, id_p, ud_c, procent_alokacji from transactions;
t_id_t transactions.id_t%type;
t_id_c transactions.id_c%type;
t_id_p transactions.id_p%type;
t_ud_c transactions.ud_c%type;
t_procent transactions.procent_alokacji%type;
counter_clients number:=1;
sum_products number:=1;
BEGIN
open c_clients;
open c_products;
open c_transactions;
fetch c_clients into c_id, c_faktura, c_howmuch;
fetch c_products into p_id, p_durat;
FOR i in 1 .. totalTransactions() loop
fetch c_transactions into t_id_t, t_id_c, t_id_p,t_ud_c, t_procent;
if counter_clients!=t_id_c Then
counter_clients:= counter_clients+1;
fetch c_clients into c_id, c_faktura, c_howmuch;
end if;
t_procent:=t_ud_c/c_faktura;
end loop;
END;
答案 0 :(得分:1)
如果我正确理解了您的问题,则想用计算值TRANSACTIONS
更新表t_procent
。我相信您想在计算t_procent
之后添加以下语句:
UPDATE TRANSACTIONS
SET PROCENT_ALOKACJI = t_procent
WHERE ID_T = t_id_t;
我不确定TRANSACTIONS
表的完整描述,但似乎TRANSACTIONS.ID_T
可能是TRANSACTION
表的主键。如果这不正确,请随时替换正确的列。
好运。