Re: [firebird-support] info
This "Problem" is listed in the tracker: http://tracker.firebirdsql.org/browse/CORE-1645 I don't understand who ever though of supporting case-behaviour, why the hell should i want a table named "ATable" and "atable" and both different tables. Anyway this is something what is inherited from the past, let's hope the firebird developers get some time in the future to solve this. Kind Regards, Arno Brinkman ABVisie -Oorspronkelijk bericht- From: Nico Speleers - Carfac BVBA nico.spele...@carfac.com [firebird-support] Sent: Thursday, January 5, 2017 10:36 AM To: firebird-support@yahoogroups.com Subject: RE: [firebird-support] info Based on table- and columnnames in camelcase our programmers can automatic create their objects and classes. Therefore we need to create our table- and columnnames in camelcase. Another reason is readability. We found camelcase more readable then UPPERCASE. Have you got a solution for my problem ? Nico Speleers Analyst Carfac bvba Driving on experience Rijksweg 53 9680 Maarkedal Tel. +32 55 23 00 00 Fax +32 55 31 00 95 nico.spele...@carfac.com www.carfac.be -Oorspronkelijk bericht- Van: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] Verzonden: donderdag 5 januari 2017 10:23 Aan: firebird-support@yahoogroups.com Onderwerp: Re: [firebird-support] info 05.01.2017 8:51, Nico Speleers - Carfac BVBA nico.spele...@carfac.com [firebird-support] wrote: > If I execute Create table MyTable(aField integer) then the tablename is > saved as MYTABLE. Why do you care how it is saved? Just don't look into system tables when writing your queries. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links Posted by: Nico Speleers - Carfac BVBA++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links
Re: [firebird-support] Left join derived table
Hi, > SELECT A.FIELD_1, A.FIELD_2, D.FIELD_D1, D.FIELD_D2 > FROM TABLE_A A > LEFT JOIN (SELECT FIRST 1 D.FIELD_D1, D.FIELD_D2, D.FIELD_3 FROM TABLE_D D > ORDER BY D.ID DESC) D ON D.FIELD_3 = A.FIELD_3 I assume this is not what he wants. The reason is the FIRST 1 in the derived table! The (D.FIELD_3 = A.FIELD_3) clause will be executed after the FIRST 1 on the derived table is applied. If TABLE_D.ID is unique this could be a solution: SELECT A.FIELD_1, A.FIELD_2, D.FIELD_D1, D.FIELD_D2 FROM TABLE_A A LEFT JOIN TABLE_D D ON (D.ID = (SELECT FIRST D2.ID FROM TABLE_D D2 WHERE D2.FIELD_3 = A.FIELD_3 ORDER BY D2.ID DESC)) Kind Regards, Arno Brinkman ABVisie From: liviuslivius liviusliv...@poczta.onet.pl [firebird-support] Sent: Wednesday, September 28, 2016 12:39 PM To: firebird-support@yahoogroups.com Subject: Re: [firebird-support] Left join derived table W dniu 2016-09-28 09:04:07 użytkownik 'Marcin Bury' marcin.b...@studio-delfi.pl [firebird-support]napisał: Hello All I'd like to ask how to get below statement working: SELECT A.FIELD_1, A.FIELD_2, D.FIELD_D1, D.FIELD_D2 FROM TABLE_A A LEFT JOIN (SELECT FIRST 1 FIELD_D1, FIELD_D2 FROM TABLE_D D WHERE D.FIELD_3 = A.FIELD_3 ORDER BY D.ID DESC) D ON (1=1) Firebird complains that A.FIELD_3: Column does not belong to referenced table. I have the 'one to many' relation between TABLE_A and TABLE_D, and I would like to join a record from TABLE_A with latest detail entry from TABLE_D. Maybe derived tables are not the right solution here. Thanks Marcin ._,___
Re: [firebird-support] Optimizer request
Which Firebird version are you using? Does this perform for you as expected: SELECT * FROM (SELECT partners.partid + 0 AS PartID FROM partners WHERE partners.country = 'Spain') dt JOIN orders ON (orders.partid = dt.partid) Kind Regards, Arno Brinkman From: mailto:firebird-support@yahoogroups.com Sent: Saturday, September 10, 2016 10:05 PM To: firebird-support@yahoogroups.com Subject: Re: [firebird-support] Optimizer request CREATE TABLE PARTNERS ( PARTID INTEGER NOT NULL, COUNTRY CHAR(20) ); ALTER TABLE PARTNERS ADD CONSTRAINT PK_PARTNERS PRIMARY KEY (PARTID); CREATE INDEX PARTNERS_IDX1 ON PARTNERS (COUNTRY); CREATE TABLE ORDERS ( ORDERNUM INTEGER NOT NULL, ORDERDATE DATE, AMOUNT DECIMAL(18,2), PARTID INTEGER ); ALTER TABLE ORDERS ADD CONSTRAINT PK_ORDERS PRIMARY KEY (ORDERNUM); ALTER TABLE ORDERS ADD CONSTRAINT FK_ORDERS_PARTNERS FOREIGN KEY (PARTID) REFERENCES PARTNERS (PARTID) ON DELETE NO ACTION ON UPDATE NO ACTION; This is tables definitions. So, index exist and after all perfomance analyzer gives me same result. Perfomance analyzer was taken from IBExpert. Whatever I do (as others suggest) perfomance are the same. I still vote for changes in optimizer. Right side from WHERE clause needs to be evaluated before main query and it is simple and much better solution same as Oracle optimize query. Firebird is very kind to programmer and has easy to understand, efficient P/SQL and some improvements will give us significant efficiency. . Djordje From: mailto:firebird-support@yahoogroups.com Sent: Friday, September 09, 2016 10:51 PM To: firebird-support@yahoogroups.com Subject: Re: [firebird-support] Optimizer request On Fri, Sep 9, 2016 at 8:30 AM, 'Djordje Radovanovic' softsis...@sbb.rs [firebird-support]wrote: I tried query with subquery in where clause and found big issue for this type of subquery. select * from orders where orders.partid in (select partners.partid from partners where partners.country = ‘Spain’) Perfomance Analysis returns me this partners 687660 non index reads orders 28657 index reads If you analyze this result you’ll find that there is 687659 unnecessary non index reads. If developer of optimizer accept that all queries on the left side of where clause has priority (and there is no way to be opposite) than we have big improvement in optimization. Is there an index on partners.country? What plans are generated for each query? If I were writing this query, I'd write select o.* from orders o inner join partners p where p.partid = o.opartid and p.country = 'Spain'; All that silliness about "select from (select from )" probably doesn't save anything in this case - it does when the inner select is complicated, but not here. Firebird won't carry around unneeded fields from the partners table. What is the distribution of partners.country? Good luck, Ann __,_._,_
Re: [firebird-support] SQL Error Code -104: What is wrong with this rather simply SQL?
Hi, The message doesn’t tell you which expression is not contained in an aggregate function or GROUP BY clause, but is very clear that it is “P.PHONE_ID” Not sure what you trying to achieve, but your SQL is indeed invalid, because there can be multiple PHONE_ID’s per AREA_CODE, PHONE_NO Kind Regards, Arno Brinkman From: mailto:firebird-support@yahoogroups.com Sent: Wednesday, April 6, 2016 10:03 PM To: firebird-support@yahoogroups.com Subject: [firebird-support] SQL Error Code -104: What is wrong with this rather simply SQL? SELECT DISTINCT P.AREA_CODE, P.PHONE_NO, (SELECT COUNT(*) FROM PHONE P2 WHERE P2.PHONE_ID = P.PHONE_ID) AS CNT FROM PHONE P WHERE P.AREA_CODE IS NOT NULL GROUP BY 1, 2 HAVING (SELECT COUNT(*) FROM PHONE P3 WHERE P3.PHONE_ID = P.PHONE_ID AND P3.AREA_CODE IS NOT NULL) > 1 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)
Re: AW: AW: AW: [firebird-support] coalesce bug in fb 3.0 rc2?
Hi, Thank you for providing a script, this is much easier comparing. I can now reproduce the error you get. Please enter a ticket with this script into the tracker, so they can fix this issue. Enter these both queries, so they can quickly find the bug: The query with the wrong results: SELECT a.tnr, a.minb, coalesce(b.amount,0) as m FROM t_main a left join t_stock b on (a.tnr = b.tnr) WHERE ((a.minb > coalesce(b.amount,0))) A workaround by ignoring use of index: SELECT a.tnr, a.minb, coalesce(b.amount,0) as m FROM t_main a left join t_stock b on (a.tnr = b.tnr || '') WHERE ((a.minb > coalesce(b.amount,0))) Kind Regards, Arno
Re: [firebird-support] Firebird 3.0 RC1 - SQL optimization help
Hello, You have no indices defined at all. While i don’t understand your system i cannot really say what indices you should add, but these will at least help: CREATE ASC INDEX I_TERMINAL_SAYIM ON TERMINAL_SAYIM (BELGENO, ADRESKODU, ISLEMTURU, BARKOD, OLCUBIRIMI, TEKPARCA); Kind Regards, Arno Brinkman From: mailto:firebird-support@yahoogroups.com Sent: Wednesday, January 20, 2016 4:57 PM To: firebird-support@yahoogroups.com Subject: [firebird-support] Firebird 3.0 RC1 - SQL optimization help Hi, I have below tables. CREATE TABLE BAZLISTE ( ADRESKODU varchar(30) NOT NULL, ISLEMTURU varchar(2) NOT NULL, BELGENO varchar(30) NOT NULL, BARKOD varchar(30) NOT NULL, MIKTAR bigint, OLCUBIRIMI varchar(10), PRIMARY KEY (BELGENO,BARKOD,ADRESKODU,ISLEMTURU) ); CREATE TABLE TERMINAL_SAYIM ( LAPTOPID bigint generated by default as identity not null primary key, DOSYAADI varchar(250) NOT NULL, ELTERMINALIKAYITID bigint NOT NULL, ADRESKODU varchar(30), BELGENO varchar(30) NOT NULL, BELGETARIHI date NOT NULL, BELGEADI varchar(30), LOKASYONKODU varchar(30) NOT NULL, BOLGEKODU varchar(30) NOT NULL, GOZKODU varchar(30) NOT NULL, SSCC varchar(30), SSCCKAPANDI char(1) CHARACTER SET ISO8859_1, BARKOD varchar(30) NOT NULL, MIKTAR integer NOT NULL, OLCUBIRIMI varchar(10), KONTROLSUZ varchar(1) NOT NULL, TEKPARCA char(1) CHARACTER SET ISO8859_1 NOT NULL, TEKPARCAINDEX smallint NOT NULL, TERMINALID varchar(30), KULLANICIKODU varchar(30), OKUTMATARIHSAATI timestamp NOT NULL, AKTARIMTARIHSAATI timestamp NOT NULL, AKTARANKULLANICI varchar(30) NOT NULL, SERINO varchar(25), LOT varchar(25), SKT varchar(10), ISLEMTURU varchar(2), ESLESTI varchar(1) ); CREATE TABLE URUN ( BARKOD varchar(30) NOT NULL primary key, URUNKODU varchar(50), URUNACIKLAMASI varchar(60), URUNGRUBU varchar(30), RENK varchar(20), BEDEN varchar(20), CUP varchar(20), OLCUBIRIMI varchar(10), SERINO varchar(1), LOT varchar(1), SKT varchar(1) ); I am running below SQL which takes 7.5 minutes. select AdresKodu as "Adres Kodu", IslemTuru as "İşlem Türü", BelgeNo as "Belge No", Barkod, OlcuBirimi as "Ölçü Birimi",SayimMiktar as "Okutulan Miktar",BazMiktar as "Baz Miktar",(SayimMiktar-BazMiktar) as Fark, UrunKodu as "Ürün Kodu",UrunAciklamasi as "Ürün Açıklaması",UrunGrubu as "Ürün Grubu",Renk,Beden,Cupfrom (SELECTdbovwUNB.AdresKodu, dbovwUNB.IslemTuru, dbovwUNB.BelgeNo, dbovwUNB.barkod, dbovwUNB.olcubirimi, coalesce(dbovwUT.Miktar,0) AS SayimMiktar, coalesce(dbovwUBAZ.Miktar, 0) AS BazMiktar, URUN.UrunKodu, URUN.UrunAciklamasi, URUN.UrunGrubu, URUN.Renk, URUN.Beden, URUN.CupFROM(SELECTAdresKodu, IslemTuru, BelgeNo, barkod, olcubirimi FROMBAZLISTEwhere BelgeNo='REYSAS' AND AdresKodu='SAYIM' AND IslemTuru='SA'UNIONSELECTAdresKodu, IslemTuru, BelgeNo, barkod, olcubirimiFROMTERMINAL_SAYIMwhere BelgeNo='REYSAS' AND AdresKodu='SAYIM' AND IslemTuru='SA') asdbovwUNBLEFT OUTER JOINURUN ON dbovwUNB.olcubirimi = URUN.OlcuBirimi AND dbovwUNB.barkod = URUN.Barkod LEFT OUTER JOIN(SELECTAdresKodu, IslemTuru, BelgeNo, Barkod, Miktar, OlcuBirimiFROMBAZLISTEwhere BelgeNo='REYSAS' AND AdresKodu='SAYIM' AND IslemTuru='SA') as dbovwUBAZ ON dbovwUNB.olcubirimi = dbovwUBAZ.OlcuBirimi AND dbovwUNB.barkod = dbovwUBAZ.Barkod AND dbovwUNB.BelgeNo = dbovwUBAZ.BelgeNo AND dbovwUNB.IslemTuru = dbovwUBAZ.IslemTuru AND dbovwUNB.AdresKodu = dbovwUBAZ.AdresKodu LEFT OUTER JOIN(SELECTAdresKodu , IslemTuru, BelgeNo, Barkod, OlcuBirimi , SUM(Miktar) AS MiktarFROM TERMINAL_SAYIMwhere BelgeNo='REYSAS' AND AdresKodu='SAYIM' AND IslemTuru='SA' and TekParca='H'GROUP BY BelgeNo, Barkod, OlcuBirimi, IslemTuru, AdresKodu, BelgeNo) as dbovwUT ON dbovwUNB.olcubirimi = dbovwUT.OlcuBirimi AND dbovwUNB.barkod = dbovwUT.Barkod AND dbovwUNB.BelgeNo = dbovwUT.BelgeNo AND dbovwUNB.IslemTuru = dbovwUT.IslemTuru AND dbovwUNB.AdresKodu = dbovwUT.AdresKodu) as BazKarsilastirma I read below PLAN generated before executing the SQL in Flamerobin: Preparing statement: select AdresKodu as "Adres Kodu", IslemTuru as "İşlem Türü", BelgeNo as "Belge No", Barkod, OlcuBirimi as "Ölçü Birimi",SayimMiktar as "Okutulan Miktar",BazMiktar as "Baz Miktar",(SayimMiktar-BazMiktar) as Fark, UrunKodu as "Ürün Kodu",UrunAciklamasi as "Ürün Açıklaması",UrunGrubu as "Ürün Grubu",Renk,Beden,Cupfrom (SELECTdbovwUNB.AdresKodu, dbovwUNB.IslemTuru, dbovwUNB.BelgeNo, dbovwUNB.barkod, dbovwUNB.olcubirimi, nullif(dbovwUT.Miktar,0) AS SayimMiktar, nullif(dbovwUBAZ.Miktar, 0) AS BazMiktar, URUN.UrunKodu, URUN.UrunAciklamasi, URUN.UrunGrubu, URUN.Renk, URUN.Beden, URUN.CupFROM(SELECTAdresKodu, IslemTuru, BelgeNo, barkod, olcubirimi FROMBAZLISTEwhere BelgeNo='REYSAS' AND AdresKodu='SAYIM' AND
Re: [firebird-support] 'Invalid expression' error in GROUP BY when field based on a SQL statement is used in SELECT field list
May be this is what you want: SELECT ReceiptID, (SELECT FIRST 1 S.Service FROM ReceiptLine RLF JOIN Service S ON (S.ServiceID = RLF.ServiceID) WHERE RLF.ReceiptLineID = MIN(RL.ReceiptLineID) ) AS Service, SUM(Qty*Cost) Price FROM ReceiptLine RL GROUP BY ReceiptID Regards, Arno Brinkman ABVisie From: mailto:firebird-support@yahoogroups.com Sent: Monday, January 18, 2016 9:50 AM To: firebird-support@yahoogroups.com Subject: [firebird-support] 'Invalid expression' error in GROUP BY when field based on a SQL statement is used in SELECT field list This 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)" is returned by the following SQL: SELECT ReceiptID, ( SELECT FIRST 1 S.Service FROM Service S WHERE (S.ServiceID = RL.ServiceID) ORDER BY RL.ReceiptLineID ) AS Service, SUM(Qty*Cost) Price FROM ReceiptLine RL GROUP BY ReceiptID, Service Additional information: The table ReceiptLine is a detail (as in master-detail) table that stores the line items relating to a purchase, with the fields ReceiptID and ServiceID being foreign keys. The Service table stores product/service names. Using the ReceiptLine and Service tables, the SQL needs to provide the total of each receipt with only the first service name from the set of line items. Is there an alternative way, using SQL only, to achieve the desired result?
Re: [firebird-support] FB 3.0
Support for Users of Firebird ReleasesHi, Just quickly restored a FB2 DB in FB3 and connected with the Application (Build in Delphi 7 using IBX). I copied the fbclient.dll from the install directory into the application directory and renamed to gds32.dll No problems i ran into. Met vriendelijke groet, Arno Brinkman ABVisie a...@abvisie.nl http://www.abvisie.nl
Re: [firebird-support] Conditional where statements
Hi, Another solution could be building the query up with the conditions and use "EXECUTE STATEMENT " in the stored procedure Kind Regards, Arno Brinkman ABVisie -Oorspronkelijk bericht- From: Alan J Davies alan.dav...@aldis-systems.co.uk [firebird-support] Sent: Thursday, November 5, 2015 9:00 PM To: firebird-support@yahoogroups.com Subject: [firebird-support] Conditional where statements Hi, I have a SP that has been running as is for many years on various servers and the performance is very acceptable. However, I have just replaced a dual Xeon test server with - wait for it! - a Raspberry PI 2 running a customised Linux OS. It runs perfectly well and I've benchmarked a number of SPs and the difference is 0.5 - 1 second or so which is great for testing updates where there's only 2-3 users, but importantly it highlights the inefficiency of my code. The upside is that there is a huge benefit in power consumption!! This is one of my SPs that I've shown in full rather than a cut-down version, which is what I would normally do. This takes a second or less on the customer's system and 11-12 seconds on the Raspberry and the reason for that is the OR statements. If I remove them it comes down to the 0.5 seconds result. That may seem obvious to some but I was unaware of the big performance hit that was disguised by the brute force of the servers. I could, of course, have 8 different SPs - one for each variant of locsearch ( locsearch is passed as a parameter from Delphi - from a stock number to an invoice number etc.) but that means I have to ensure that a change to one is replicated to all others which is why I do it this way. (its too easy to miss one version) My question, therefore, is 'Is that what I have to do and just be careful?' or is there a more elegant but high-performance solution. create or alter procedure stocks_many_sel ( locsearch varchar(30), loclocation char(1), loctransaction char(1), fromdate date_char, uptodate date_char, locindex integer) returns ( trans_type char(1), location shop_location, stock_no stock_nmbr, mini_desc char_40, ref char_30, stone_wt stone_weight, cost_price float_as_char, ret_price float_as_char, act_price float_as_char, sell_date date_no_century, inv_date date_no_century, invoice_price float_as_char, sequence_no decimals_0, real_inv_date date_domain, real_sell_date date_domain, acno account, cust_no decimals_0, tickettype char(1)) as begin /* search conditions - location and trans_type, e.g. W C, H D any 2 combinations when entered must be matched however, if left blank will be found just by stock_no set loclocation & loctransaction to null to make the not distinct work */ if (loclocation='') then loclocation=null; if (loctransaction='') then loctransaction=null; locsearch=trim(locsearch); for select s.stock_no, case when s.inv_date is null then '' else datetostr(s.inv_date,'%d/%m/%y') end, s.ref, floattostr(s.invoice_price,'% 12.2f'), floattostr(cost_price,'% 12.2f'), floattostr(s.ret_price,'% 12.2f'), floattostr(s.act_price,'% 12.2f'), s.location,s.trans_type, case when s.sell_date='01/01/2000' then '' else datetostr(s.sell_date,'%d/%m/%y') end, s.stone_wt,s.tickettype, left(s.desc_blob,40), s.sequence_no, s.inv_date,s.sell_date,s.acno,s.cust_no fromstocks s joinsupplier su on su.acno=s.acno and s.location is not distinct from coalesce(:loclocation,s.location) and s.trans_type is not distinct from coalesce(:loctransaction,s.trans_type) and s.inv_date between :fromdate and :uptodate /* search by field passed in locindex */ where (:locindex=0/* stock no */ and s.stock_no=:locsearch) or (:locindex=1/* stock class */ and s.stkclass=:locsearch) or (:locindex=2/* ref */ and s.ref containing :locsearch) or (:locindex=3/* certificate */ and s.certificate containing :locsearch) or (:locindex=4/* inv_nmbr */ and s.inv_nmbr containing :locsearch) or (:locindex=5 /* supplier */ and s.acno=:locsearch) or (:locindex=-1 /* pursuit # */ and s.pursuit_no=:locsearch) or (:locindex=6 /* description */
Re: [firebird-support] Firebird Temporary Table
Hello, > I am using firebird 2.5. > Need to use temporary table on my stored procedures. I am able to create > temporary table using create global temporary table command. > But when i select it, it returns 'unknown table' error. Did i do it wrong > ? > I would like to know how to use global temporary table in firebird. Those are Connection or Transaction bound, may be there is your problem, read for more info: http://www.firebirdsql.org/refdocs/langrefupd21-ddl-table.html Kind Regards, Arno Brinkman ABVisie a...@abvisie.nl