Re: [firebird-support] strange bahaviour

2019-07-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 04/07/2019 11:21, Svein Erling Tysvær setys...@gmail.com 
[firebird-support] ha scritto:
If you were using dialect 1, I would say the difference would be 
expected (since NUMERIC(18) is equal to DOUBLE PRECISION in dialect 
1), but I guess you're using dialect 3?


Yes, I use dialect 3 on FB 2.5.8.27089

Luigi Siciliano

--



Re: [firebird-support] strange bahaviour

2019-07-03 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 03/07/2019 16:35, liviuslivius liviusliv...@poczta.onet.pl 
[firebird-support] ha scritto:

What are the exact types of both fields?


NUMERIC(18,4) via domain:

CREATE DOMAIN CURRENCY_D
 AS Numeric(18,4)
 DEFAULT 0.00
 NOT NULL
;

Thanks.
--

Luigi Siciliano
--



[firebird-support] strange bahaviour

2019-07-03 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

I have this query:

select
  id,
  importo,
  pagato
from
  elenco_scadenze
where
  (importo - pagato) <> 0.00

and this results:

ID    IMPORTO    PAGATO

29  60,0016   60,00

90    569,8344    569,83


If I do this:

UPDATE

  ELENCO_SCADENZE

set

  IMPORTO = CAST(IMPORTO AS DECIMAL(18,2))


the result of the query changes but is a mistake because the result must 
be _no rows_ :


ID    IMPORTO    PAGATO

29  60,00       60,00

90    569,83        569,83


Why?

Thanks.

--

Luigi Siciliano
--



Re: [firebird-support] No login to all databases

2019-05-02 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hello,

Il 02/05/2019 10.53, Salvatore Besso salvatore.be...@outlook.it 
[firebird-support] ha scritto:


maybe a remove and reinstall of Firebird could cure the problem. Save
the users database before removing Firebird.

No, remove and reinstall do not solve :( maybe Windows is damaged (I see 
that M$ SqlServer don't works like Firebird).


I need to reinstall Windows 8.1 (build 6.3.9600) but after download at 
microsoft.com site during install at 72% except a error that a file (not 
specified) is missing or damaged and stop installation :(


Thanks.
--

Luigi Siciliano
--




Re: [firebird-support] No login to all databases

2019-05-02 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
I tried to copy all my databases in another system and with the same 
server version 2.5.8.27089 and the same Flamerobin version 0.9.2 the 
databases opens and i can read all tables.
What I can verify on system that cannot open databases?
Thanks

-- 
Luigi Siciliano
--






++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] No login to all databases

2019-05-02 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hello,
  I had a system failure... My system not boot at all. Seems to lost 
the MBR that I rebuild with a command line "bootsect /nt60 c: /MBR"
After the rebuild MBR my sistem seems to works but all Firebird 
databases not login.
Seems that Firebird hangs but in windows resource manager Firebird 
server has 0% CPU and 2,0MB RAM.
If i try to connect to database even Flamerobin hangs without error for 
hours.

GFix same of flamerobin.
I tried with a copy of database make before a sistem failure but is the 
same problems.

All of programs in my system seems to works fine.
What I can do?

--

Luigi Siciliano
--



Re: ODP: [firebird-support] Before Insert or After Insert trigger?

2018-09-07 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hi,

Il 06/09/2018 10.41, Karol Bieniaszewski liviusliv...@poczta.onet.pl 
[firebird-support] ha scritto:
If you need to update same table then „before” update trigger is the 
best choice.


>>Updating another table from a Before trigger is made in a transaction

>>that rolling back if exception occurs?

If you do not run it in different transaction context - like IN 
AUTONOMOUS TRANSACTION - then yes



Ok, I think I asked an incorrect question
I could explain better:
Updating another table from a Before trigger is made in a transaction 
that rolling back if exception occurs even I have hundred rows in table 
that fire a before insert/update trigger and if the exception occurs in 
hundredth row? or trigger is fired row by row in table and this 
behaviour not occurs and the update made by row 1..99 are confirmed even 
occurs an exception in row 100?


Thanks.
--

Luigi Siciliano
--



[firebird-support] Before Insert or After Insert trigger?

2018-09-06 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

   I have an After Insert/Update trigger for a table to update another 
table like this:



   if (NEW.AGGIORNA_CONDIZIONI = 1) then
     begin
   update
     ARTICOLI_CONDIZIONI_CLIENTI ACC
   SET

       
     end
   else if ...



Now I need to set a fields in the same table like this to track the 
updates performed:

CONDIZIONI_AGGIORNATE = NEW.AGGIORNA_CONDIZIONI,

AGGIORNA_CONDIZIONI = 0 /* no conditions to update */


To do this I must change from After Insert/Update trigger in Before 
Insert/Update trigger.

Is this safe or I must do other behaviour?

Updating another table from a Before trigger is made in a transaction 
that rolling back if exception occurs?

Thanks.

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Query and problem with nulls

2018-01-05 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 04/01/2018 21.57, setysvar setys...@gmail.com [firebird-support] ha 
scritto:


I expect the following query to give you the result
you want:

...


Yes.
I think I understand your query and I'll treasure it for the next time.

Thanks so much.
--

Luigi Siciliano
--



Re: [firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
not, I not solved ;(
The query seem to works because return rows but the rows returned are 
wrongs.
-- 

Luigi Siciliano
--



Re: [firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 04/01/2018 13.27, Rustam rusta...@ukr.net [firebird-support] ha scritto:


Try use explicit JOIN here:

...

FROM
  DOC_CORPO DC, DOC_TESTA DT


Not works because in DT there is not rows between 01/01/2018 and 31/12/2018.

But I solved:

I have another table in database that contains foreign keys for 
dt.deposito_id.

I modified the query like this, and now works ok:
SELECT
  DEPOSITO_ID,
  RIPORTO,
  CARICO,
  SCARICO,
  RIPORTO + ESISTENZA AS ESISTENZA,
  IMPEGNATI,
  ORDINATI
FROM
(
 SELECT
   D.ID AS DEPOSITO_ID,
   (SELECT
  SUM(DC2.CARICO - DC2.SCARICO)
    FROM
  DOC_CORPO DC2,
  DOC_TESTA DT2
    WHERE
  DC2.DOC_TESTA_ID = DT2.ID
  AND DC2.ARTICOLO_ID = :ID
  AND DT2.DATA < :DaData
   ) AS RIPORTO,
   SUM(DC.CARICO) as Carico,
   SUM(DC.SCARICO) as Scarico,
   SUM(DC.CARICO - DC.SCARICO) as ESISTENZA,
   SUM(DC.IMPEGNATI) as Impegnati,
   SUM(DC.ORDINATI) as Ordinati
 FROM
  DEPOSITI D
   LEFT JOIN DOC_TESTA DT ON D.ID = DT.DEPOSITO_ID,
   DOC_CORPO DC
 WHERE
   DC.ARTICOLO_ID = :ID
   AND DT.DATA >= :DaData
   AND DT.DATA <= :AData
 GROUP BY
   D.ID
)

Thanks.
--

Luigi Siciliano
--



Re: [firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
I expecting the result because in table Doc_testa DT I have rows between 
01/01/2017 and 31/12/2017 and not have rows between 01/01/2018 and 
31/12/2018.
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 04/01/2018 16.58, Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] ha scritto:
> 04.01.2018 16:55, Luigi Siciliano luigi...@tiscalinet.it [firebird-support] 
> wrote:
>> As you see:
>> - if I select between 01/01/2018 and 31/12/2018 the are not rows in DT
>> - if I select between 01/01/2017 and 31/12/2017 works fine because the
>> are at least 1 row in DT
> So, where is the problem? I can't see "all nulls".
>
The problem is:
if I select between 01/01/2018 and 31/12/2018 I not have results! this because 
there are no rows in DT between 01/01/2018 and 31/12/2018.

I, instead, expecting this result:
DEPOSITO_ID RIPORTO CARICO SCAR
ICO   ESISTENZA   IMPEGNATI ORDINATI
=== === ===

=== === === ===
    1  1.   0.000 0.0
000   2.000  0. 0.

Thanks.
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 04/01/2018 12.39, Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] ha scritto:
> Are you sure that your query really returns all nulls and this is not a 
> visual bug in
> the tool you run this query in? Show log from isql, please.
the log is:
SQL> SELECT
CON>   DEPOSITO_ID,
CON>   RIPORTO,
CON>   CARICO,
CON>   SCARICO,
CON>   RIPORTO + ESISTENZA AS ESISTENZA,
CON>   IMPEGNATI,
CON>   ORDINATI
CON> FROM
CON> (
CON>  SELECT
CON>    DT.DEPOSITO_ID,
CON>    (SELECT
CON>   SUM(DC2.CARICO - DC2.SCARICO)
CON> FROM
CON>   DOC_CORPO DC2,
CON>   DOC_TESTA DT2
CON> WHERE
CON>   DC2.DOC_TESTA_ID = DT2.ID
CON>   AND DC2.ARTICOLO_ID = 'CRSSV750'
CON>   AND DT2.DATA < '01/01/2018'
CON>    ) AS RIPORTO,
CON>    SUM(DC.CARICO) as Carico,
CON>    SUM(DC.SCARICO) as Scarico,
CON>    SUM(DC.CARICO - DC.SCARICO) as ESISTENZA,
CON>    SUM(DC.IMPEGNATI) as Impegnati,
CON>    SUM(DC.ORDINATI) as Ordinati
CON>  FROM
CON>    DOC_CORPO DC, DOC_TESTA DT
CON>  WHERE
CON>    DC.DOC_TESTA_ID = DT.ID
CON>    AND DC.ARTICOLO_ID = 'CRSSV750'
CON>    AND DT.DATA >= '01/01/2018'
CON>    AND DT.DATA <= '12/31/2018'
CON>  GROUP BY
CON>    DT.DEPOSITO_ID
CON> );
SQL> SELECT
CON>   DEPOSITO_ID,
CON>   RIPORTO,
CON>   CARICO,
CON>   SCARICO,
CON>   RIPORTO + ESISTENZA AS ESISTENZA,
CON>   IMPEGNATI,
CON>   ORDINATI
CON> FROM
CON> (
CON>  SELECT
CON>    DT.DEPOSITO_ID,
CON>    (SELECT
CON>   SUM(DC2.CARICO - DC2.SCARICO)
CON> FROM
CON>   DOC_CORPO DC2,
CON>   DOC_TESTA DT2
CON> WHERE
CON>   DC2.DOC_TESTA_ID = DT2.ID
CON>   AND DC2.ARTICOLO_ID = 'CRSSV750'
CON>   AND DT2.DATA < '01/01/2017'
CON>    ) AS RIPORTO,
CON>    SUM(DC.CARICO) as Carico,
CON>    SUM(DC.SCARICO) as Scarico,
CON>    SUM(DC.CARICO - DC.SCARICO) as ESISTENZA,
CON>    SUM(DC.IMPEGNATI) as Impegnati,
CON>    SUM(DC.ORDINATI) as Ordinati
CON>  FROM
CON>    DOC_CORPO DC, DOC_TESTA DT
CON>  WHERE
CON>    DC.DOC_TESTA_ID = DT.ID
CON>    AND DC.ARTICOLO_ID = 'CRSSV750'
CON>    AND DT.DATA >= '01/01/2017'
CON>    AND DT.DATA <= '12/31/2017'
CON>  GROUP BY
CON>    DT.DEPOSITO_ID
CON> );

DEPOSITO_ID RIPORTO CARICO SCAR
ICO   ESISTENZA   IMPEGNATI ORDINATI
=== === === 

=== === === ===
   1  0.   1.000 0.0
000   1.000  0. 0.

As you see:
- if I select between 01/01/2018 and 31/12/2018 the are not rows in DT
- if I select between 01/01/2017 and 31/12/2017 works fine because the 
are at least 1 row in DT

Any suggestion?

Thanks.
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] Query and problem with nulls

2018-01-04 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

   The following query works fine but returns *all nulls* if no rows 
between :DaData and :AData

SELECT

   DEPOSITO_ID,
   RIPORTO,
   CARICO,
   SCARICO,
   RIPORTO + ESISTENZA AS ESISTENZA,
   IMPEGNATI,
   ORDINATI
FROM
(
  SELECT
    DT.DEPOSITO_ID,
    (SELECT
   SUM(DC2.CARICO - DC2.SCARICO)
     FROM
   DOC_CORPO DC2,
   DOC_TESTA DT2
     WHERE
   DC2.DOC_TESTA_ID = DT2.ID
   AND DC2.ARTICOLO_ID = :ID
   AND DT2.DATA < :DaData
    ) AS RIPORTO,
    SUM(DC.CARICO) as Carico,
    SUM(DC.SCARICO) as Scarico,
    SUM(DC.CARICO - DC.SCARICO) as ESISTENZA,
    SUM(DC.IMPEGNATI) as Impegnati,
    SUM(DC.ORDINATI) as Ordinati
  FROM
    DOC_CORPO DC, DOC_TESTA DT
  WHERE
    DC.DOC_TESTA_ID = DT.ID
    AND DC.ARTICOLO_ID = :ID
    AND DT.DATA >= :DaData
    AND DT.DATA <= :AData
  GROUP BY
    DT.DEPOSITO_ID
)

How I can modify it?

Thanks.

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] How I can speed up this query

2017-10-14 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 13/10/2017 21.33, 'Daniel Miller' dmil...@amfes.com 
[firebird-support] ha scritto:


>
It would be interesting to compare the plans for both your original
query syntax and Set's suggestion - see where the difference is.


Original:

PLAN (PNC2 NATURAL)
PLAN JOIN (PNC NATURAL, PNT INDEX (PN_TESTA_PK), C INDEX (PK_CLIENTI),
PNS INDEX (PN_SCADENZE_FK))

With Set suggestion:

PLAN (PNC2 NATURAL)
PLAN JOIN (PNC NATURAL, PNT INDEX (PN_TESTA_PK), C INDEX (PK_CLIENTI),
PNS INDEX (PN_SCADENZE_FK))

Thanks.
--

Luigi Siciliano
--



Re: [firebird-support] How I can speed up this query

2017-10-12 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 11/10/2017 20.38, setysvar setys...@gmail.com [firebird-support] ha 
scritto:
> I think this should give the same result as your query, whether or not
> it is any quicker, I simply do not know (but I would love to hear if it
> made any difference).

Your query is to slow, flamerobin tells 4.360s. :(
> PLAN (PNC2 NATURAL)
>
> seems to be your problem (PNC on the other hand, seems OK).
>
> Hence, if PARITA and/or SCADENZA are selective, I would recommend that
> you create an index for either or both of these fields. That way, I
> would assume your original query to become a lot quicker.
Ok, I create an index for PARTITA and SCADENZA fields for PNC and Your 
query speed up, Flamerobin now tells 0.060s :)

And, my query, now, flamerobin tells 0.045s :))

The secondary index are automatically maintained by server, is it right 
to do a periodically manually maintenance for it's?

Thanks
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] How I can speed up this query

2017-10-11 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

I have this query

SELECT
   ID,
   DENOMINAZIONE,
   SCADENZA,
   PARTITA,
   NUMERO_DOCUMENTO,
   DATA_DOCUMENTO,
   IMPORTO,
   IMPORTO - PAGATO AS RESIDUO,
   PAGATO,
   PAGAMENTO,
   SALDARE
from
(
SELECT
   C.ID,
   C.DENOMINAZIONE,
   PNS.SCADENZA,
   PNS.PARTITA,
   PNT.NUMERO_DOCUMENTO,
   PNT.DATA_DOCUMENTO,
   PNS.IMPORTO,
   COALESCE((SELECT
              SUM(PNC2.AVERE - PNC2.DARE)
                from
  PN_CORPO PNC2
    WHERE
  PNC2.PARTITA = PNS.PARTITA
  AND PNC2.SCADENZA = PNS.SCADENZA
  AND PNC2.SCADENZA IS NOT NULL
   ), 0) AS PAGATO,
   0.00 AS PAGAMENTO,
   '0' AS SALDARE
from
   PN_SCADENZE PNS,
   PN_CORPO PNC,
   CLIENTI C,
   PN_TESTA PNT
where
   PNS.PN_TESTA_ID = PNC.PN_TESTA_ID
   AND C.ID = PNC.CLIENTE_ID
   AND PNT.ID = PNS.PN_TESTA_ID
)

 From Statistics of Flamerobin:

Prepare time: 0.014s
Field #01: . Alias:ID Type:SMALLINT
Field #02: . Alias:DENOMINAZIONE Type:STRING(60)
Field #03: . Alias:SCADENZA Type:DATE
Field #04: . Alias:PARTITA Type:INTEGER
Field #05: . Alias:NUMERO_DOCUMENTO Type:STRING(20)
Field #06: . Alias:DATA_DOCUMENTO Type:DATE
Field #07: . Alias:IMPORTO Type:NUMERIC(18,4)
Field #08: . Alias:RESIDUO Type:NUMERIC(18,4)
Field #09: . Alias:PAGATO Type:NUMERIC(18,4)
Field #10: . Alias:PAGAMENTO Type:NUMERIC(18,2)
Field #11: . Alias:SALDARE Type:STRING(1)
PLAN (PNC2 NATURAL)
PLAN JOIN (PNC NATURAL, PNT INDEX (PN_TESTA_PK), C INDEX (PK_CLIENTI), 
PNS INDEX (PN_SCADENZE_FK))

Executing...
Done.
4684158 fetches, 0 marks, 0 reads, 0 writes.
0 inserts, 0 updates, 0 deletes, 3011 index, 2313903 seq.
Delta memory: 70560 bytes.
Total execution time: 1.608s
Script execution finished

How I can speed up it?
The time 1.608s if referred at only 300 rows fetched as defaults of 
flamerobin. In production I have 1157 rows affected (they grows rapidly) 
in near 6.20s.

Thanks

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] why I not get first row in procedure

2017-09-01 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Ok, I find my mistake:

It is necessary add a line SUSPEND after DO before the second FOR SELECT

like this:
FOR SELECT
   
   DO *SUSPEND*
  FOR SELECT
  

Thanks.
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] why I not get first row in procedure

2017-09-01 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

why I not get first row in this procedure:

SET TERM ^ ;
RECREATE PROCEDURE ESTRATTO_CONTO_prova (
     CONTO Char(5),
     CLIENTE Smallint,
     DATADAL DATE,
     DATAAL date )
RETURNS (
     ID Integer,
     DATA_REGISTRAZIONE Date,
     CAUSALE_ID Char(3),
     DATA_DOCUMENTO Date,
     NUMERO_DOCUMENTO Varchar(20),
     DESCRIZIONE_TESTA Varchar(120),
     DOC_TESTA_ID Integer,
     CONTO_ID Char(5),
     CLIFOR_ID Smallint,
     DARE CURRENCY_D,
     AVERE CURRENCY_D,
     SALDO CURRENCY_D,
     DESCRIZIONE_CORPO Varchar(120),
     PARTITA Integer,
     SCADENZA Date,
     DENOMINAZIONE Varchar(60),
     CAUSALE_DESCRIZIONE Varchar(80),
     CONTO_DESCRIZIONE Varchar(60) )
AS
DECLARE VARIABLE SOMMA float;
BEGIN

   SALDO = 0;

   FOR SELECT
     0,           /* PNT.ID, */
     :DATADAL,    /* PNT.DATA_REGISTRAZIONE, */
     NULL,        /* PNT.CAUSALE_ID, */
     :DATADAL,    /* PNT.DATA_DOCUMENTO, */
     NULL,        /* PNT.NUMERO_DOCUMENTO, */
     NULL,        /* PNT.DESCRIZIONE, */
     null,           /* PNT.DOC_TESTA_ID, */
     null,           /* PNC.CONTO_ID, */
     null,       /* IIF (PNC.CLIENTE_ID IS NOT NULL, 
PNC.CLIENTE_ID, PNC.FORNITORE_ID) AS "CLIFOR_ID", */
     COALESCE(SUM(PNC.DARE), 0),
     COALESCE(SUM(PNC.AVERE), 0),
     COALESCE(SUM(PNC.DARE - PNC.AVERE), 0) + :SALDO,
     'Riporto...',    /* PNC.DESCRIZIONE, */
     NULL,        /* PNC.PARTITA, */
     NULL,        /* PNC.SCADENZA, */
     NULL,        /* IIF (PNC.CLIENTE_ID IS NOT NULL, 
C.DENOMINAZIONE, F.DENOMINAZIONE) as DENOMINAZIONE, */
     NULL,        /* TC.DESCRIZIONE, */
     NULL     /* PDC.DESCRIZIONE */
   from
     PN_TESTA PNT
     JOIN PN_CORPO PNC on PNT.ID = PNC.PN_TESTA_ID
     LEFT JOIN CLIENTI C ON PNC.CLIENTE_ID = C.ID
     LEFT JOIN FORNITORI F ON PNC.FORNITORE_ID = F.ID
     LEFT JOIN TIPO_CAUSALI TC ON PNT.CAUSALE_ID = TC.ID
     LEFT JOIN PIANO_DEI_CONTI PDC ON PNC.CONTO_ID = PDC.ID
   WHERE
     PNC.CONTO_ID = :CONTO
     AND (((PNC.CLIENTE_ID IS NULL) AND (PNC.FORNITORE_ID IS NULL)) OR
  (IIF (PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, 
PNC.FORNITORE_ID) = :CLIENTE))
     AND DATA_REGISTRAZIONE < :DATADAL
   INTO
     :ID,
     :DATA_REGISTRAZIONE,
     :CAUSALE_ID,
     :DATA_DOCUMENTO,
     :NUMERO_DOCUMENTO,
     :DESCRIZIONE_TESTA,
     :DOC_TESTA_ID,
     :CONTO_ID,
     :CLIFOR_ID,
     :DARE,
     :AVERE,
     :SALDO,
     :DESCRIZIONE_CORPO,
     :PARTITA,
     :SCADENZA,
     :DENOMINAZIONE,
     :CAUSALE_DESCRIZIONE,
     :CONTO_DESCRIZIONE

   DO
   FOR SELECT
     PNT.ID,
     PNT.DATA_REGISTRAZIONE,
     PNT.CAUSALE_ID,
     PNT.DATA_DOCUMENTO,
     PNT.NUMERO_DOCUMENTO,
     PNT.DESCRIZIONE,
     PNT.DOC_TESTA_ID,
     PNC.CONTO_ID,
     IIF (PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, PNC.FORNITORE_ID) 
AS "CLIFOR_ID",
     PNC.DARE,
     PNC.AVERE,
     PNC.DARE - PNC.AVERE + :SALDO,
     PNC.DESCRIZIONE,
     PNC.PARTITA,
     PNC.SCADENZA,
     IIF (PNC.CLIENTE_ID IS NOT NULL, C.DENOMINAZIONE, F.DENOMINAZIONE) 
as DENOMINAZIONE,
     TC.DESCRIZIONE,
     PDC.DESCRIZIONE
   from
     PN_TESTA PNT
     JOIN PN_CORPO PNC on PNT.ID = PNC.PN_TESTA_ID
     LEFT JOIN CLIENTI C ON PNC.CLIENTE_ID = C.ID
     LEFT JOIN FORNITORI F ON PNC.FORNITORE_ID = F.ID
     LEFT JOIN TIPO_CAUSALI TC ON PNT.CAUSALE_ID = TC.ID
     LEFT JOIN PIANO_DEI_CONTI PDC ON PNC.CONTO_ID = PDC.ID
   WHERE
     PNC.CONTO_ID = :CONTO
     AND (((PNC.CLIENTE_ID IS NULL) AND (PNC.FORNITORE_ID IS NULL)) OR
  (IIF (PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, 
PNC.FORNITORE_ID) = :CLIENTE))
     AND PNT.DATA_REGISTRAZIONE >= :DATADAL
     AND PNT.DATA_REGISTRAZIONE <= :DATAAL
   ORDER BY
     PNT.DATA_REGISTRAZIONE,
     PNT.ID,
     PNT.CAUSALE_ID,
     PNT.DATA_DOCUMENTO,
     PNT.NUMERO_DOCUMENTO
   INTO
     :ID,
     :DATA_REGISTRAZIONE,
     :CAUSALE_ID,
     :DATA_DOCUMENTO,
     :NUMERO_DOCUMENTO,
     :DESCRIZIONE_TESTA,
     :DOC_TESTA_ID,
     :CONTO_ID,
     :CLIFOR_ID,
     :DARE,
     :AVERE,
     :SALDO,
     :DESCRIZIONE_CORPO,
     :PARTITA,
     :SCADENZA,
     :DENOMINAZIONE,
     :CAUSALE_DESCRIZIONE,
     :CONTO_DESCRIZIONE

   DO SUSPEND;
END^
SET TERM ; ^

If I run the select separately I obtain the right result per select.

Thanks.

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual 

[firebird-support] Is it possible IF then statement in where clause?

2017-08-30 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

   I have a stored procedure that have two parameters: CONTO and CLIENTE 
because there is two values for CONTO that needs CLIENTE parameters, all 
other values of CONTO not needs CLIENTE.

I need to have a if statement in WHERE clause to add "AND IIF 
(PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, PNC.FORNITORE_ID) = 
:CLIENTE)" clause but it is not accepted, see:

I others word the "AND IIF (PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, 
PNC.FORNITORE_ID) = :CLIENTE)" will execute only for the two values of 
CONTO.

< snip>
   from

     PN_TESTA PNT
     JOIN PN_CORPO PNC on PNT.ID = PNC.PN_TESTA_ID
   WHERE
     PNC.CONTO_ID = :CONTO

   if :CLIENTE is not null then  <-- *IS NOT ACCEPTED*

     AND IIF (PNC.CLIENTE_ID IS NOT NULL, PNC.CLIENTE_ID, 
PNC.FORNITORE_ID) = :CLIENTE)



There's a solution?

Thanks.

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] "EXTRACT (YEAR FROM DT.DATA) <= 2016" or "DT.DATA <= '12/31/2016'"

2016-12-09 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

   what is more performant from subject?

I would prepare myself for a table that grows rapidly.

Is the same in FB 2.5.6 or 3.0.1?

Thanks
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Connecting to Firebird database from two or more pc with same username

2016-04-14 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hello,

Il 14/04/2016 09.26, 'Thomas Steinmaurer' t...@iblogmanager.com 
[firebird-support] ha scritto:


I guess you mean with the same Firebird user name? Or are you using 
Windows trusted authentication?




Oops, sorry. I mean the same Firebird username.
I notice that in an LAN with three users, all users was authenticated 
with the same Firebird username at the same time!
I did not notice any malfunction, but I doubt that it is not safe and is 
the bearer of impending problems on the data.


In general this is fine of course, even many people are using SYSDBA 
for regular connects, although this is not a good idea from a security 
perspective.




Ok but, as you say, and if I understand correctly, it is safe and 
Firebird is imperishable its data, even if it gets the data from 
different PCs at the same time and with the same FB user name. It's right?



With a single user you basically can't distinguish people on the 
server side through CURRENT_USER etc.




I have however, suggested to everyone to change this behaviour and 
connect to Firebird database with the username assigned them by the 
Database Administrator.


Thanks

--

Luigi Siciliano
--



[firebird-support] Connecting to Firebird database from two or more pc with same username

2016-04-14 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hello,
   If a user try to connect from two or more PC with same username, 
Firebird accepts the connection but is safe without problems or is best 
to avoid like the pest?

Thanks.
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] How write a query with a progressive sum field

2016-03-09 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 08/03/2016 20.36, setysvar setys...@gmail.com [firebird-support] ha 
scritto:
> This will not work properly if more than one row of DC are joined to 
> the same DT (but then your ORDER BY isn't 100% deterministic). If you 
> change the ordering of your query, you also have to change the 
> subselect (e.g. if you add DESC you have to change from > to <). If 
> this doesn't fit, is too slow or too difficult to understand, I'd 
> recommend EXECUTE BLOCK (as Sean already wrote). HTH,

Thank You, the query suggested works but because of the primary index of 
DOC_TESTA the value calculated of SALDO is not compliant with the result 
of the rows of the query.

I solved by creating a stored procedure like this:

AS
BEGIN
   SALDO = 0;

   FOR SELECT
 DT.DATA,
 DT.DOCUMENTO_ID,
 DT.NUMERO,
 DT.SERIE,
 DC.CARICO,
 DC.SCARICO,
 DC.CARICO - DC.SCARICO + :SALDO,
   from
 DOC_TESTA DT
 JOIN DOC_CORPO DC on DT.ID = DC.DOC_TESTA_ID
   WHERE
 DC.ARTICOLO_ID = :ID
   ORDER BY
 DT.DATA,
 DT.DOCUMENTO_ID,
 DT.NUMERO,
 DT.SERIE
   INTO
 :DATADOCUMENTO,
 :DOCUMENTO_ID,
 :NUMERO,
 :SERIE,
 :CARICO,
 :SCARICO,
 :SALDO,

   DO SUSPEND;
END^

Thanks to all :)
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] How write a query with a progressive sum field

2016-03-07 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Il 07/03/2016 17.28, Thomas Steinmaurer t...@iblogmanager.com 
[firebird-support] ha scritto:
> Although not that flexible as an ad-hoc query, but perhaps your
> particular use case can be achieved with a selectable stored procedure
> ...

Thank you Thomas, I modified my query like this:

select
DT.DATA,
   DT.DOCUMENTO_ID,
   DT.NUMERO,
   DT.SERIE,
   DC.CARICO,
   DC.SCARICO,
   SUM(dc2.carico - DC2.SCARICO) AS saldo
from
   DOC_TESTA DT
   JOIN DOC_CORPO DC on DT.ID = DC.DOC_TESTA_ID
   left JOIN DOC_CORPO DC2 ON (DC.DOC_TESTA_ID >= DC2.DOC_TESTA_ID)
AND 
(DC.ARTICOLO_ID = DC2.ARTICOLO_ID)
WHERE
DC.ARTICOLO_ID = :ID
GROUP BY
DATA,
   DOCUMENTO_ID,
   NUMERO,
   SERIE
ORDER BY
DATA,
   DOCUMENTO_ID,
   NUMERO,
   SERIE

but I have an issue:
if I have a row with CARICO = 0 and SCARICO = 0, SALDO is added or 
subtracted by the number present in last row with
CARICO > 0 or SCARICO > 0

if I add "(AND(DC.CARICO + DC.SCARICO) > 0) IN a LEFT JOIN I obtain 
almost correct result but the rows that contain "CARICO = 0 and SCARICO 
= 0" now contain SALDO = NULL, the others contains correct progressive sum.

What I'm wrong?

Thanks
-- 

Luigi Siciliano
--

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] How write a query with a progressive sum field

2016-03-07 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Il 07/03/2016 11.58, Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] ha scritto:
> sum(carcio-scarcio) over () as SALDO.

Ok, I understand but, "over" is unknow in firebird 2.5.5.

I modified my query like this:

select
DT.DATA,
DT.DOCUMENTO_ID,
DT.NUMERO,
DT.SERIE,
DC.CARICO,
DC.SCARICO,
SUM(dc2.carico - DC2.SCARICO) AS saldo
from
DOC_TESTA DT
JOIN DOC_CORPO DC on DT.ID = DC.DOC_TESTA_ID
left JOIN  DOC_CORPO DC2 ON (DC.DOC_TESTA_ID >= DC2.DOC_TESTA_ID)
 AND (DC.ARTICOLO_ID = DC2.ARTICOLO_ID)
WHERE
DC.ARTICOLO_ID = :ID
GROUP BY
   DATA,
   DOCUMENTO_ID,
   NUMERO,
   SERIE
ORDER BY
DATA,
DOCUMENTO_ID,
NUMERO,
SERIE

but I have an issue:

if I have a row with CARICO = 0 and SCARICO = 0

then SALDO is added or subtracted of number present in last row with 
CARICO > 0 or SCARICO > 0

Thanks
-- 

Luigi Siciliano
--



Re: [firebird-support] How write a query with a progressive sum field

2016-03-07 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 07/03/2016 11.32, Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] ha scritto:
> sum(saldo) over (order by data) 

Thank You for your response but I can't do: sum(SALDO) because SALDO is 
not a field of my table.

I badly explained myself: I have a table with only this fields:

DATA DOCUMENTO_ID   NUMERO   SERIE  CARICO   SCARICO


I need add SALDO fields in the result of the query to get a progressive 
sum of CARICO - SCARICO.

Thanks

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] How write a query with a progressive sum field

2016-03-07 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
   I need to write a query with a computed field that contain a 
progressive sum like this table:

DATA DOCUMENTO_ID   NUMERO   SERIE  CARICO   SCARICO   SALDO
01/01   A  1 A  
10 1
02/01   A  2  A  
30 4
02/01   V 33 B  
02 2
02/01   V 35 C  
01 1

I need to modify this query by adding SALDO field to get progressive sum 
of CARICO - SCARICO:
select
   DT.DATA,
   DT.DOCUMENTO_ID,
   DT.NUMERO,
   DT.SERIE,
   DC.CARICO,
   DC.SCARICO
from
   DOC_TESTA DT
   JOIN DOC_CORPO DC on DT.ID = DC.DOC_TESTA_ID
WHERE
   DC.ARTICOLO_ID = :ID
ORDER BY
   DATA,
   DOCUMENTO_ID,
   NUMERO,
   SERIE


How I do?

Thanks
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] RDB$FLAGS for trigger CHECK_XX in RDB$TRIGGERS is corrupted (304) Error in log file

2016-03-02 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
   in firebird v.2.5.5 log file I discovered this frequent error:

Database: PP
RDB$FLAGS for trigger CHECK_30 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_31 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_32 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_33 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_34 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_35 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_36 in RDB$TRIGGERS is corrupted (304)

What I will investigate?

Thanks

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] RDB$FLAGS for trigger CHECK_XX in RDB$TRIGGERS is corrupted (304) Error in log file

2016-03-01 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
  in firebird v.2.5.5 log file I discovered this frequent error:

Database: PP
RDB$FLAGS for trigger CHECK_30 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_31 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_32 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_33 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_34 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_35 in RDB$TRIGGERS is corrupted (304)
RDB$FLAGS for trigger CHECK_36 in RDB$TRIGGERS is corrupted (304)

What I will investigate?

Thanks
-- 
Luigi Siciliano
--






++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] SUM(DC.I) / SUM(DC.Q) vs SUM(DC.I / DC.Q) why result is different?

2016-02-29 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 29/02/2016 17.51, Fernando P. Nájera Cano y...@fernandonajera.com 
[firebird-support] ha scritto:
> When you do SUM(DC.I / DC.Q), the value of the division is calculated
> *per row*, and then those values are summed up.
>
> Fernando Nájera

Ok, now I understand.

Thank You
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] SUM(DC.I) / SUM(DC.Q) vs SUM(DC.I / DC.Q) why result is different?

2016-02-29 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 29/02/2016 15.31, Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] ha scritto:
> 29.02.2016 15:19, Luigi Siciliano luigi...@tiscalinet.it [firebird-support] 
> wrote:
>> What is the difference from "SUM(DC.I) / SUM(DC.Q)"
>> and "SUM(DC.I / DC.Q)"
> 1/2 + 1/4 <> 2/6.


I not understand,

I have this table (DC):

A_IDIQ
13701
23701

sum(DC.I) is = 740
and sum(DC.Q) is = 2
then 740/2 = 370

but
SUM(DC.I / DC.Q) it should be (740 / 2) = 370. Why not?

Why i am wrong?

Thanks
-- 

Luigi Siciliano
--

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] SUM(DC.I) / SUM(DC.Q) vs SUM(DC.I / DC.Q) why result is different?

2016-02-29 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
   I have, in DC table, two rows with same data:
A_IDI   Q
1   370 1
2   370 1

with this query:

SELECT FIRST 1
   DT.D as DCU,
   SUM(DC.I) / SUM(DC.Q) AS CU,
   (SELECT
  SUM(DC.I) / SUM(Q)
FROM
  DOC_C DC
WHERE
  DC.C > 0.00
  AND DC.A_ID = :ID
   ) AS CM
FROM
   DOC_C DC, DOC_T DT
WHERE
   DC.DOC_T_ID = DT.ID
   AND DC.C > 0.00
   AND DC.A_ID = :ID
GROUP BY
   DT.D
ORDER BY
   DT.D

I obtain correct result:
CU = 370
CM = 370

but with this query:

SELECT FIRST 1
DT.D as DCU,
SUM(DC.I / DC.Q) AS CU,
(SELECT
SUM(DC.I) / SUM(Q)
FROM
DOC_C DC
WHERE
DC.C > 0.00
AND DC.A_ID = :ID
) AS CM
FROM
DOC_C DC, DOC_T DT
WHERE
DC.DOC_T_ID = DT.ID
AND DC.C > 0.00
AND DC.A_ID = :ID
GROUP BY
DT.D
ORDER BY
DT.D


I obtain wrong result:
CU = 740
CM = 370


Why?

What is the difference from "SUM(DC.I) / SUM(DC.Q)"
and "SUM(DC.I / DC.Q)"

Thanks
-- 
Luigi Siciliano
--






++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] How to manage tribbers BeforeUpdate and AfterUpdate for same table

2016-01-25 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
   I Have a table with a column (TrigSign) that is a signal 
(programmatically setted without direct users interactions) for a 
BeforeInsert/Update trigger to do some updates in other table:
Example:
  If TrigSign = 0 do Nothing
  else If TrigSign = 1 do Something
  else if TrigSign = 2 do Somethings other, etc,

Somethings in others tables are to do only once even the user modify the 
rows of the table that contains TrigSign column or I run a 
storedprocedure that involves in fire the trigger.

I need setting TrigSign = 0 after run the BeforeInsert/Update trigger to 
prevent accidentally execution of the trigger.

How I can do this?
I need a After Insert/Update trigger? But in this case I implement a 
recursive loop Before-After Insert/Update Trigger?

Thanks
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Small Database with very very bad performance on LAN

2016-01-08 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 08/01/2016 16.30, Thomas Steinmaurer t...@iblogmanager.com 
[firebird-support] ha scritto:
> You have to sort out where your current bottleneck is.
>
> Can you pin-point it to a particular query or is performance in general
> bad? With Firebird 2.5, you have quite some monitoring amory, e.g.
> monitoring tables (tables starting with MON$...) or the Trace API.

The performance is bad in general, the navigation on a tables are too slow.

I find the problem, it's me that i used ZeosLib property "SortedFields" 
on a TQuery" component.

> Increase "Page buffers" to e.g. 1 (e.g. with gfix command-line
> tool), then re-connect your client application and see if this helps.
Before I Find the problem, seems not helps, it's a bit well but not helps.

> There is other tuning stuff,
I'm reading the Firebird Book written by Helen Borrie to understand the 
usage of FB but is hard reading over 1000 pages when the software must 
be ready for yesterday ;)

There are some other pages to read for undestrand the tuning of FB?

> getting a big picture on your slow statements, their
> execution plan probably pointing to missing indexes ... is a good start.

This helped me to find the problem.

> Good luck.

Thank you
-- 

Luigi Siciliano
--








++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Small Database with very very bad performance on LAN

2016-01-08 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,

Il 08/01/2016 16.22, Tim Ward t...@telensa.com [firebird-support] ha scritto:
> What are your queries, query plans, query statistics?

The queries are similar to: SELECT * FROM TABLE.

Investigating for query plans, statistics, Buffers as suggested by 
Thomas, I discovered the origin of the problem:
FB is innocent :) the guilty is me because I use ZEOSLib to connect to 
FB and I used the property "SortedFields" instead of using the clause 
"ORDER BY" in SQL query thinking that is more flexible on a Delphi RAD 
development like Delphi :(

Now the application seems faster and works best of the same application 
that use BDE :)

Thanks to all.

-- 

Luigi Siciliano
--








++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] Small Database with very very bad performance on LAN

2016-01-08 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
   I have a small database (less 100MB)  that works on Firebird 2.5.5 
SS64bit over a machine with Win7 64bit with 4GB Ram, CPU Pentium G620.

I seems to work very well in local but with the 3 clients on LAN works 
very bad. It is very very slow to open and navigate a simple table with 
less of 5.000 rows!

What i can do?

I very novice in Firebird.

The result of gstat is:
Database header page information:
 Flags   0
 Checksum12345
 Generation  26613
 Page size   4096
 ODS version 11.2
 Oldest transaction  26603
 Oldest active   26604
 Oldest snapshot 26604
 Next transaction26605
 Bumped transaction  1
 Sequence number 0
 Next attachment ID  139
 Implementation ID   26
 Shadow count0
 Page buffers0
 Next header page0
 Database dialect3
 Creation date   Jan 4, 2016 15:44:10
 Attributes  force write

 Variable header data:
 Sweep interval: 2
 *END*

Thanks

-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Small Database with very very bad performance on LAN

2016-01-08 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hallo,

Il 08/01/2016 14.20, Daniel Rail dan...@accra.ca [firebird-support] ha 
scritto:



Have you tried with SuperClassic or Classic? SuperServer 2.5.5 still



Ok, I tried SC and CS and the performance on LAN seems best of SS but 
not good :( May be the performance of CS is best of SC but seems very 
similar.


With CS or SC the performance are too slow for working, seems the same 
like the SS


The same application with BDE (Borland DataBase engine) works fast even 
in LAN but the application with firebird is tool slow even contain the 
same data!


Any other suggestion?

Thanks

--

Luigi Siciliano
--



[firebird-support] Numeration without hole, Is right Before Insert Trigger?

2015-12-22 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hello,
   I must assign a serial number, without hole, in a column of a fiscal 
document.
I must assign the number only when I know if the document is complete 
and I think the right moment is on a Before Insert Trigger for the table.

Is right or the insertion can fail? If not right, when I must assign the 
number to be sure of not have a hole in numeration?

Thanks
-- 

Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] Why during installation firebird.msg is not being copied in c:\windows?

2015-09-27 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hallo,
I installed FB 2.5.4 like by defaults. When I get an error (i.e. 
password incorrect) FB returns a Error message like this:

"SQL Error: Your user name and password are not defined. Ask your 
database administrator to set up a Firebird login.. Error Code: -902. 
can't format message 13:98 -- message file C:\WINDOWS\firebird.mgs not 
found"

Like suggested in this faq  if I 
manually copy the file "firebird.msg" located on directory where is 
installed FB (C:\Program files\firebird\firebird_2_5) the error not happens.

Why during installation this file is not copied in windows directory? 
This file is needed to copy to C:\WINDOWS only manually?

Thanks
-- 
Luigi Siciliano
--







++

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

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] There is a simple way to rename constraint that have not a name?

2015-01-30 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
There is a way to rename constraint that have not a name?

I have a database with a no name constraint primary key in many tables.

I learned my lesson and I would repair to this situation.

There is a simple way to assign a name to all no name constraints?

Like this statement:

UPDATE
   rdb$relation_constraints
SET
   rdb$constraint_name = 'MyPrimaryKeyName'
WHERE
   rdb$relation_name = MyTable
   AND rDB$CONSTRAINT_TYPE = 'PRIMARY KEY'

There are contraindications?

Thanks
-- 

Luigi Siciliano
--







++

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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

* To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

* Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] How to change Primary Key on a table by adding a new field

2015-01-27 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]

Hello Bogdan,
  thanks for your suggestion.

By ZeosLib TSQLProcessor, I try this:

--
SET TERM !!;
EXECUTE BLOCK RETURNS (stmt VARCHAR(1000)) AS
BEGIN
FOR
SELECT 'ALTER TABLE MYTABLE DROP CONSTRAINT ' ||
   rdb$constraint_name
from
  rdb$relation_constraints
where
  rdb$relation_name = MYTABLE
  AND rDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
into :stmt
DO begin suspend; execute statement :stmt; end
END!!

set term ; !!
---

seems to work but not commit the statement. The primary Key is yet 
present :(


Where I have a mistake?

Thanks


Il 26/01/2015 19.49, 'Bogdan Mihalache' bogdan.mihala...@soter.ro 
[firebird-support] ha scritto:


Select trim(RC.RDB$INDEX_NAME)
from RDB$RELATION_CONSTRAINTS RC
where (RC.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY') and
(RC.RDB$RELATION_NAME = :TABELA)
into :PKTEMP

Using that select you can fiind the name of the column who has the primary
key.
Inspired from Carlos Cantu external log procedure. Maybe you can be 
inspired

to.

-Original Message-
From: firebird-support@yahoogroups.com 
mailto:firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com 
mailto:firebird-support@ya%0Ahoogroups.com]

Sent: Monday, January 26, 2015 8:06 PM
To: firebird-support@yahoogroups.com 
mailto:firebird-support@yahoogroups.com
Subject: [firebird-support] How to change Primary Key on a table by 
adding a

new field

Hello,
I have an application that use a Firebird database and I need to
change a Primary Key on a table by adding a new field.

I can drop a primary key constraint by ALTER TABLE MyTable DROP
CONSTRAINT MyINTEG_000 where MyINTEG_000 is the constraint on my
development database file.

I cannot use the instruction above because I don't know in all
production databases of my customers the name of the Primary Key I want
update.

How I can solve?

Thanks.
--

Luigi Siciliano
--





++# 43;+++

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





--

Luigi Siciliano
--



[firebird-support] How to change Primary Key on a table by adding a new field

2015-01-26 Thread Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
Hello,
   I have an application that use a Firebird database and I need to 
change a Primary Key on a table by adding a new field.

I can drop a primary key constraint by ALTER TABLE MyTable DROP 
CONSTRAINT MyINTEG_000 where MyINTEG_000 is the constraint on my 
development database file.

I cannot use the instruction above because I don't know in all 
production databases of my customers the name of the Primary Key I want 
update.

How I can solve?

Thanks.
-- 

Luigi Siciliano
--







++

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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

* To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

* Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] How merge two queries

2014-09-10 Thread Luigi Siciliano luigi...@tiscalinet.it [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 DT.DATA_DOCUMENTO) = 2013
   AND DC.VOCE_ID = V.ID
   AND V.CONTRIBUTI = 1
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)


Second (results: ANNO, IMPOSTA):
select
   EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO,
   SUM(DC.IMPORTO) AS IMPOSTA
from
   DOC_CORPO DC,
   DOC_TESTA DT
WHERE
   DT.ID = DOC_TESTA_ID
   AND DT.DOCUMENTO_ID  'PRO'
   AND EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) = 2013
   AND DC.VOCE_ID = 'ENPACL'
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)

There is a way to merge those two queries to obtain the same result in 
one query that results: ANNO, IMPONIBILE, IMPOSTA?

Thanks.

-- 

Luigi Siciliano
--







++

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

* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

* To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

* Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/