Recent

Author Topic: Firebird move file for me  (Read 3532 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2259
    • Lazarus and Free Pascal italian community
Firebird move file for me
« on: May 17, 2016, 11:51:19 am »
Hello guys I have an application written in Lazarus that refers to a firebird db. And in a table called T_File I own a field called OLD_PATH that contains the file path at the present time and new_path that will contain the path where I want this file to be moved. Until everything is right. I was wondering there is a chance to tell firebird to really move the files from OLD_PATH new_path through a store procedures? If you like I do?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6886
Re: Firebird move file for me
« Reply #1 on: May 17, 2016, 11:57:02 am »
There is no "move database" command (that I'm aware of) in Firebird.

You'll need to move the databsse manually. There is however a method to do it in code and safely. You can backup the database to the same name but with extension .fbk (instead of .fdb for example). Then you can change the connection-string to include the new path and restore the backupped database.fbk to that location. At that point you have the database at the new location. There is however no possibility to delete the old database file.

All this is because you might not have physical access to the real database location. If you do have access you can delete the original database with a simple deletefile command. (you can also delete the .fbk backup-file when you're sure the new database is all correct)

For some code to backup and restore you can look at the wiki here:
http://wiki.freepascal.org/TFBAdmin
« Last Edit: May 17, 2016, 11:59:39 am by rvk »

xinyiman

  • Hero Member
  • *****
  • Posts: 2259
    • Lazarus and Free Pascal italian community
Re: Firebird move file for me
« Reply #2 on: May 17, 2016, 12:05:13 pm »
No, it is not move the database, it is to launch a shell command to move an image attached to my records
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6886
Re: Firebird move file for me
« Reply #3 on: May 17, 2016, 12:08:33 pm »
No, it is not move the database, it is to launch a shell command to move an image attached to my records
Well, that has nothing to do with Firebird itself. Firebird can't move arbitrary files for you or even run a shell you made. You'll need to do that yourself. (It would be a huge security risk if Firebird could do that)

If you have access to the locations of the files you can move them yourself with code, otherwise you'll need to establish a connection (via telnet or SSH) and execute your script.

xinyiman

  • Hero Member
  • *****
  • Posts: 2259
    • Lazarus and Free Pascal italian community
Re: Firebird move file for me
« Reply #4 on: May 17, 2016, 12:12:08 pm »
In fact, I was almost sure that it was so. But I hoped for a miracle. I know that I have to write a service that reads that data. Thanks anyway
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6886
Re: Firebird move file for me
« Reply #5 on: May 17, 2016, 12:13:39 pm »
In fact, I was almost sure that it was so. But I hoped for a miracle. I know that I have to write a service that reads that data. Thanks anyway
You could try programming this yourself via UDF but I wouldn't recommend it:
http://stackoverflow.com/questions/22945455/does-firebird-have-the-ability-to-run-system-level-commands

A server-side script would indeed be better in this case.

 

TinyPortal © 2005-2018