Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 6th, 2004, 03:31 PM
augustd augustd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 11 augustd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to INSERT LONG Datatype >4000 characters? (ORA-01461: can bind a LONG value on...

I'm trying to insert text into a LONG column using a trigger. Every time an update is made to one table, the trigger gathers data from it and its referenced tables and inserts it all into a separate table used for CTX searches:

CREATE TABLE search_text (
person_id INTEGER NOT NULL
, content LONG
);

The trigger:

CREATE OR REPLACE TRIGGER person_trg1
AFTER INSERT OR UPDATE ON person
FOR EACH ROW
DECLARE
CURSOR person_cursor IS
SELECT :new.prefix AS prefix, :new.first_name AS first_name, :new.middle_name AS middle_name,
:new.last_name AS last_name, :new.suffix AS suffix, :new.title AS title, :new.role AS role, :new.notes AS personNotes,
a.email AS email, a.phone AS phone, a.fax AS fax, a.url AS url, a.mobile AS mobile, a.address1 AS address1,
a.address2 AS address2, a.city AS city, a.state AS state, a.zip_code AS zip_code, a.country AS country,
c.company_name AS company_name, c.principal AS principal, c.description AS companyDescription,
c.notes AS companyNotes, g.display_name AS display_name, g.description AS groupDescription
FROM address a, company c, group_data g
WHERE :new.person_id = a.address_id
AND :new.company_id = c.company_id
AND :new.type_id = g.group_id;
person_val person_cursor%ROWTYPE;

CURSOR contact_cursor IS
SELECT cont.subject AS subject, cont.notes AS notes
FROM contact cont, contact_person_xref cpx
WHERE cpx.person_id = :new.person_id
AND cpx.contact_id = cont.contact_id;
contact_val contact_cursor%ROWTYPE;

all_contacts LONG;
all_text LONG;

BEGIN
FOR contact_val IN contact_cursor LOOP
all_contacts := all_contacts || ' ' || contact_val.subject || ' ' || contact_val.notes;
END LOOP;

OPEN person_cursor;
FETCH person_cursor INTO person_val;
all_text := person_val.prefix
|| ' ' || person_val.first_name
|| ' ' || person_val.middle_name
|| ' ' || person_val.last_name
|| ' ' || person_val.suffix
|| ' ' || person_val.title
|| ' ' || person_val.role
|| ' ' || person_val.personNotes
|| ' ' || person_val.email
|| ' ' || person_val.phone
|| ' ' || person_val.fax
|| ' ' || person_val.url
|| ' ' || person_val.mobile
|| ' ' || person_val.address1
|| ' ' || person_val.address2
|| ' ' || person_val.city
|| ' ' || person_val.state
|| ' ' || person_val.zip_code
|| ' ' || person_val.country
|| ' ' || person_val.company_name
|| ' ' || person_val.companyDescription
|| ' ' || person_val.companyNotes
|| ' ' || person_val.display_name
|| ' ' || person_val.groupDescription
|| ' ' || all_contacts ;
CLOSE person_cursor;

IF INSERTING THEN
INSERT INTO search_text
(address_id, content)
VALUES ( :new.person_id, :new.person_id || ' ' || all_text );

ELSE
UPDATE search_text
SET content = :new.person_id || ' ' || all_text
WHERE address_id = :new.person_id;

END IF;

END;
.
/

The trigger works fine until the collected data (all_text) grows greater than 4000 chars. Then I get this error:

ORA-01461: can bind a LONG value only for insert into a LONG column

If a LONG datatype can be up to 2GB, why am I getting this error at only 4001 chars?

Reply With Quote
  #2  
Old May 20th, 2004, 11:46 PM
rajasinghit rajasinghit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 rajasinghit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
You can not insert a value which is of length more than 4000 into a LONG column of a table. But, you can get fetch the LONG column from the table and store it into a variable of type LONG.
That is why you are getting the error. Please think BFILE oprion or something.
Thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > How to INSERT LONG Datatype >4000 characters? (ORA-01461: can bind a LONG value on...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway