| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Concatenating BLOB data in PL/SQL, returning it to Pro*C
I may be going about this in entirely the wrong way, but ...
I have a database containing blob data. I wish to write a PL/SQL stored function which can be called from Pro*C.
I would like this stored procedure to collect the data from blobs stored in several rows and return it in some parseable form to my C program.
Several hours with enormous manuals later, and I'm thinking this is not an easy problem. Some sample code follows; in particular, what I want is for something like the CONCAT to work, looping over each row collecting blob data into some form which is returned to the caller.
Any thoughts?
Thanks,
--chuck
CREATE OR REPLACE FUNCTION goober
RETURN RAW IS
blob_locator BLOB;
offset NUMBER := 1;
buffer RAW(1000);
rval RAW(10000);
length NUMBER := 0;
b_ptr NUMBER := 0;
continue NUMBER := 0;
CURSOR csr_get_id IS SELECT widgit from widgits;
CURSOR csr_get_locator(in_id NUMBER) IS SELECT widgit_data from
our.wigits where widgit_id = in_id;
BEGIN
OPEN csr_get_id;
LOOP
FETCH csr_get_id INTO id;
EXIT WHEN csr_get_id%NOTFOUND;
OPEN csr_get_locator(id);
FETCH csr_get_locator INTO blob_locator;
IF csr_get_locator%FOUND THEN
length := DBMS_LOB.GETLENGTH(blob_locator);
IF length > 0 THEN
DBMS_LOB.READ(blob_locator, length, offset, buffer);
-- ***
-- It would be sooooo cool if this next line worked.
-- ***
rval := CONCAT (rval, buffer);
END IF;
CLOSE csr_get_locator;
ELSE
CLOSE csr_get_locator;
END IF;
END LOOP;
CLOSE csr_get_id;
RETURN rval;
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Thu Jan 21 1999 - 13:28:19 CST
![]() |
![]() |