Unix Technical Forum

How to load a binary file into DB from a stored procedure?

This is a discussion on How to load a binary file into DB from a stored procedure? within the Sybase forums, part of the Database Server Software category; --> Let's see. Imagine I have a server with a table with two fields: id and data. I want to ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2008, 06:58 AM
Eneko Alonso
 
Posts: n/a
Default How to load a binary file into DB from a stored procedure?

Let's see. Imagine I have a server with a table with two fields: id
and data. I want to insert a new record on the table. Id will be given
(a numeric unique id) and data must be the content on a file
accessible by Sybase (on a folder in the server hard drive or maybe on
a shared location in network). The path to the file will be given,
relative to Sybase server. The file can be any kind of document
(images, PDFs, docs, compressed files, etc)

Now, from a client connected to the DB I want to execute a command to
load the file into DB. This is, I want to use only SQL since the
client can not access the file directly.

Is there a way to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-24-2008, 06:58 AM
David Kerber
 
Posts: n/a
Default Re: How to load a binary file into DB from a stored procedure?

In article <3c72457b-ab37-48bf-955c-
f215c74b685f@f24g2000prh.googlegroups.com>, eneko.alonso@gmail.com
says...
> Let's see. Imagine I have a server with a table with two fields: id
> and data. I want to insert a new record on the table. Id will be given
> (a numeric unique id) and data must be the content on a file
> accessible by Sybase (on a folder in the server hard drive or maybe on
> a shared location in network). The path to the file will be given,
> relative to Sybase server. The file can be any kind of document
> (images, PDFs, docs, compressed files, etc)
>
> Now, from a client connected to the DB I want to execute a command to
> load the file into DB. This is, I want to use only SQL since the
> client can not access the file directly.
>
> Is there a way to do this?


Which Sybase database? In ASA (aka SQLAnywhere), you can use the
xp_read_file() system procedure.

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-24-2008, 06:58 AM
Eneko Alonso
 
Posts: n/a
Default Re: How to load a binary file into DB from a stored procedure?

>
> Which Sybase database? *In ASA (aka SQLAnywhere), you can use the
> xp_read_file() system procedure.
>
> --
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).


I'm using Sybase SQL Anywhere 10.0.1 and I just looked for this method
and it is available!
There is a problem, though. It requires DBA permissions and I would
like, if possible, a solution for non-DBA users. But so far this looks
pretty good. Thanks a lot!!!

Eneko.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-24-2008, 06:58 AM
David Kerber
 
Posts: n/a
Default Re: How to load a binary file into DB from a stored procedure?

In article <129081a3-1fe4-4664-bc9c-
f50af8837e7d@g16g2000pri.googlegroups.com>, eneko.alonso@gmail.com
says...
> >
> > Which Sybase database? *In ASA (aka SQLAnywhere), you can use the
> > xp_read_file() system procedure.
> >
> > --
> > Remove the ns_ from if replying by e-mail (but keep posts in the
> > newsgroups if possible).

>
> I'm using Sybase SQL Anywhere 10.0.1 and I just looked for this method
> and it is available!
> There is a problem, though. It requires DBA permissions and I would
> like, if possible, a solution for non-DBA users. But so far this looks
> pretty good. Thanks a lot!!!


IIRC, stored procedures execute with the permissions of the owner (which
can be DBA), not the user.


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com