firebird

Using rdb$get_context as default value for a column

In a Firebird database, I need to create a DOMAIN with default value taken from the context variable. It should be something like CREATE DOMAIN USER_ID AS INTEGER DEFAULT RDB$GET_CONTEXT('USER_SESSION','UID') NOT NULL; When I execute this, I am getting the following error Invalid token. Dynamic SQL Error. SQL error code = ...

SQL: Get a random entry iff condition is false.

Using Firebird: I want to select a random entry in the table if the first SQL query returns 0 rows. Is there anyway to combine these two queries? SELECT * FROM table WHERE cond=1; SELECT FIRST 1 * FROM table ORDER BY rand(); Im using ExecuteNativeQuery on the java-side which takes basic SQL statements. Sadly, If-Else statements don'...

How can I measure the amount of space taken by blobs on a Firebird 2.1 database?

I have a production database, using Firebird 2.1, where I need to find out how much space is used by each table, including the blobs. The blob-part is the tricky one, because it is not covered using the standard statistical report. I do not have easy access to the server's desktop, so installing UDFs etc. is not a good solution. How ca...

procedure give me garbage data in some fields

I have that code: string pathToSave = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string file = pathToSave + "\\" + "produkty_" + lang + ".csv"; FileStream fs = new FileStream(file, FileMode.Create); StreamWriter sw = new StreamWriter(fs); // sw.WriteLine("id;Akt....

stored procedure which solve me names of column of table

Hey, I need a stored procedure which in parameter have name of table(varchar) and it return names of columns in this specific table. It is possible ? I think about some SELECT which retrieve this names from table but I am weak at SQL :/ I add that I use Firebird 1.5 :/ ...

Insert null into not null column with default FIREBIRD

Inserting null into not null column with default is giving me a validation error instead of taking the default value. I don't want to make on before triggers to all of the tables. Is there any other way to do this? Firebird 2.1.3 ...

Trouble translating a SQL Server query to Firebird

I'm new to Firebird, and I'm having particular difficulty translating this T-SQL to Firebird SQL. This code is stored outside of the database, not in a stored procedure. DECLARE @NumTotal int DECLARE @NumUsed int SELECT @NumTotal = COUNT(*) FROM "some_Table" WHERE "CreatedOn"=@CreatedOn SELECT @NumUsed = COUNT(*) FROM "som...

Why cant I execute this alter procedure firebird query?

the query is: SET TERM ^ ; ALTER PROCEDURE SALVARROTA ( datahora timestamp, distancia double precision, custo double precision, capacidadelivre double precision, capacidadetotal double precision, nome varchar(50), depositox double precision, depositoy double precision, chegadax double precision, ...

Locating all reachable nodes using SQL

Suppose a table with two columns: From and To. Example: From To 1 2 2 3 2 4 4 5 I would like to know the most effective way to locate all nodes that are reachable from a node using a SQL Query. Example: given 1 it would return 2,3,4 and 5. It is possible to use several queries united by UNION clauses but it would limit the...

Compact Firebird 2.1 Database

How can I compact Firebird 2.1 database, like we do in MS Access (discarding erased data, remaking index, etc)? There's a way to do it? Thanks! ...

Firebird cli import/export tool

looking for a kickass import/export cli tool for firebird db that is comparable to mysql cli tools. is fsql the best thing out there? needs to run on win,mac and linux ...

Know of any Firebird profilers and/or stress tester app's ?

The title pretty much says it all. Im looking for som testing programs for a firebird db server, to stress-test and find bottlenecks. Something like DB-Optimizer, only for firebird would be nice. Can also be separate programs, one for stress-testing and one for profiling. ...

In Firebird would be a way to auto-update coincident rows in a INSERT procedure?

if you are running a query that inserts a new set of records in a table from other one, there is a way to force the update of the coincident pk record in the destination table, without deleting records or split the process in two others (insert new and update existing)? ...

ibase_execute just hangs when there is a deadlock

Setup: firebirdsql 2.1.3 win32, php 5.3 (installed with xampp) When I try to update a record that's edited in a desktop app or IBexpert, and there is a deadlock, ibase_execute just hangs, does not return any value nor raises an exception. When there's no deadlock, everything works fine. Any ideas how to catch this? ...

What does values of MON$STATEMENTS.MON$STATE stand for?

Querying against FB 2.5 RC3 server I can see values 0, 1, 2 in the mentioned field. But release notes describe only 0 and 1. What does 2 mean? ...

Firebird configuration - turn case-sensitivity off

I'm looking to perform case-insensitive search in a Firebird database, without modifying actual queries. In other words, I'd like all my existing "SELECT/WHERE/LIKE" statements to retrieve BOB, Bob, and bob. Does Firebird configuration allow to modify this behavior? ...

Howto update duplicates in firebird?

Hi everyone. Searched google for "firebird update duplicates" and "firebird handle duplicate update" but did not get any stuff, that would solve my question; so i thought it would be a good idea to use this marvellous site for the first time :) So how do i achieve mysql's "INSERT INTO asdf (x,y,z) VALUES ('a',1,2) ON DUPLICATE KEYS UPDA...

How to drop a unique constraint in Firebird

I have this table CREATE TABLE "VACCINE" ( "CVX" INTEGER, "CPT" CHAR(5), "SHORTNAME" VARCHAR(20), "FULLNAME" VARCHAR(256), "VTYPE" CHAR(1), UNIQUE ("CVX") ); but it turns out that CVX is not unique after all. How do I drop the unique constraint? I can get the name of the constraint like this select rdb$constraint_n...

Delphi Interbase Sql Conversion to Sql Server and Oracle

hello, i have a delphi application which uses database interbase / firebird. To consult and write data I use the InterBase components palette (IBTable, IBQuery, IBDataset). I'm performing the conversion of my system to sqlserver / Oracle but i have thousands of queries that are assembled at runtime with SQL Instructions Specific of datab...

Is there a way to have metadata name longer than 31 Characters ?

Hi ! Is there an easy way to have metadata names longer than 31 Characters in Firebird 2.1 and above ? This limitation is annoying with Foreign Keys and Views Name. Thanks! ...