帮忙看段程序,有些疑问想请教Puber

[复制链接]
查看11 | 回复9 | 2021-1-23 14:14:07 | 显示全部楼层 |阅读模式
有以下疑问,PUber们帮忙看看。谢谢了。
1 同样的程序,在另外一个组织中,可以执行,在目前组织中不可以执行 (不同的组织,仅仅组织ID号不同而已)
2 这个程序中的cc1是什么东东,也没见有什么声明的;
3 bom_structure_tl_all_es_c和bom_structure_tl_all中居然没有数据,会不会是这个里面的问题导致程序无法运行的。
这个是一个BOM的东东。运行的时候提示错误。
ORA-01436: CONNECT BY loop in user data
ORA-06512: at line 153


程序如下:
Declare
v_assembly_item_id number;
v_max
number;
v_level
number;
v_sub
number;
v_num
number;
v_seg
varchar2(40);
v_pseg
varchar2(40);
v_cseg
varchar2(40);
Cursor c_bom_strct(v_ll number) is
select distinct ba.segment1,

ba.psegment1,

ba.csegment1,

ba.levela,

ba.extended_quantity
from bom_structure_tl_all_es_c ba
where ba.levela = v_ll;

Cursor bom_level is
select distinct t.levela from bom_structure_tl_all_es_c t;
Cursor cur_assembly is
select inventory_item_id, segment1
from mtl_system_items
where item_type = 'FG' and organization_id = 33
order by segment1;

begin

begin
delete from BOM_STRUCTURE_TL_ES_C;
commit;
end;

begin
insert into BOM_STRUCTURE_TL_ES_C
(assembly_item_id,
psegment1,
component_item_id,
component_quantity,
component_yield_factor,
csegment1,
item_type,
EFFECTIVE_DATE,
EXTENDED_QUANTITY)
select bbom.assembly_item_id,

pmsi.segment1 psegment1,

bic.component_item_id,

bic.component_quantity,

bic.component_yield_factor,

cmsi.segment1 csegment1,

cmsi.item_type,

trunc(bic.effectivity_date) effective_date,

BIC.COMPONENT_QUANTITY /

decode(BIC.COMPONENT_YIELD_FACTOR,

0,

1,

BIC.COMPONENT_YIELD_FACTOR) extended_quantity
from mtl_system_items pmsi,

mtl_system_items cmsi,

bom_bill_of_materialsbbom,

bom_inventory_components bic
where pmsi.organization_id = 33 and cmsi.organization_id = 33 and

bbom.organization_id = 33 and

pmsi.inventory_item_id = bbom.assembly_item_id and

bbom.bill_sequence_id = bic.bill_sequence_id and

cmsi.inventory_item_id = bic.component_item_id and

trunc(sysdate) >= bic.effectivity_date and

trunc(sysdate)v_level then
update bom_structure_tl_all_es_c t
set t.pextended_quantity = v_num
where t.segment1 = v_seg and t.psegment1 = v_cseg and

t.levela = v_sub;

end if;

end loop;
commit;
end loop;
commit;
end;
end;
/

回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
cc1是自动定义的游标,for cc1...
connect by循环就是递归有回头的,10g有nocycle
回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
本帖最后由 gyhgood 于 2012-2-3 11:29 编辑
bom_structure_tl_all_es_c和bom_structure_tl_all 应该是临时表
cc1是当前循环次数
ORA-01436: CONNECT BY loop in user data
ORA-06512: at line 153
自己DEBUG一下出错位置的循环中的变量

回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
gyhgood 发表于 2012-2-3 11:25
bom_structure_tl_all_es_c和bom_structure_tl_all 应该是临时表
cc1是当前循环次数

那这个循环次数,要不要设置变量。
我看这个并没有设置变量呀。
回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
notags 发表于 2012-2-3 11:24
cc1是自动定义的游标,for cc1...
connect by循环就是递归有回头的,10g有nocycle

兔子你好。
刚QQ你了。没反应。
我的版本很低。
这个自动定义的游标怎么讲。
我看还有这句。
start with a.assembly_item_id = cc2.inventory_item_id
可是去哪里查看这个自动定义的游标呢?
谢谢。

回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
应该是自动从游标获取的record,隐式的
回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
把select开始的找出来运行一下
回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
notags 发表于 2012-2-3 12:08
应该是自动从游标获取的record,隐式的

这个怎么讲?
这个隐式的要怎么查看。
谢谢。
回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
〇〇 发表于 2012-2-3 12:15
把select开始的找出来运行一下

谢谢你的答复。
我当时也想着把SQL分开运行。
刚把SQL分开运行后。发现有个小问题。
在TOAD中。TOAD进行自动格式化了。发现Select 后面的cc1.segment1被格式化成了cc1_0
Start with 后面的cc1.inventory_item_id 被格式化成了cc2.
想请教下这个CC1CC2 到底是什么?怎么样才能找到。



CC1.png (41.46 KB, 下载次数: 0)
下载附件
2012-2-3 13:53 上传

谢谢。

回复

使用道具 举报

千问 | 2021-1-23 14:14:07 | 显示全部楼层
ForrestAgain 发表于 2012-2-3 13:56
谢谢你的答复。
我当时也想着把SQL分开运行。

用sqlplus
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行