October 8th, 2007, 04:35 AM
Using REPLACE in a UPDATE statement
Is there any way to do a REPLACE into a record, using an UPDATE statement?
In Sql Server I can do this:
UPDATE Tbl1 SET Rec1= REPLACE(Rec1, 'SomeValue', '')
How can I do this in Firebird?
October 8th, 2007, 05:19 AM
Add rFunc to your database and do an StrReplace, something like
Rec1= StrReplace(Rec1, 'SomeValue', '');
October 8th, 2007, 06:16 AM
Ok, I'll try it later.
October 8th, 2007, 06:20 AM
Check the link I provided please.
October 8th, 2007, 06:22 AM
yeah.. the server was down just for a few minutes
October 8th, 2007, 07:02 AM
Ok. I'm trying it, and it sounds great.
However, this requires to add some functions to the database(s) you want to use it. In my server I have about 500 db's, and executing the sql's for each db is too much dangerous.
Is there any other way to do the task, that not suppose a modify of the db's?
October 8th, 2007, 07:26 AM
AFAIK no , but as the sql is always the same I don't think that danger comes from the number of times it is executed
Originally Posted by Borjaserrano
October 9th, 2007, 11:46 AM
Well, I did a small tool in .NET to execute the sql scripts I need to add the rFunc features to our databases. This tool just takes the db name and local path of all db's from another db and then executes the script for each db.
However, I'm getting this exception every time I execute the sql script:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 7, char 1
Weird, because line 7 is refered to the second DECLARE statement of the script.
I'm executing the script by a objBD.ExecuteNonQuery() sentence of a FbCommand object.
Maybe I must to execute one DECLARE statement in one ExecuteNonQuery sentence?
October 10th, 2007, 05:01 AM
Thanks mate, finally I added all the functions of rFunc to all databases and now works perfect.
I had to use a FbScript object and a FbBatchExecution object instead FbCommand
Comments on this post