2010-11-19 9 views
31

मैंने शुरुआत/अंत के साथ एक क्वेरी ब्लॉक बनाया है और इसे SQL * प्लस में चलाने के लिए चाहते हैं। लेकिन मैं इसे कमांड लाइन में कैसे चला सकता हूं?एसक्यूएल * प्लस में प्रारंभ/अंत के साथ ओरेकल क्वेरी कैसे चलाएं?

दरअसल कोड कुछ ब्लॉग से है और इसका उपयोग डेटाबेस में टेक्स्ट खोजने के लिए किया जाता है। एबीसी खोज की जाने वाली ग्रंथ है।

set serveroutput on size 1000000 
declare 
TYPE QueryCurType is REF CURSOR; 
query1 QueryCurType ; 

cursor c1 is select owner,table_name from dba_tables where owner not in ('SYS','SYSTEM') and table_name not like '%$%'; 
cursor c2(t1 varchar2) is select column_name from dba_tab_columns where table_name=t1 and DATA_TYPE in ('NVARCHAR2','VARCHAR2','CHAR'); 
temp_var varchar2(3000); 
query varchar2(3000); 

begin 
for tab1 in c1 loop 
    for col in c2(tab1.table_name) loop 
    query:='select '||col.column_name||' from '||tab1.owner||'.'||tab1.table_name||' where '||col.column_name||' like "ABC"'; 
    --dbms_output.put_line('executing..'||query); 
    open query1 for query; 
    loop 
     fetch query1 into temp_var; 
     if concat('a',temp_var) != 'a' then 
     dbms_output.put_line('Found String: "'||temp_var||'"# Column:'||col.column_name||'# Table:'||tab1.table_name); 
     end if; 
     exit when query1%NOTFOUND; 
    end loop; 
    end loop; 
end loop; 
end; 

लेकिन यह कभी नहीं चलाया जाता है। मैं कोड कैसे चला सकता हूं?

+1

गुमनाम पीएलएसक्यूएल ब्लॉक की पूरी सामग्री को देखने में मदद मिलेगी, और यदि आप कोई भी प्राप्त कर रहे हैं तो ओआरए कोड। –

+0

मैंने सवाल संपादित किया है। – newguy

उत्तर

60

आप आप शायद सिर्फ एक "/" एक लाइन पर अपने आप में अंत में की जरूरत है निष्पादित करने के लिए की तरह

begin 
    dbms_output.put_line('Hello World'); 
end; 
/
+0

यह वही है जो मैं चाहता हूं। धन्यवाद गैरी – newguy

+6

ओमग ... बेवकूफ ओरेकल! – qwertzguy

+0

प्रश्न कंसोल में कोई लाइन प्रदर्शित नहीं है। मैं सभी dbms_output.put_line मुद्रित करने के लिए sqlplus को कैसे बता सकता हूं? – Qianlong

13

एक स्लैश के साथ इसे का पालन करने की जरूरत है।

संबंधित मुद्दे