[firebird-support] Re: object is in use

2014-08-19 Thread Dmitry Yemanov dim...@users.sourceforge.net [firebird-support]
18.08.2014 23:39, 'Carlos H. Cantu' wrote:

 LSSBcfs While this would avoid the error, you will not know when/if your 
 change will be applied.
 LSSBcfs A connection can hold an object in use for an indeterminant period 
 of time.

 Dmitry said to me sometime ago that procedures changes will be
 executed immediately and not get held. I tested and seems to be true
 (ie: wait behavior is different for such case).

It's not about when your DDL is applied but about the cached procedure 
BLR that is used by others. The changed (new) procedure BLR will be used 
by newly compiled statements immediately after your DDL has been 
executed. However, all already compiled statements will keep using the 
old procedure BLR until these statements are released.

So Sean is correct except that holding an object applies to particular 
statements, not a connection as a whole.


Dmitry








++

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] Re: Forced write, page size and buffer size

2014-08-19 Thread Dmitry Yemanov dim...@users.sourceforge.net [firebird-support]
18.08.2014 22:51, Aldo Caruso wrote:

 For reliability reasons, I decided to turn on forced writes on a
 database running on Linux.

What is FB architecture: SS / CS / SC? I suspect SS given your default 
cache size (2048 pages) but it's worth double checking.

 1) Does it makes sense to activate forced writes on Linux ?

It depends on what reliability means to you.

 2) Is increasing the page size the right approach to improve performance
 ? Which are the drawbacks of setting page size to 16K ?

The cost is a higher concurrency for the same pages under parallel load.

 3) The same question stands for cache pages: is it useful ( or has
 disadvantages ) to have so many cache pages as there are on disk pages (
 provided there is enough RAM size ) ?

It would surely not hurt.


Dmitry









++

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] Re: Is it possible to store firebird DB file on a NAS?

2014-08-19 Thread map...@gmail.com [firebird-support]
WD my Cloud it enables smb/cifs protocol so a network share can be mapped as 
drive  In Firebird 2.5.x is possible with
  
 RemoteFileOpenAbility 1 in the firebird.conf (With a few big warnings if you 
read the conf file)
 

 you need to take care only the Firebird server to have access to that NAS 
share (exclusive access)

 

 I recommend an usb3.0/thunderbolt ssd drive for io speed 
 If you follow this benchmark
 

 As you can see, performance with random IO operations shows ~8x better 
results for SSD drive. We knew from our experience with customers databases 
that SSD is 30-50% faster with real-word applications, but 8x increase is very 
high.
 
http://ib-aid.com/en/articles/firebird-performance-degradation-tests-myths-and-truth/
 
http://ib-aid.com/en/articles/firebird-performance-degradation-tests-myths-and-truth/
  


 



Re: [firebird-support] Re: object is in use

2014-08-19 Thread 'Carlos H. Cantu' lis...@warmboot.com.br [firebird-support]
DYdusnfs It's not about when your DDL is applied but about the cached procedure
DYdusnfs BLR that is used by others. The changed (new) procedure BLR will be 
used
DYdusnfs by newly compiled statements immediately after your DDL has been 
DYdusnfs executed. However, all already compiled statements will keep using the
DYdusnfs old procedure BLR until these statements are released.
DYdusnfs So Sean is correct except that holding an object applies to 
particular
DYdusnfs statements, not a connection as a whole.
DYdusnfs Dmitry

Thanks for clarification. I still wonder why the initial reporter said
the trick didn't work for him.

Carlos
Firebird Performance in Detail - http://videos.firebirddevelopersday.com
www.firebirdnews.org - www.FireBase.com.br

DYdusnfs 18.08.2014 23:39, 'Carlos H. Cantu' wrote:

 LSSBcfs While this would avoid the error, you will not know when/if your 
 change will be applied.
 LSSBcfs A connection can hold an object in use for an indeterminant period 
 of time.

 Dmitry said to me sometime ago that procedures changes will be
 executed immediately and not get held. I tested and seems to be true
 (ie: wait behavior is different for such case).




[firebird-support] Re: Is it possible to store firebird DB file on a NAS?

2014-08-19 Thread trsk...@yahoo.com [firebird-support]
Hi,Thanks for you reply.

If I understand correctly, WD Cloud come with password to access private folder.
So, I am planing to install FB server where NAS attached and set private folder 
in NAS, then map this folder as a network drive.

Other users, don't have direct access to this private folder. Accessing FB 
database is just the same with format comp name:network drive on NAS

With this setting, is this necessary to set RemoteFileOpenAbility = 1?

WD Cloud come with pre-installed harddisk, so I can't replace its disk.
I still have a doubt with this cloud, it got good reviewer by some webs, but 
got bad rating by users experiences.

Regards,
Anto



Re: [firebird-support] Forced write, page size and buffer size

2014-08-19 Thread Aldo Caruso aldo.car...@argencasas.com [firebird-support]

Sean,

  thanks for your answer.

Aldo

El 18/08/14 a las 15:59, 'Leyne, Sean' s...@broadviewsoftware.com 
[firebird-support] escibió:




 Given this scenario my questions are the following:

 1) Does it makes sense to activate forced writes on Linux ?

Different versions of Linux file systems provide better protection 
than others.


Personally, I believe that forced write = ON is necessary for all OS 
-- but I suspect that I am in the minority (some will swear they have 
never had a problem/db corruption, but I am too chicken to take the 
risk -- I like sleeping at night).


 2) Is increasing the page size the right approach to improve 
performance ?

 Which are the drawbacks of setting page size to 16K ?

There is no universally true answer, it depends.

 3) The same question stands for cache pages: is it useful ( or has
 disadvantages ) to have so many cache pages as there are on disk pages (
 provided there is enough RAM size ) ?

As long as you have the RAM there is no problem.

Sean






Re: [firebird-support] Forced write, page size and buffer size

2014-08-19 Thread Aldo Caruso aldo.car...@argencasas.com [firebird-support]

Rich,

I got the point: with forced writes off you can't be sure of when the 
data is sent to disk.
But, in that case, what is the point of turning it off ? If you must 
wait for the server shut down to be 100% sure that the data is written 
to disk, isn't the risk too high to have forced write off ?
I suspect that data is written to disk far before than the server shut 
down or a connection close, otherwise FB designers shoudn't leave forced 
write as an option, it should always be activated.


Aldo

El 18/08/14 a las 16:11, 'Saunders, Rich' greym...@mykolab.com 
[firebird-support] escibió:


On 2014-08-18 14:51, Aldo Caruso aldo.car...@argencasas.com
[firebird-support] wrote:
 After that I noticed that some massive updates ( 100K records ) took
 nearly 5 minutes, whereas with async writes it used to take 10 seconds.

Of course, we don't know how much work actually took place during that
10 second period when
forced writes were off. Could be that very little of the update was
actually on disk
at that point. So do you consider the massive update actually done at
that point?

Also while forced writes are off, when is all that 5 minutes worth of
work actually done? When the database is closed? When the server was
shut down? Thats's the problem with forced writes being off - you never
know.

--

Cheers!
Rich Saunders






Re: [firebird-support] Re: Forced write, page size and buffer size

2014-08-19 Thread Aldo Caruso aldo.car...@argencasas.com [firebird-support]
Dmitry,

   Your guess is correct: Super Server architecture.
   Reliability in this context means for me having no database 
corruption after a power failure or kernel panic.

Aldo Caruso

El 19/08/14 a las 06:12, Dmitry Yemanov dim...@users.sourceforge.net 
[firebird-support] escibió:
 18.08.2014 22:51, Aldo Caruso wrote:
 For reliability reasons, I decided to turn on forced writes on a
 database running on Linux.
 What is FB architecture: SS / CS / SC? I suspect SS given your default
 cache size (2048 pages) but it's worth double checking.

 1) Does it makes sense to activate forced writes on Linux ?
 It depends on what reliability means to you.

 2) Is increasing the page size the right approach to improve performance
 ? Which are the drawbacks of setting page size to 16K ?
 The cost is a higher concurrency for the same pages under parallel load.

 3) The same question stands for cache pages: is it useful ( or has
 disadvantages ) to have so many cache pages as there are on disk pages (
 provided there is enough RAM size ) ?
 It would surely not hurt.


 Dmitry





 

 

 ++

 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










++

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] Forced write, page size and buffer size

2014-08-19 Thread Aldo Caruso aldo.car...@argencasas.com [firebird-support]

Carlos,

I agree with you. The performance degradation was very high on an 
ext4 file system ( which has barrier enabled by default ). On the other 
hand, I found no noticiable performance degradation on an ext3 file 
system ( which has barrier disabled by default ).


Having barrier disabled on a server with an ext3 file system, does 
FW=ON improve reliability or is it useless ?


Aldo Caruso

El 18/08/14 a las 16:27, 'Carlos H. Cantu' lis...@warmboot.com.br 
[firebird-support] escibió:


Usually, if you turn FW = ON on Linux, and your filesystem has barrier
enabled, it will affect performance of batch updates really badly.

You would either accept the performance degradation, or disable one of
them (FW or barrier).

Carlos
Firebird Performance in Detail - http://videos.firebirddevelopersday.com
www.firebirdnews.org - www.FireBase.com.br

ACacacfs Hello,

ACacacfs For reliability reasons, I decided to turn on forced writes 
on a

ACacacfs database running on Linux.

ACacacfs After that I noticed that some massive updates ( 100K 
records ) took
ACacacfs nearly 5 minutes, whereas with async writes it used to take 
10 seconds.


ACacacfs One solution is, of course, disabling sync writes when doing 
massive
ACacacfs updates. Unfortunately not always massive updates are under 
database
ACacacfs admin control ( some end users actions can lead to massive 
updates,

ACacacfs indirectly, by means of triggers ).

ACacacfs Another aproach I tested was augmenting page size from its 
default
ACacacfs value ( 4 KB ) to its maximum allowed value ( 16 KB ). The 
speed was
ACacacfs notably enhaced ( 1 minute for the update + 10 seconds for 
the commit,
ACacacfs but sometimes 2 seconds for the update and 40 seconds for 
the commit).


ACacacfs It should be pointed out that 4 KB was fine, taking into 
account
ACacacfs record size ( max. 300 bytes ) and index max depth ( always 
 3 ).


ACacacfs Going one step further, I augmented cached pages from its 
default (
ACacacfs 2048 ) to 8192. Some small performance improvement was 
observed, but not
ACacacfs very significative. It shoud be noted also that, with a 16 
KB page size,
ACacacfs the database has 5700 pages on disk, so there are enough 
cache pages to

ACacacfs hold the entire database.

ACacacfs Given this scenario my questions are the following:

ACacacfs 1) Does it makes sense to activate forced writes on Linux ?
ACacacfs 2) Is increasing the page size the right approach to improve 
performance

ACacacfs ? Which are the drawbacks of setting page size to 16K ?
ACacacfs 3) The same question stands for cache pages: is it useful ( 
or has
ACacacfs disadvantages ) to have so many cache pages as there are on 
disk pages (

ACacacfs provided there is enough RAM size ) ?

ACacacfs Thanks in advance for any clue.
ACacacfs Aldo

ACacacfs 

ACacacfs 

ACacacfs 
++


ACacacfs Visit http://www.firebirdsql.org and click the Documentation 
item
ACacacfs on the main (top) menu. Try FAQ and other links from the 
left-side menu there.


ACacacfs Also search the knowledgebases at
ACacacfs http://www.ibphoenix.com/resources/documents/

ACacacfs 
++

ACacacfs 

ACacacfs Yahoo Groups Links






Re: [firebird-support] Forced write, page size and buffer size

2014-08-19 Thread 'Carlos H. Cantu' lis...@warmboot.com.br [firebird-support]













RE: [firebird-support] Forced write, page size and buffer size

2014-08-19 Thread 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]

 Afair, in previous talks, Ann suggested that if you have to choose one or
 another, choose FW ON.
 
 The best thing would be if someone could simulate some crashes (like power
 failure) in both configurations and report back about existence of corruption.

Unfortunately, it is not always possible for a simulation to catch all possible 
modalities.

The hard truth is that the only _absolute guarantee_ to prevent database 
corruption is FW = ON.


Sean



Re: [firebird-support] Re: object is in use

2014-08-19 Thread Hugo Eyng hugoe...@msn.com [firebird-support]

Hello.

Sorry, but I didn´t, yet,  understand why I can´t exceute an ALTER 
PROCEDURE without _*closing all conections and restarting the FB 
service.*__*

*_
I guess that the problem could be related to my application leaving some 
transaction, that uses the SP, without commit/rollback or something so. 
But I am not sure.


Win 2008 R2 enterprise 64bits
Dell PowerEdge R620
32gb RAM
FB 2.5.2
SuperClassic

I notice that i am not the only one facing this trouble: 
http://tracker.firebirdsql.org/browse/CORE-3108


Using and WAIT or NO WAIT Transaction, in my opinion, is not the answer, 
or at least no the best answer.


I tried to find 'who' or 'what' is using the STORED PROCEDURE while I am 
trying to excecute the ALTER, but I was

not able to do it.

Hugo

Em 19/08/2014 06:03, Dmitry Yemanov dim...@users.sourceforge.net 
[firebird-support] escreveu:

18.08.2014 23:39, 'Carlos H. Cantu' wrote:


LSSBcfs While this would avoid the error, you will not know when/if your 
change will be applied.
LSSBcfs A connection can hold an object in use for an indeterminant period of 
time.

Dmitry said to me sometime ago that procedures changes will be
executed immediately and not get held. I tested and seems to be true
(ie: wait behavior is different for such case).

It's not about when your DDL is applied but about the cached procedure
BLR that is used by others. The changed (new) procedure BLR will be used
by newly compiled statements immediately after your DDL has been
executed. However, all already compiled statements will keep using the
old procedure BLR until these statements are released.

So Sean is correct except that holding an object applies to particular
statements, not a connection as a whole.


Dmitry








++

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







--


Atenciosamente,

Hugo Eyng



[firebird-support] Re: object is in use

2014-08-19 Thread Dmitry Yemanov dim...@users.sourceforge.net [firebird-support]
19.08.2014 21:56, Hugo Eyng wrote:

 Sorry, but I didn´t, yet,  understand why I can´t exceute an ALTER
 PROCEDURE without _*closing all conections and restarting the FB
 service.*__*

You can.

 I notice that i am not the only one facing this trouble:
 http://tracker.firebirdsql.org/browse/CORE-3108

They use NOWAIT transactions, hence the issue.

 Using and WAIT or NO WAIT Transaction, in my opinion, is not the answer,
 or at least no the best answer.

Maybe not the best, but it works. Do you really need to resolve the 
issue or not?

 I tried to find 'who' or 'what' is using the STORED PROCEDURE while I am
 trying to excecute the ALTER, but I was not able to do it.

There are no ways to find that, except the low-level trickery with 
fb_lock_print.


Dmitry








++

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] Re: CrossTab Select

2014-08-19 Thread sremula...@bol.com.br [firebird-support]
Help my frields!

Re: [firebird-support] Re: CrossTab Select

2014-08-19 Thread Thomas Beckmann thomas.beckm...@assfinet.de [firebird-support]
Hard to help, when there's no question...

Looking back the thread, you got some answers but did not relate on them
in your following questions.

Does

select
  sum(iif(extract(weekday from t.DATAB) = 0, PRODUTO, 0)) as W0,
  sum(iif(extract(weekday from t.DATAB) = 1, PRODUTO, 0)) as W1,
  sum(iif(extract(weekday from t.DATAB) = 2, PRODUTO, 0)) as W2,
  sum(iif(extract(weekday from t.DATAB) = 3, PRODUTO, 0)) as W3,
  sum(iif(extract(weekday from t.DATAB) = 4, PRODUTO, 0)) as W4,
  sum(iif(extract(weekday from t.DATAB) = 5, PRODUTO, 0)) as W5,
  sum(iif(extract(weekday from t.DATAB) = 6, PRODUTO, 0)) as W6
from TABELAB t
where t.DATAB between date '23.06.2014' and date '28.06.2014'

what you expect (if you add HORA, you'll need to group by the other
columns)?

Thomas

Am 19.08.2014 21:36, schrieb sremula...@bol.com.br [firebird-support]:
  
 
 Help my frields!
 
 

-- 
Mit freundlichen Grüßen,

Thomas Beckmann
Diplom-Informatiker


Wielandstraße 14c • 23558 Lübeck
Tel +49 (22 25) 91 34 - 545 • Fax +49 (22 25) 91 34 - 604
Mail thomas.beckm...@assfinet.de mailto:thomas.beckm...@assfinet.de

ASSFINET-Logo

*ASSFINET Dienstleistungs-GmbH*
Max-Planck-Straße 14 • 53501 Grafschaft bei Bonn
i...@assfinet.de mailto:i...@assfinet.de • www.assfinet.de
http://www.assfinet.de/

Geschäftsführer: Dipl. Wirtschaftsinformatiker Marc Rindermann
Registergericht Koblenz HRB 23331

Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist
nicht gestattet.



RE: [firebird-support] CrossTab Select

2014-08-19 Thread 'Edward Mendez' emendez...@nc.rr.com [firebird-support]
I am I including the original question in case someone has better answer

 

I am assuming that if you have 2 produtos for the same time period that you 
will want both of them displayed in the same row like so “CEBOLA,AJO”.

 

SELECT HORA, COALESCE( LIST(SEG),0) seg, COALESCE( LIST(TER),0) ter, COALESCE( 
LIST(QUA),0) qua, COALESCE( LIST(QUI),0) qui, COALESCE( LIST(SEX),0) sex, 
COALESCE( LIST(SAB),0) sab, COALESCE( LIST(DOM),0)dom from (

Select HORA, produto, MAX(SEG) seg, MAX(TER) ter, MAX(QUA) qua, MAX(QUI) qui, 
MAX(SEX) sex, MAX(SAB) sab, MAX(DOM) dom from (

SELECT HORA, PRODUTO,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 0 THEN PRODUTO ELSE NULL 
END) SEG,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 1 THEN PRODUTO ELSE NULL 
END) TER,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 2 THEN PRODUTO ELSE NULL 
END) QUA,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 3 THEN PRODUTO ELSE NULL 
END) QUI,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 4 THEN PRODUTO ELSE NULL 
END) SEX,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB)  WHEN 5 THEN PRODUTO ELSE 
NULL END) SAB,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 6 THEN PRODUTO ELSE NULL 
END) DOM

FROM TABLEAB

WHERE TABLEAB.DATAB BETWEEN '06/22/2014'

  AND '06/28/2014' ) T1

GROUP BY PRODUTO, HORA ) T2

GROUP BY  HORA

 

Here is the data I am using for this example.

 

TABLEAB_IDDATAB HORA   PRODUTO

  06/22/2014 9:00:00 AMCEBOLA

  06/23/2014 9:00:00 AMCEBOLA

  06/24/2014 9:00:00 AMCEBOLA

  06/25/2014 9:00:00 AMCEBOLA

  06/26/2014 9:00:00 AMCEBOLA

  06/27/2014 9:00:00 AMCEBOLA

  06/28/2014 9:00:00 AMCEBOLA

  16/22/2014 9:10:00 AMCEBOLA

  26/25/2014 9:00:00 AMAJO

 

Below is the output

 

HORA|SEG|TER|QUA|QUI|SEX|SAB|DOM

09:00:00|CEBOLA|CEBOLA|CEBOLA|CEBOLA,AJO|CEBOLA|CEBOLA|CEBOLA

09:10:00|CEBOLA|0|0|0|0|0|0

 

If you want different produtos on different rows then run the query below;

 

SELECT HORA, COALESCE( LIST(SEG),0) seg, COALESCE( LIST(TER),0) ter, COALESCE( 
LIST(QUA),0) qua, COALESCE( LIST(QUI),0) qui, COALESCE( LIST(SEX),0) sex, 
COALESCE( LIST(SAB),0) sab, COALESCE( LIST(DOM),0) dom from (

SELECT HORA, PRODUTO,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 0 THEN PRODUTO ELSE NULL 
END) SEG,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 1 THEN PRODUTO ELSE NULL 
END) TER,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 2 THEN PRODUTO ELSE NULL 
END) QUA,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 3 THEN PRODUTO ELSE NULL 
END) QUI,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 4 THEN PRODUTO ELSE NULL 
END) SEX,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB)  WHEN 5 THEN PRODUTO ELSE 
NULL END) SAB,

   ( CASE EXTRACT(WEEKDAY FROM TABLEAB.DATAB) WHEN 6 THEN PRODUTO ELSE NULL 
END) DOM

FROM TABLEAB

WHERE TABLEAB.DATAB BETWEEN '06/22/2014'

  AND '06/28/2014' ) T1

GROUP BY PRODUTO, HORA

 

With the following output

 

HORA|SEG|TER|QUA|QUI|SEX|SAB|DOM

09:00:00|0|0|0|AJO|0|0|0

09:00:00|CEBOLA|CEBOLA|CEBOLA|CEBOLA|CEBOLA|CEBOLA|CEBOLA

09:10:00|CEBOLA|0|0|0|0|0|0

 

I hope this helps.

 

Thanks,

 

Ed Mendez

 

From: firebird-support@yahoogroups.com 
[mailto:firebird-support@yahoogroups.com] 
Sent: Wednesday, June 25, 2014 6:29 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] CrossTab Select

 

  

Partners'm racking my brain on a SQL code, does anyone could give a force 

I made the following SP

CREATE PROCEDURE PRODS(
PAC INTEGER)
RETURNS(
HOR TYPE OF HORA,
SEG TYPE OF DESCRICAO,
TER TYPE OF DESCRICAO,
QUA TYPE OF DESCRICAO,
QUI TYPE OF DESCRICAO,
SEX TYPE OF DESCRICAO,
SAB TYPE OF DESCRICAO,
DOM TYPE OF DESCRICAO)
AS
BEGIN
FOR SELECT HORA, (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO 
else 0 END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 
0 END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 0 
END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 0 
END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 0 
END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 0 
END), (CASE EXTRACT(WEEKDAY FROM TABELAB.DATAB) when 0 then PRODUTO else 0 END) 
from TABELAB
WHERE TABELAB.DATABBETWEEN '23.06.2014' AND '28.06.2014'
GROUP BY HORA, PRODUTO, DATAB


INTO HOR, :DOM, :SEG, :TER, :QUA, :QUI, :SEX, :SAB DO
SUSPEND; 

END

Correct Return

#Código


1

2

3

HORA  SEG   TERQUA   QUI
  SEX  SAB  DOM

09:00 CEBOLA  CEBOLA CEBOLACEBOLA  CEBOLA   
CEBOLA  0

09:10 CEBOLA  0 00  
0