TheInsider
Programmer
Hi,
I'm writing a small application in Java that accesses a SQL Server 2000 database via JDBC. One of my tables stores binary data (files) in a column of type IMAGE. These files may be anywhere from 30kB to 2MB in size. (Please don't reply telling me about the inefficiency of doing this. I've taken the courses, and I'm aware of the pitfalls.) Anyway, what I'm trying to do is something like the following:
Unfortunately, the latter doesn't work because you can't assign IMAGE data to a variable. I've read up on TEXTPTR() and READTEXT, but really don't understand where the information from READTEXT actually goes.
I also can't do something like because it's also illegal:
I know I could use a straight SELECT statement and a Recordset / ResultSet, but I need the stored procedure to validate user credentials and do some other processing before I return the file data.
I've scoured the web looking for examples, but the only ones I've found are for inserting binary data, which is trivial, and I don't need a tutorial for that. And, because of Microsoft's unfortunate choice in naming the data type "IMAGE", most Google results return tutorials about pictures.![[thumbsdown] [thumbsdown] [thumbsdown]](/data/assets/smilies/thumbsdown.gif)
Is there any way of outputting the IMAGE data, other than by doing the following and using a Recordset / ResultSet to capture the data?
TIA
I'm writing a small application in Java that accesses a SQL Server 2000 database via JDBC. One of my tables stores binary data (files) in a column of type IMAGE. These files may be anywhere from 30kB to 2MB in size. (Please don't reply telling me about the inefficiency of doing this. I've taken the courses, and I'm aware of the pitfalls.) Anyway, what I'm trying to do is something like the following:
Code:
CREATE PROCEDURE test
@my_id INT,
@fileData IMAGE OUTPUT
AS
SELECT @fileData = fileData
FROM my_table
WHERE my_id = @my_id
GO
I also can't do something like because it's also illegal:
Code:
DECLARE @size
SET @size = 123456
SET TEXTSIZE @size
I've scoured the web looking for examples, but the only ones I've found are for inserting binary data, which is trivial, and I don't need a tutorial for that. And, because of Microsoft's unfortunate choice in naming the data type "IMAGE", most Google results return tutorials about pictures.
![[thumbsdown] [thumbsdown] [thumbsdown]](/data/assets/smilies/thumbsdown.gif)
Is there any way of outputting the IMAGE data, other than by doing the following and using a Recordset / ResultSet to capture the data?
Code:
CREATE PROCEDURE test
@my_id INT
AS
SELECT fileData
FROM my_table
WHERE my_id = @my_id
GO
TIA