Solved

Copy a blob from one table to another inside a stored procedure

Posted on 2008-10-31
1
1,261 Views
Last Modified: 2013-12-09
I'm running Firebird 2.1.1 & my applicaton written in .net 2.0
I've become unstuck when trying to write a stored procedure to copy some blob data (a tiff image) from one table to another. For example:

Table 1 contains a field called ImageScan , Type blob , Size 80, Subtype Binary
and row 4  of this contains my image

Table 2 contains a field called FiledScan , Type blob , Size 80 Subtype Binary
and row 6 is where I want the image to be copied to

I dont want to copy the image to the client and have the client reinsert the blob into the new table due to network overhead.

The SP would start with something like this:
Create Procedure CopyBlob (OldImageNumber integer, NewImageNumber integer)
where oldimage is the row number of the existing image and NewImageNumber is the row number of the new image.

Thanks in advance Jon


0
Comment
Question by:JonR01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
dprochownik earned 250 total points
ID: 22852814
I'm not sure what do you mean by "row number". In databases rows are not identify by  row number but by some IDs. Here you have simple script creates procedure which do what you want, but after I changed "row number" to "row id"

SET TERM ^ ;

CREATE OR ALTER PROCEDURE CopyBlob (
    OldRowID integer,
    NewRowID integer)
as
begin
  Update Table2 b
  set b.fieldscan = (select first 1 a.imagescan from Table1 a where a.id=:OldRowID)
  where b.id = :NewRowID;
end^

SET TERM ; ^

GRANT ALL ON Table1 TO PROCEDURE CopyBlob;

GRANT ALL ON Table2 TO PROCEDURE CopyBlob;

GRANT EXECUTE ON PROCEDURE CopyBlob TO PUBLIC;

Of course I assumed that there is a row with specified ID in Table2, before you use procedure. If not you can use "Insert" or "Insert or update" syntax instead "Update".
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question