日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

oracle绑定变量过多,oracle - 在SQL Plus中使用绑定变量并返回多行? - 堆栈内存溢出...

發(fā)布時(shí)間:2023/12/4 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle绑定变量过多,oracle - 在SQL Plus中使用绑定变量并返回多行? - 堆栈内存溢出... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這是一個(gè)愚蠢的問題,但我似乎無(wú)法解決。 我有一個(gè)查詢?cè)贠CI程序中引起麻煩,因此我想在SQL * Plus中手動(dòng)運(yùn)行它以檢查是否有任何區(qū)別。 這是查詢:

select e.label as doc_name,

e.url,

i.item_id,

'multi' as form_type

from cr_items i, cr_extlinks e

where i.parent_id = :comment_id

and e.extlink_id = i.item_id

UNION

select null as doc_name,

utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url,

r.item_id,

'single' as form_type

from cr_revisions r

where r.revision_id = ( select content_item.get_latest_revision(:comment_id) from dual);

end;

我想將comment_id綁定到值3052753,所以我做了以下工作:

DECLARE

comment_id number := 3052753;

BEGIN

select e.label ,

e.url,

i.item_id,

'multi'

from cr_items i, cr_extlinks e

where i.parent_id = :comment_id

and e.extlink_id = i.item_id

UNION

select null ,

utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url,

r.item_id,

'single'

from cr_revisions r

where r.revision_id = ( select content_item.get_latest_revision(:comment_id) from dual);

END;

/

這給出了這個(gè)錯(cuò)誤:

ORA-06550: line 4, column 1:

PLS-00428: an INTO clause is expected in this SELECT statement

現(xiàn)在,我已經(jīng)很不高興了,因?yàn)槲也幌霃母旧细拇瞬樵?#xff0c;但是無(wú)論如何我都會(huì)努力并提出這個(gè)建議(INTO和UNION并不太順利):

DECLARE

comment_id number := 3052753;

x_label VARCHAR2(50);

x_url VARCHAR2(500);

x_item number;

x_thing VARCHAR2(50);

BEGIN

select label, url, item_id, thing into x_label, x_url, x_item, x_thing from (

select e.label ,

e.url,

i.item_id,

'multi' as thing

from cr_items i, cr_extlinks e

where i.parent_id = :comment_id

and e.extlink_id = i.item_id

UNION

select null ,

utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url,

r.item_id,

'single' as thing

from cr_revisions r

where r.revision_id = ( select content_item.get_latest_revision(:comment_id) from dual)) ;

END;

/

但是現(xiàn)在,當(dāng)然,因?yàn)槲乙祷氐男卸嘤?行,所以我完全可以預(yù)測(cè)

ORA-01422: exact fetch returns more than requested number of rows

現(xiàn)在,我可以繼續(xù)使用游標(biāo)等了,但是我的小查詢?cè)絹?lái)越偏離它的原始自我了。 我要做的就是檢查查詢是否以該comment_id值正常運(yùn)行。 當(dāng)然,我可以將comment_id硬編碼到查詢中,并且工作正常。 但是它在OCI中也可以正常工作,因此我將在SQL * PL中重現(xiàn)該問題以及在OCI代碼中看到的綁定變量。 但是,為什么要在SQL * Plus中做到這一點(diǎn)卻如此艱難呢? 我是否錯(cuò)過(guò)了一些顯而易見的事情?

數(shù)據(jù)庫(kù)是Oracle 10.2.0.1.0-64位在Red Hat Enterprise Linux ES版本4(Nahant Update 8)上運(yùn)行

總結(jié)

以上是生活随笔為你收集整理的oracle绑定变量过多,oracle - 在SQL Plus中使用绑定变量并返回多行? - 堆栈内存溢出...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。