BlueMichael
將理論付出于實踐,在實踐中成長!
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
::
2 隨筆 :: 0 文章 :: 0 評論 :: 0 Trackbacks
<
2008年9月
>
日
一
二
三
四
五
六
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年9月 (2)
搜索
最新評論
閱讀排行榜
1.?Oracle10g__安裝手記(頭一次)(212)
2.?用視圖能顯示單行超過255個字符的例子(211)
評論排行榜
1.?用視圖能顯示單行超過255個字符的例子(0)
2.?Oracle10g__安裝手記(頭一次)(0)
用視圖能顯示單行超過255個字符的例子
?
/**/
/*
????
說明:?????
?????在調試sql腳本時,如果要用Dbms_Output.Put_Line顯示腳本中的變量,如果變量中的內容單行長度????
?????超過了255個字符,會提示下面錯誤:????
?????ORA-20000:?ORU-10028:?line?length?overflow,?limit?of?255?chars?per?line????
?????所以我們可以用下面的已經創建好的包和視圖來實現。????
?????????
?????簡單點說就是也可以創建一個表,其中一個字段為long,將變量插入后再用select去查看。上面方式省略了創建表的過程。????
*/
????
--
?第一步????
create
?
or
?
replace
?package?my_output?????
as
?????
?????
procedure
?put(?s?
in
?
varchar2
?);?????
?????
procedure
?put_line(?s?
in
?
varchar2
?);?????
?????
procedure
?new_line;?????
??????
?????
function
?get_line(?n?
in
?
number
?)?
return
?
varchar2
;?????
?????pragma?restrict_references(?get_line,?wnds,?rnds?);?????
??????
?????
function
?get_line_count?
return
?
number
;?????
?????pragma?restrict_references(?get_line_count,?wnds,?rnds,?wnps?);?????
??????
?????pragma?restrict_references(?my_output,?wnds,?rnds,?wnps,?rnps?);?????
end
;?????
???
--
?第二步??????
create
?
or
?
replace
?package?body?my_output?????
as
?????
?????type?Array?
is
?
table
?
of
?
varchar2
(
4000
)?
index
?
by
?binary_integer;?????
?????g_data????????array;?????
?????g_cnt????????
number
?
default
?
1
;?????
??????
?????
procedure
?put(?s?
in
?
varchar2
?)?????
?????
is
?????
?????
begin
?????
?????????
if
?(?g_data.last?
is
?
not
?
null
?)?
then
?????
?????????????g_data(g_data.last)?:
=
?g_data(g_data.last)?
||
?s;?????
?????????
else
?????
?????????????g_data(
1
)?:
=
?s;?????
?????????
end
?
if
;?????
?????
end
;?????
??????
?????
procedure
?put_line(?s?
in
?
varchar2
?)?????
?????
is
?????
?????
begin
?????
?????????put(?s?);?????
?????????g_data(g_data.last
+
1
)?:
=
?
null
;?????
?????
end
;?????
??????
?????
procedure
?new_line?????
?????
is
?????
?????
begin
?????
?????????put(?
null
?);?????
?????????g_data(g_data.last
+
1
)?:
=
?
null
;?????
?????
end
;?????
??????
?????
function
?get_line(?n?
in
?
number
?)?
return
?
varchar2
?????
?????
is
?????
?????????l_str?
varchar2
(
4000
)?
default
?g_data(n);?????
?????
begin
?????
?????????g_data.
delete
(n);?????
?????????
return
?l_str;?????
?????
end
;?????
??????
?????
function
?get_line_count?
return
?
number
?????
?????
is
?????
?????
begin
?????
?????????
return
?g_data.
count
+
1
;?????
?????
end
;?????
??????
end
;?????
???
--
?第三步????
create
?
or
?
replace
?
view
?my_output_view?????
as
?????
select
?rownum?
lineno
,?my_output.get_line(?rownum?)?
text
?????
???
from
?all_objects?????
??
where
?rownum?
<
?(?
select
?my_output.get_line_count?
from
?dual?);?????
???
--
---------------------------------------------------------------????
--
?實現????
--
?1?寫入要查看的內容????
declare
?????
??QuerySql?
varchar2
(
4000
);????
begin
??????
??Dbms_Output.enable(
4000
);????
??QuerySql???:
=
'
?IIDD?AS?ID,?IsDel?AS?已刪除,?AnJianID?AS?案件編號,?BaoGaoRenXM?AS?報案人姓名,?JieBaoRenXM?AS?接報人姓名,?JieBaoShiJian?AS?接報時間,?BM_MingCheng?AS?辦案單位名稱??From?XZ_ShouLiDengJi?a?WHERE??(exists?(Select?
''
S
''
?from?GG_AnJianBanLi??where?AnJianID=a.AnJianID)?and?not?exists?(Select?
''
S
''
?From?GG_AnJian?Where?AnJianID=a.AnJianID?and?HuiBiRenYuan_BH?like?
''
%admin%
''
))?ORDER?BY?AddDateTime?DESC
'
;????
??Dbms_Output.Put_Line(
'
LENGTH?:?
'
?
||
?Length(QuerySql));????
??my_output.put_line(QuerySql);?????
end
;?????
--
?2?查看結果????
select
?
*
?
from
?my_output_view??
posted on 2008-09-11 09:53
dsy
閱讀(211)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © dsy
主站蜘蛛池模板:
乐都县
|
临洮县
|
柘荣县
|
峨眉山市
|
资阳市
|
云林县
|
泌阳县
|
会宁县
|
呼玛县
|
寿宁县
|
龙里县
|
贺兰县
|
西贡区
|
卢湾区
|
灯塔市
|
临漳县
|
澜沧
|
囊谦县
|
温泉县
|
襄垣县
|
昌都县
|
长顺县
|
社旗县
|
临汾市
|
云南省
|
诸暨市
|
阿勒泰市
|
仁布县
|
根河市
|
安龙县
|
望都县
|
宝丰县
|
拉孜县
|
遵化市
|
武宁县
|
扶沟县
|
旺苍县
|
左云县
|
南皮县
|
柳河县
|
汾阳市
|