RE: [firebird-support] Gbaked and restored database larger than the original?

2015-07-08 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Take a look here: http://www.firebirdfaq.org/faq361/ I'd add that restore also has a -use_all_space option. If you don't specify this, then pages are filled to approximately 80% (80% is preferable over 100% unless it is a read-only database). See

SV: [firebird-support] general question: calculated fileds vs performance

2015-07-07 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello! Generally speaking, regarding performance, is expensive having calculated fields? Not complex ones, I mean this type of thing: ... COMPUTED BY (cast(qty * price * tax / 100 as money 2)) So far I don't notice any difference but I'd like to hear opinions about whether is a good idea

RE: [firebird-support] Get ID of record with minsort

2015-06-25 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I have a table with one ID-Column and one Sort-Column. I need the ID from the record with the lowest sort-number. Sortnumbers are not unique (can be doubled). Can I do this with one SQL-Statement? If you want one row returned: Select ID_column From Table Order by Sort_Column Rows 1 If you

Re: [firebird-support] Soc Sec No comparison using Firebird

2015-06-24 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Greetings All, I would like to pass into a stored procedure two social security numbers for comparison and have the result tell me if one character has changed, or if two characters were switched or if it does not compare at all. Has anyone done anything like this they could share? Or is it

Re: [firebird-support] Firebird migration to increase perfomances

2015-06-23 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Yes I just checked my original query will return 6 rows without the distinct OK, then lets add another CTE so that the calculations aren't multiplied: with tmp1(surname, name, trxdate, source, job_number, creditnr, sourceid, serviceadvisOR) as (select distinct trim(c.name||' '||c.surname),

RE: [firebird-support] Firebird migration to increase perfomances

2015-06-23 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi Set Wow your query runs like a bat out of hell J 0.16 Milliseconds !! and it easier to maintain as you say. The only issue is that it somehow multiplies the totals by 6 on all results as compared mine? i.e. mine will return an invoice total of say 18500.00 and yours will return 111000.00

RE: [firebird-support] Firebird migration to increase perfomances

2015-06-22 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
At first glance, your plan seems OK. However, it would be better if we also could see the index definitions as well as get some information about index selectivity. And, this list removes attachments, so please post the text of the query as part of the message. Set Stef van der Merwe wrote: I

RE: [firebird-support] Firebird migration to increase perfomances

2015-06-22 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi all, some years ago I developed a web application based on Interbase, Win98, PHP, Apache. During those yeas has been lightly updated with lase release of software, now the we application (10 users) use the follow: Microsoft Server 2012 (64bit) Apache 2.0 PHP 5.4 Firebird SQL 1.5 (3

Re: [firebird-support] Firebird migration to increase perfomances

2015-06-22 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
There can be lots of reasons for a database application being slow. If the database have huge tables, and the application is written thinking in terms of tables as opposed to datasets, then things will be slow Svein. An interesting comment, to me anyway, regarding tables vs datasets.

RE: [firebird-support] Firebird 2.52 gbak fails to do a restore - error trigger (3)

2015-06-12 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Unlike Vlad, Helen and Thomas, I know next to nothing about problems like yours (I'm good at SELECTs, which is way different from corrupted backups). Hence, listen more to them than to me. gbak:restoring privilege for user SYSDBA gbak: ERROR:action cancelled by trigger (3) to preserve data

[firebird-support] GROUP BY optional with constants?

2015-06-10 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I did a mistake with a query I wrote (Fb 2.5.3 or 2.5.4), but to my surprise Firebird did not complain and gave me the desired result. What I found was that whilst Firebird complains about missing GROUP BY if writing something like SELECT 'This does not work', RDB$RELATION_ID,

RE: [firebird-support] Re: Inssuficient rights for operation....

2015-06-09 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello. I used Firebird 1.5.6 on server on WIN7, a database with a role with full rights, and a user defined in ROLE, USER. I have a problem. In the network with a application, on different client station, login with the USER, all functions work OK. From server or another WIN7 station, with USER

RE: [firebird-support] How to CAST float to integer with error?

2015-05-26 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello, is it possible by using CAST or in any other way to get database error when casting such number to integer? SELECT CAST('13.245' AS INTEGER) FROM RDB$DATABASE This gives 13 but instead I would like to get an error because precision is lost. However, I would like to NOT get an error when

RE: [firebird-support] Parametrized queries and execute statement - dynamic parameter list

2015-05-26 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
3. when i change proc to use execute statement with parameters   SET TERM ^ ; CREATE PROCEDURE MY_PROC_CALC_EXEC_PARAM(ID INTEGER) RETURNS(SUM_AAA INTEGER) AS DECLARE VARIABLE VAR_SQL VARCHAR(1000); BEGIN VAR_SQL = 'SELECT SUM(AAA) FROM TABLEY WHERE ID=:ID';   EXECUTE STATEMENT (VAR_SQL) (ID :=

Re: [firebird-support] Why index is not used in this query?

2015-05-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
SELECT * FROM TABLE_2 T2 INNER JOIN TABLE_1 T1 ON T2.TABLE_1_ID = T1.ID After executing this query I am getting such plan: PLAN JOIN (T1 NATURAL, T2 INDEX (FK_TABLE_2)) Why in case of TABLE_1 optimizer did not chose index PK_TABLE_1? And why I am getting error when i try to enforce it

Re: [firebird-support] Re: Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause)

2015-05-07 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Except that grouping by OPS_ZIP would not accomplish the same thing. Multiple zip codes map to the same REGION_ID and the zip codes might not be contiguous. Guess I'm going to have to rethink this. What about with tmp(PB_LOAD_TYPE, APPT_DATE, REGION_ID, PICKUP, DELIVERY) as (SELECT

Re: [firebird-support] Is it possible to do this with window function?

2015-05-02 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi guys. Hi Bruce! I am having such data: ID DATE_TIMETYPE 101.01.2015, 00:00:00.000A 201.01.2015, 00:01:00.000A 301.01.2015, 00:02:00.000A 401.01.2015, 00:10:00.000B 501.01.2015, 00:15:00.000B 601.01.2015, 00:20:00.000A 7

SV: [firebird-support] SQL Case query takes 4 minutes 30 seconds to execute !!

2015-04-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
[I've removed irrelevant details from your original question] I sincerely hope I am in the right place. We have a query which takes 4 minutes 30 seconds to execute this is simply too long. Please help ! Definitely, Stef, most performance problems can be solved on this list, and I agree

RE: [firebird-support] SQLAnywhere to Firebird possibility

2015-04-24 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, I have been a major contributor to Firebird since 2003, also my previous company BASX, which I was the Head developer of, was a gold sponsor of Firebird. I have recently moved to another company that uses SQLAnywhere. They are interested in moving to Firebird. But Firebird does not have

RE: [firebird-support] Need Speed Optimization for SQL

2015-04-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I have below SQL and DDL of respective columns used in this SQL. Below sql takes 6-7 seconds to give the result. Would it be possible to bring the output time to 1 seconds, coz there are some other operartion I need to perform based on this sql output withing short period of t ime. SQL:

RE: [firebird-support] Need Speed Optimization for SQL

2015-04-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi SET, Nice to see you here, but I am getting below error after executing your sql, i think group by clause is needed, would you please help? Yes, sorry I forgot group by: with TMP(PK_JOB_ITEMS) as (select distinct PK_JOB_ITEMS from CRM_JOB_ITEMS where FK_JOB =

RE: [firebird-support] Need Speed Optimization for SQL

2015-04-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi SET, I tried as below way by adding Group By clause: with TMP(PK_JOB_ITEMS) as (select distinct PK_JOB_ITEMS from CRM_JOB_ITEMS where FK_JOB = '{8BDDED49-8509-48C1-A169-B7E68A74C230}') select Sum(cdi.QUANTITY) AS Delivered, cdi.FK_JOB_ITEM from tmp t join CRM_DOCUMENT_ITEMS cdi on

[firebird-support] Re: Need Speed Optimization for SQL

2015-04-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
CRM_DOCUMENT_HEADER Table - PK_DOCUMENT_HEADER is primary key and having seperate index on this column as well What do you mean by this, Vishal? I think it was fixed a while ago, but duplicate indexes used to confuse the optimizer, so PK_DOCUMENT_HEADER ought not to be both the primary key and

Re: [firebird-support] SQL puzzle: Order based on Prerequisite

2015-04-12 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
In a table called Steps, I have the following fields: ID, B4Me, Dsc, -ID field contains a unique ID for each record -B4Me contains the ID of some other record in the table that MUST appear in a result set, BEFORE this record. B4Me may be null. This is called the B4Me order. -Records will be

RE: [firebird-support] Recursive CTE question

2015-04-08 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Can the question be rephrased as you being interested in which sets are identical, Elias? If I understand things correctly, I would assume double negation to be the simple answer you're looking for: with tmp(id) as (select distinct id from CRITICALPARAMVALS) select t.id, t2.id from tmp t join

RE: [firebird-support] V1.56 query killing my V2.54 app

2015-04-08 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Ok, used the +0 and worked. On v1.56 I was used with setting up a high granularity data column (col04Int - part of the primary key) with a True/false (0/1) type of column (ColDetSmIntFlag) to boost the selectivity of the index IXColDetSmIntFlag. I kept the index with that configuration for a

Re: [firebird-support] V1.56 query killing my V2.54 app

2015-04-07 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi all, I'm trying to upgrade an app to v2.54 from v1.56 but there are some queries that aren't planning the way they should. I have this query: Select Distinct a.col01Int, a.col02SmInt, a.col03SmInt, a.col04VarCh45 from dettbl b Inner Join msttbl a on (a.col01Int = i.col01Int and

Re: [firebird-support] Recursive CTE question

2015-04-07 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi everyone! This might not be a straightforward Firebird question, but I'm hoping there's a feature I'm unaware of that can help me beyond plain-vanilla SQL. I have two tables. The first is a list of names of critical parameters, and the second relates certain object IDs, critical parameter

Re: [firebird-support] V1.56 query killing my V2.54 app

2015-04-07 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Actually, the problem isn't with FK_dettbl, but with the A Natural. In a Master detail relationship with 450K+ rows in the master and 800K+ rows in the detail, that natural is a killer. The problem is that Firebird thinks that PLAN SORT (SORT (JOIN (A NATURAL, B INDEX (FK_dettbl is a

RE: [firebird-support] Cast as Numeric without parenthesis

2015-03-26 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I would expect numbers in the range -2147483648 to +2147483647 to be accepted (the size of an integer), and then there’s a separate field for storing whether things are shifted to the left or right. I’ve no experience or theoretical knowledge confirming this, but your examples would fit such a

RE: [firebird-support] Cast as Numeric without parenthesis

2015-03-26 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
then why here is an error?   SELECT CAST('123456789.23' as numeric) FROM RDB$DATABASE Logically speaking I don't understand why SELECT CAST('123456789.23' as numeric(9,0)) FROM RDB$DATABASE is failing when SELECT CAST('1.23' as numeric(1,0)) FROM RDB$DATABASE succeeds. Practically, I guess

RE: [firebird-support] Extract week of the year (within year)

2015-03-24 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
is possible to get week of the year within year? I see that built in functions only support ISO-8601 (or i do not know some parameter) Actually, Karol, “week within year” is not the week, Karol. 1 January could be week 53 and 31 December could be week 1. If you want to consider 1 January

RE: [firebird-support] How To Generate Auto Increment Number in SQL Itself ?

2015-03-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
HI Louis, It's pretty cool, but i need only in SQL, that too same number for all records for same employee and next incremental number for all records of the another employee. SET any help offered ? The first thing that comes to mind, is EXECUTE BLOCK (which is basically a STORED PROCEDURE

RE: [firebird-support] Hang On ExecuteNonQuery Using Firebird2.5 with visual studio 2010

2015-02-24 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
For iLoop as Integer=0 to grid.Rows.Count-1'Grid Has 100,000 Rows '-Sometimes Hang Here Also- rdr = Get_Reader(USP_CHECK_AND_GET_ITEM_EXIST(' Mid(Trim(dicFields_Name.Item(SP_ITEM_CODES)), 1, 20) ',' Mid(Trim(dicFields_Name.Item(ITEM_PART_CODES)), 1, 20) ','

RE: [firebird-support] Hang On ExecuteNonQuery Using Firebird2.5 with visual studio 2010

2015-02-23 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
update never fails but it fails in insert query. loop run in a single connection with a new datarows in same query. I think it is about time to show us some code (not all). Could it be that another transaction not visible to your current transaction has inserted a row that creates a lock

RE: [firebird-support] Hang On ExecuteNonQuery Using Firebird2.5 with visual studio 2010

2015-02-23 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
please, somone guide me where i am wrong This support list is for the Firebird database. For the .NET providers, you need to subscribe to the firebird-net-provider list: List-Subscribe: https://lists.sourceforge.net/lists/listinfo/firebird-net-provider, At first glance it sounds

RE: [firebird-support] Hang On ExecuteNonQuery Using Firebird2.5 with visual studio 2010

2015-02-23 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Sukhen wrote: update never fails but it fails in insert query. loop run in a single connection with a new datarows in same query. I answered: I think it is about time to show us some code (not all). Could it be that another transaction not visible to your current transaction has inserted a row

RE: [firebird-support] Multiple WHERE clauses

2015-02-22 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
You may consider WITH TMP(My72, cFrom, cTo, dValueFrom, dValueTo) as (SELECT CAST(:My72 as integer), US1.dValue, US2. dValue FROM RDB$DATABASE LEFT JOIN dSetValue('Current Year', 'From') US1 ON (1=1) LEFT JOIN dSetValue('Current Year', 'To') US2 ON (1=1)) SELECT whatever FROM TMP t CROSS JOIN

RE: [firebird-support] Charset in ISQL: How to show special characters

2015-02-19 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
my impression was the other way arround ;-) Then I'm either misreading your e-mail, or you've switched the examples around? When I change the charset in isql to any charset, that is definitly not used in the database I always get the same output from isql. I was expecting that the presentation

RE: [firebird-support] Know nothing - please help

2015-02-18 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I have a query like this: select    artikli.a_sif,     v1.v_txt,     v2.v_txt,     coalesce(sum(magkol.k_total),0) total,     coalesce(sum(magkol.k_nabcen * magkol.k_total),0) vrednost,     coalesce(sum(magkol.k_nabcen * magkol.k_total),0)/ coalesce(sum(magkol.k_total),1) nc,    

Re: [firebird-support] Query too slow

2015-02-18 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi; I am using FB 2.5.3. in a fast environment (win8 64bit - QuadCore 3.4 Ghz - 8 GB ram). If I run this query it goes very very fast and returns 84 records: Preparing query: select distinct PROC from GEST where (GEST.FSAL between '20080801' and '20080812') order by PROC Prepare time: 0.007s

SV: [firebird-support] Re: Grouping without sorting alphabetically

2015-02-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Thanks Set for starting me on the right track. Please see my finalized query below which gets me to the expected result. Good to see that you got the result you wanted, Bhavbhuti! I do have two comments regarding your final result: 1) Why do you use ORDER BY within the CTEs? In the outer

Re: [firebird-support] How to join records

2015-02-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
On Feb 16, 2015, at 4:22 AM, josef.gschwendt...@quattro-soft.de [firebird-support] firebird-support@yahoogroups.com wrote: we have 2 tables For each record in Table1 there are 2 records in Table2. Table1 (T1) == 1 2 Table2 (T2) T2T1 == 11 21 32

RE: [firebird-support] Re: Grouping without sorting alphabetically

2015-02-13 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Dataset: 1Haemogram Report 1Routine Haemogram 1Haemogram Report 5Diff. Count (Mature Cells) 1Haemogram Report 10 Special Investigations 2Haemogram Report

RE: [firebird-support] Re: Speed issues

2015-02-09 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I am having similar issues. Are there any resources to read up on this? What do you mean by similar issues, Louis? Zoran first showed us his SQL and plan, so that we more or less could see that his SQL, plan and indexes seemed good (that's arguably the most common reason for speed problems).

Re: [firebird-support] nesting - weight calculation

2015-01-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
There is at least a good alternative, Frank Ingermann showed how to do something very similar when calculating the amount of ingredients required when baking a marble cake at a Firebird conference a few years ago. He used a recursive CTE. Whether a recursive CTE is simpler than a recursive

Re: [firebird-support] Unlock record

2015-01-24 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I saw the same as you, and made the following test: - Opened my application. - Executed the option which locks a record (executes a SELECT * FROM TABLE1 WHERE (FIELD1 = 'some value') WITH LOCK). - Opened the database with IB_SQL. - Looked in table MON$STATEMENTS. I found many records. Many of

Re: [firebird-support] Unlock record

2015-01-22 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I looked in a database, and in MON$STATEMENTS tabla I have the following fields: MON$STATEMENT_ID MON$ATTACHMENT_ID MON$TRANSACTION_ID MON$STATE MON$TIMESTAMP MON$SQL_TEXT MON$STAT_ID How can I detect which is the record I have to delete to unlock my record? This is the only table I have to

SV: [firebird-support] Unlock record

2015-01-20 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
May be I can modify or delete some record in any MON$ table or do some other thing? I typically locate and delete records from MON$STATEMENTS. Mind you, that is 2.5 and typically when I have a long-running query. Don't know whether deleting from this table is possible or safe with 2.1 or

Re: [firebird-support] working days between two dates

2015-01-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi Tomas! I just mean week days... Something like DateDiff() but only counting from monday to friday. I have a function in Delphi for that. I could make an UDF I think. I just wander if there is something already done. I thought it was something very used... probably is not? I don't know

[firebird-support] Re: Deadlock exception occurs but it shouldn't?

2014-12-25 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
The main purposes of explicit locks are (1) to prevent expensive handling of update conflict errors in heavily loaded application this is the exact reason I try to avoid conflicts. My threads can wait but they should not raise exceptions. I always though that it is possible to avoid such

[firebird-support] Re: performance of subselect with group by

2014-12-18 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello, thanks Set, makes my test unnecessary! But I'm thinking a little bit about my original problem. Would it make sense to add a tracker entry for optimization of subselects without reference to outer query? I think that they should get evaluated and transformed to something

Re: [firebird-support] Performance optimation?

2014-12-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello, I save values in some tables (simpler description) First a Table who saved the timestamp of the mensuration Table A timestamps ID primary key TS timestamp Second a Table with the measured data (25 records/measured sensors will be saved every 10 Minutes, one record in Table A, 25 in

[firebird-support] Re: performance of subselect with group by

2014-12-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello, Thanks for the answer. How can I optimize if I want to use a DML command in conjunction with a subselect, e.g. delete from test where Id in ( select min(t.Id) FROM test t group by t.reference, t.key having count(*) 1 ) Hi Björn! I don't think there is any simple way to

[firebird-support] Re: performance of subselect with group by

2014-12-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I don't think there is any simple way to make a delete with a subselect as the only part of a where clause perform great on largish tables. That is, using EXECUTE BLOCK (which doesn't exist on older Firebird versions) should perform OK: execute block as declare variable id integer;

Re: [firebird-support] group by date

2014-12-14 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Any ideas? Hello @ll, I would like to group my records by day or month. The date is saved as timestamp. If I do the following, SELECT EXTRACT(day FROM m.messzeit), COUNT(*) as CountMessages FROM te_messzeiten m GROUP BY EXTRACT(day FROM m.messzeit) I get all days (1 to 31), but I need group

RE: [firebird-support] Grouping SQL counts

2014-12-11 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
FB 1.5x I have a SQL statement that returns the results I want--giving me a count on the detail dataset (ClientRegHistList is a detail list on ClientRegHis, more info below)   select C.RegDate, Count(Client_ID)     from ClientRegHist C, ClientReghistList CL    where

Re: [firebird-support] Like and database entry -

2014-12-10 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
where name like 'Ab%' returns any entry of the table, where name start with Ab except those ones containing character -. Using starting with or containing the same database entries are missing. Firebird simply doesn't exclude entries depending on which character follows what you're searching

RE: [firebird-support] Re: Firebird database seems to influence multi user ability

2014-12-09 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I have been an interbase guy about fifteen years ago and loved to see it go open source. I used to work with Paul Beach (Hello, if you're here,Paul) Yes, Paul Beach is still here, he’s working with other InterBase and Firebird experts at IB Phoenix. Here you can see who they are:

RE: [firebird-support] Why this similar to is wrong?

2014-11-25 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
select  iif('em...@testdomain.com' similar to '([_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+)','ok','fail') from rdb$database Says 'invalid string' and 'invalid pattern', but the pattern it´s the same in other languages for validate email address. I know nothing about regular

RE: [firebird-support] Left outer join with stored procedure

2014-11-19 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello All, I have a table regioni with 164 rows (r_id), and also stored procedure which returns some data like (r_id, value). When I try to use select regioni _ID, stored_procedure_value from regioni left outer join stored_procedure (:DATE1,:DATE2) I only get number 20 rows for the R_ID

RE: [firebird-support] Re: Cross database update

2014-11-17 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Dear Thomas, thank you for your answer. I have experienced that pssing by the trigger is functioning well. The only thing wrong is that the loop has no effect on the data of the records. And I hoped that someone could check the statement syntaxwise. Maybe I am doing something wrong in my

RE: [firebird-support] sum data into single row per day

2014-11-15 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Thank you Svein, that's what I tried but kept getting: SQL error code = -104. Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause). and yet it now works. I thought it must have been because I was accessing code in the iif(...). I must have

RE: [firebird-support] sum data into single row per day

2014-11-14 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
for select iif(n.code=1,sum(n.amount),0), iif(n.code=2,sum(n.amount),0), iif(n.code=3,sum(n.amount),0), n.sell_date from new_table n where n.sell_date between :fromdate and :uptodate group by n.sell_date,n.code

[firebird-support] Re: Why does the optimizer choose NATURAL for this tiny table?

2014-11-13 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi Sean/Dmitry, I've mingled my answers to your suggestions. Does the plan change to INDEX if the condition would be: S2) on p.icd10 in (t.icd10, t.icd3) S3) on p.icd10 = t.icd10 or p.icd10 = t.icd3 D2) ON p.icd10 = t.icd10 OR p.icd10 = t.icd10 No, these all keep the original plan: PLAN JOIN

[firebird-support] Why does the optimizer choose NATURAL for this tiny table?

2014-11-12 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Fb 2.5.1 I have an EXECUTE BLOCK statement, for which a small part goes NATURAL where I'd expect it to use an index associated with a UNIQUE CONSTRAINT. I would expect JOIN icd10_purres p ON p.icd10 IN (t.icd10, substring(t.icd10 from 1 for 3)) to use an index, maybe something along the lines

RE: [firebird-support] What is wrong with transactions here?

2014-11-04 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi! I have some lines in firebird.log like this: === cxv.servers.netTue Nov 4 11:37:38 2014 Sweep is started by SWEEPER Database SkyNetInt OIT 1221095, OAT 1231335, OST 1231313, Next 139981575359934 cxv.servers.netTue Nov 4 11:37:46 2014

RE: [firebird-support] update optimization problem

2014-10-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi. in firebird 2.5 Simple descrip tables table_ud ud_id integer not null primary key field_ud varchar(6) row count: 383322 table_tmp ud_id  integer  cnd    integer  index (cnd) row count: 617 UPDATE table_ud ud SET ud.field_ud = '201401' WHERE ud.ud_id in (SELECT t.ud_id FROM table_tmp t

Re: [firebird-support] How do I count the number of duplicate rows in a table?

2014-10-28 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Greetings All, Firebird 1.5.3 Should be elementary but, I'm drawing a blank on how to accomplish this. I have a table (ACCT_CASE_COURT) that contains these fields (among others): ACCT_CASE_COURT_IDINTEGERNOT NULLPK ACCT_IDINTEGERNOT NULL CASE_IDSMALLINTNOT NULL

Re: [firebird-support] PSQL: Getting both aggregation and individual rows

2014-10-27 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
is required to return the entire result set if having the aggregate functions compared to a simpler query without them (but with ORDER BY since that makes it more easily comparable)? Set On 21.10.2014 21:15, Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support] wrote: What

Re: [firebird-support] VarChars sometimes begin with single or double quote

2014-10-27 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I've not been able to find any topic that comes close to addressing my question, and it seems so basic, I'm guessing that I'm missing something fundamental. I have queries that specify for ranges in varchar fields and return those and populate my VirtualStrings in a standard alphabetical

Re: [firebird-support] PSQL: Getting both aggregation and individual rows

2014-10-21 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
What about FOR WITH TMP(MyDateTime, MySum) as (SELECT MIN(dateandtime), SUM(Value) FROM gen_data(...)) SELECT g.id, g.name, g.dateandtime, g.value, t.MyDateTime, tMySum FROM gen_data(...) g CROSS JOIN tmp t Of course, you may want a different join to CROSS JOIN. HTH, Set

RE: [firebird-support] Request new feature - better perfomance

2014-10-20 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Maybe I was not clear as I should be but here is an example in Firebird: select something,anotherthing,(select sum(thirdthing) from second b where b.something = a.something) total from a where (select sum(thirdthing) from second b where b.something = a.something) 10   tray sentence: select

RE: [firebird-support] How do I return an accurate COUNT(*) when a JOIN is involved?

2014-10-14 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
ACCT_CASE: Case Management table ACCT_IDINTEGER    NOT NULL    PK CASE_ID    SMALLINT    NOT NULL    PK CLT_ID    INTEGER    NOT NULL    FK to CLIENT table  Need this for the JOIN   DEBTOR_CASE_DEBT:  Allows for multiple PERSON's to be associated with a DEBT ACCT_IDINTEGER    NOT NULL   

RE: [firebird-support] BLOB

2014-10-13 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Text, binary, it's all the same to gbak.   Try the -g suggestion - if gbak is cleaning out garbage, it's slow. But, surely, the garbage has to be cleaned out sooner or later, and doing it in a backup run is the cheapest way to do it, as every record is being visited anyway? (Compared to, say,

[firebird-support] Re: Simultaneous inserts / selects

2014-10-10 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
All values for inserts are converted to string so there are no parameters. Sorry to hear that. MyStatement.SQL.Text:=’INSERT INTO MyTable(Field1, Field2) VALUES (:Param1, :Param2)’; MyStatement.Prepare; while not eof(InputFile) do begin readln(InputFile);

Re: [firebird-support] DATEDIFF(HOUR...) returns 1 for a 45 minutes interval

2014-10-04 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi all I would have attached a screen shot of the sample data but I guess that is not possible. What I am trying to achieve right now is get the time difference in hh:mm format to the user tStartTime and tEndTime field values 26.08.2014, 08:38:00.00026.08.2014, 09:45:00.000 26.08.2014,

Re: [firebird-support] How to improve Firebird 2.5.3 Disk I/O on Windows server 2012 R2

2014-09-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Obviously the logic of my application is not the best, but it needs to pass through a special interface, that transforms classic cobol read/write routines, in sql statements. This brings to the need to have a single commit after a single insert command of a single record. I know this is not good,

Re: [firebird-support] How to improve Firebird 2.5.3 Disk I/O on Windows server 2012 R2

2014-09-28 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi Sean, thanks for the contribution. Some answers to your requests: 1) Logic of application. It is a Microfocus Cobol legacy application, with latest (2014) x64 runtime. The long time is obviously not relative to a simple sql command, but to the overall execution. We have developed a

[firebird-support] RE: Firebirdsql adding new charsets to database

2014-09-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
If your database has the right ODS version, i.e. that it is created with Firebird 2.5, then you can just use the character set – i.e. CREATE TABLE MyTable( MyChineseField Varchar(50) character set GB18030, MyNorwegianField Varchar(50) character set iso8859_1 collate no_no, MyASCIIField

Re: [firebird-support] Select based upon date between two date fields

2014-09-15 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
The sql is below. It works fine until I add the BETWEEN statement. Hopefully you can point out something simple that I am doing wrong. SELECT description, WOReqd, Addontype as AddonTypeID, RatebookID FROM rentaladdons LEFT JOIN rentalratebook on rentaladdons.ratebookID =

Re: [firebird-support] SQL Error -104

2014-09-13 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
i just don't get it what the heck i'm doing wrong. I would like to have something like that: select ba.artno from mov_invoices mi, bas_articles ba where mi.invdate between '2014-05-01 00:00:00' and '2014-08-01 00:00:00' and case when (ba.artno like '90__') then '9000' when (ba.artno like '80__')

SV: [firebird-support] Firebird Embedded corruptions

2014-09-13 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, We have shipped Firebird Embedded bundled together with our product for a few years now and the system is currently in production at several thousand of our customer's sites. Currently we are using Firebird Embedded 2.5.1 with the latest .NET-driver and a stack consisting of Castle Active

Re: [firebird-support] How merge two queries

2014-09-10 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hallo, I have two queries: First (results: ANNO, IMPONIBILE): select EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO, SUM(DC.IMPORTO) AS IMPONIBILE from DOC_CORPO DC, DOC_TESTA DT, VOCI V WHERE DT.ID = DOC_TESTA_ID AND DT.DOCUMENTO_ID 'PRO' AND EXTRACT(YEAR FROM

[firebird-support] Re: Insert ot update statements locks a table and all other instances that try to run same statement are lcoked to

2014-09-06 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
CASHBOXID is already know. It is a reference to a table that we don't touch in the transaction. This table contains the current total amount of a cash box at the begging of the day. So when I try to load data for a cash box a java code checks is there record for this cash box for current day.

RE: [firebird-support] Insert ot update statements locks a table and all other instances that try to run same statement are lcoked to

2014-09-05 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
This is the definition of the table that locks on insert: CREATE TABLE CASH_CASHBOX_DAY_AMMOUNT ( CASHBOXID INTEGER NOT NULL, DATE_TIME NUMERIC( 18, 0) NOT NULL, AMMOUNTNUMERIC( 18, 0), CONSTRAINT PK_CASH_CASHBOX_DAY_AMMOUNT PRIMARY KEY

[firebird-support] RE: Case insensitive search on a memo field

2014-09-05 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, I'm using Firebird 2.5.3, and I am looking for text in a memo field, eg. I take it you mean BLOB or VARCHAR, I've never heard of memo fields in Firebird? Select * from mytable t where t.mymemo like '%find me%' The will only find find me and not FIND ME or Find me or Find Me etc I'm tempted

RE: [firebird-support] Case insensitive search on a memo field

2014-09-05 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Select * from mytable t where t.mymemo like '%find me%' You can create a computed index for this: CREATE INDEX idxname ON mytable COMPUTED BY (lowercase(mymemo)) Such an index does not help for LIKE '%...', it can only be used if the first character is a real character (i.e. not % or _).

RE: [firebird-support] Insert ot update statements locks a table and all other instances that try to run same statement are lcoked to

2014-09-04 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
They all use READ COMMITTED isolation. It is an application that runs in JBoss App server so I have single datasource defined that uses READ COMMITTED. Blocked statements are insert and update. Selects are not blocked. Why are inserts blocked? That should not happen unless you a) don’t

RE: [firebird-support] Query stop working after upgrade from 2.1.5 to 2.1.6

2014-09-03 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, I found that after upgrade from FireBird 2.1.5 Update 1 to 2.1.6 my query stop working with error Dynamic SQL Error SQL error code = -104 Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause). The same error occur on 2.5.3 select

Re: [firebird-support] Query stop working after upgrade from 2.1.5 to 2.1.6

2014-09-03 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, I overcome this issue with this query select ke.I_ID_GRUPY, ke.C_SYMBOL, ( select first 1 cs.C_OPIS from T_CENY_SKLADNIKI as cs left join T_CENY_W_OKRESIE as cwo on (cwo.I_ID_CENY_OKRS = cs.I_ID_CENY_OKRS) where cs.C_SYMBOL = ke.C_SYMBOL and cwo.I_ID_CENNIKA = any (select

RE: [firebird-support] conditional select

2014-08-28 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi, I'm looking at a system that I have not touched for some years and wonder if there is a way to improve this code. This all works, but is there a better or more efficient way? I can't think of how to combine them into one 'where' statement. Basically I look for a part based on

RE: [firebird-support] Difficult condiion question

2014-08-28 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hello, the following sql statement is almost done, just one thing is problematic. In the table tlager_sum I have two types of amounts, one of typ 1, one of typ 2. I just need the one of typ1. But if the material not in the table listet or just für typ 2, and there is a minimum inventory in the

RE: [firebird-support] Difficult condiion question

2014-08-28 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
I think I have it: SELECT TT.TEILENR, TT.BEZEICHNUNG, LS.MENGE, TT.MINB, LS.TYP, TT.TYP FROM TTEILE TT LEFT JOIN TLAGER_SUM LS ON TT.TEILENR = LS.TEILENR AND LS.TYP = 1 WHERE TT.TYP=1 AND (LS.MENGE IS NOT NULL AND LS.MENGEtt.minb OR TT.MINB0 and ls.menge is null) ORDER BY TT.TEILENR; The and

RE: [firebird-support] Case-insensitive, unique, multi-column index

2014-08-18 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
The problem comes with the second.  (1, 'Bob Jacobs'), (2, 'Bob Jacobs'), (3, 'BOB JACOBS'), and (4, 'bob jacobs') constitute an acceptable set of rows; (2, 'Bill Hafner') and (2, 'BILL HAFNER') do not.  That is, given a value for CORPORATION_S_KEY, there shouldn't be case-variants for the NAME

Re: [firebird-support] Getting Invalid Request BLR at offset 49 ?

2014-08-09 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
If (:In_vin = :Out_BikeLast8Vin) then BEGIN Update Total_sales_to_part_cost_match set TSPM_BIKEYEAR = :Out_BikeYear,TSPM_BIKEMAKE = :Out_BikeMake, TSPM_BIKEMODEL = :Out_BikeModel, TSPM_LAST8VIN = :Out_BikeLast8Vin; Given that your stored procedure will

RE: [firebird-support] Create Date of Database Object

2014-08-04 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Hi,   Is it possible to see from the systems tables when a database object was created?   For instance I want to try and find out when a specific trigger was created on the database, is this possible? table: MON$DATABASE field: MON$CREATION_DATE I think that is just the creation date (or

SV: [firebird-support] Firebird caching query results

2014-08-01 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
In my environment I have a software which insert new rows on a certain table. This software and the firebird server is running on the same machine. I have a software running on a client which query the the server. The problem is there are some sort of cache, because I'm getting the old rows.

RE: [firebird-support] Skip records

2014-07-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
Thomas, I usually solve this kind of problem with recusive CTEs providing a counter for the records returned, thus a simple select statement can nicely filter on this kind of property without row numbers functionality. Can you provide an example, please. I, for one, can't imagine how a CTE

SV: [firebird-support] How to truncate text to fit in a db field the easiest way in Firebird?

2014-07-29 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
$CATEGORY=str_replace(','',$_REQUEST['CATEGORY']); I convert html entities to text i can use on the web pages. I use this for being able to retrieve it back as normal characters. I use this on all my inserts. And, then i want to put it in the category field in the table. Let's say the category

  1   2   >