- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to do LONG datatype query?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 06:19 PM
тАО01-21-2005 06:19 PM
How to do LONG datatype query?
If I want to do such query:
SQL> select count(*) from dba_views where text like '%GBM%';
select count(*) from dba_views where text like '%GBM%'
*
ERROR at line 1:
ORA-00932: inconsistent datatypes
SQL>
How could I achieve that?
'cause dba_views.text is LONG datatype,
cannot compare with characters.
Thanks for any tips.
Violin.
SQL> desc dba_views
Name Null? Type
------------------------------- -------- ----
OWNER NOT NULL VARCHAR2(30)
VIEW_NAME NOT NULL VARCHAR2(30)
TEXT_LENGTH NUMBER
TEXT LONG
TYPE_TEXT_LENGTH NUMBER
TYPE_TEXT VARCHAR2(4000)
OID_TEXT_LENGTH NUMBER
OID_TEXT VARCHAR2(4000)
VIEW_TYPE_OWNER VARCHAR2(30)
VIEW_TYPE VARCHAR2(30)
SQL>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2005 11:46 PM
тАО01-21-2005 11:46 PM
Re: How to do LONG datatype query?
try this:
================
YD@MYDB.MU> l
1 declare
2
3 mtext long;
4 mcount number := 0;
5
6 cursor c1 is select text from dba_views;
7
8 begin
9
10 for r1 in c1 loop
11
12 mtext := r1.text;
13
14 if mtext like '%GBM%' then
15 mcount := mcount + 1;
16 end if;
17
18 end loop;
19
20 dbms_output.put_line(mcount||' views exists');
21
22* end;
YD@MYDB.MU>
hope this helps!
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2005 12:59 PM
тАО01-23-2005 12:59 PM
Re: How to do LONG datatype query?
Thanks for your scripts,
but it running with errors:
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 12
SQL>
-- the followings are details:
SQL> declare
2 mtext long;
3 mcount number := 0;
4
5 cursor c1 is select text from dba_views;
6
7 begin
8
9 for r1 in c1 loop
10
11 mtext := r1.text;
12
13 if mtext like 'GBM%' then
14 mcount := mcount + 1;
15 end if;
16
17 end loop;
18
19 dbms_output.put_line(mcount||' views exists');
20
21 end;
22 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 9
SQL>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2005 03:45 PM
тАО01-23-2005 03:45 PM
Re: How to do LONG datatype query?
I have tested it on both Oracle 8i and Oracle 9i. works fine
which version of Oracle are you running?
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2005 03:46 PM
тАО01-23-2005 03:46 PM
Re: How to do LONG datatype query?
set serveroutput on size 1000000;
declare
mtext long;
mcount number := 0;
cursor c1 is select text from dba_views;
begin
for r1 in c1 loop
mtext := r1.text;
if mtext like '%GBM%' then
mcount := mcount + 1;
end if;
end loop;
dbms_output.put_line(mcount||' views exists');
end;
/
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2005 07:16 PM
тАО01-23-2005 07:16 PM
Re: How to do LONG datatype query?
try with "to_char(mcount)" in dbms_output statement.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 02:32 AM
тАО01-24-2005 02:32 AM
Re: How to do LONG datatype query?
But still fails.
It got errors when fetch.
Is there any solutions?
Thx.
Violin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 03:45 AM
тАО01-24-2005 03:45 AM
Re: How to do LONG datatype query?
check Metalink doc id 264961.995
"Search for a string in LONG datatype"
This is an example to search dblinks in views. I believe you can this script and adapt for your own purpose.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 04:30 AM
тАО01-24-2005 04:30 AM
Re: How to do LONG datatype query?
cf Metalink doc id 428044.999 convert long to varchar2- note:1022030.6
In previous post, the dbmssql package is used to copy a portion of the long into a varchar2 (with column_value_long)
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 02:58 PM
тАО01-24-2005 02:58 PM
Re: How to do LONG datatype query?
can you post the exact error message?
what version of sqlplus are you using?
revert
regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2005 11:46 PM
тАО01-24-2005 11:46 PM
Re: How to do LONG datatype query?
I'll reply the testing results asap.
Here is the db info:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
SQL>
SQL> set serveroutput on size 1000000;
SQL>
SQL> declare
2
3 mtext long;
4 mcount number := 0;
5
6 cursor c1 is select text from dba_views;
7
8 begin
9
10 for r1 in c1 loop
11
12 mtext := r1.text;
13
14 if mtext like '%GBM%' then
15 mcount := mcount + 1;
16 end if;
17
18 end loop;
19
20 dbms_output.put_line(mcount||' views exists');
21
22 end;
23 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 10
SQL>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 12:33 AM
тАО01-25-2005 12:33 AM
Re: How to do LONG datatype query?
the "like" operator works on CHAR or VARCHAR2 not on LONG.
see my previous posts for bypassing the issue. I believe the solution to your question is there.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 12:58 AM
тАО01-25-2005 12:58 AM
Re: How to do LONG datatype query?
Yogeeraj's solutions works, but only upto longs of 32K. Above that boundary things get more complex.
If this is a one time report, then how about this for a work around:
set long 2000000000
spool /tmp/myviews.txt
select owner, view_name, text
from dba_views;
spool off
and use view/more/whatever to find the GBM's.
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2005 01:04 AM
тАО01-25-2005 01:04 AM
Re: How to do LONG datatype query?
set linesize 4000
set longchunksize 4000
to avoid line wrapping in the middle of your search text.
regards,
Thierry.