Subject | Re: [firebird-support] Aggregate UDF |
---|---|
Author | Alexandre Benson Smith |
Post date | 2004-02-27T22:43:49Z |
At 17:27 27/02/2004 -0500, you wrote:
if so....
try this...
I assume "Test" as table name and that bin_or UDF is declared in your
database...
set term ^;
create procedure sp_test returns (Document int, ResultAccess int) as
declare Access int;
begin
for select distinct Document from Test into :Document do begin
ResultAccess = 0;
for select distinct Access from Test where Document = :Document into
:Access do begin
ResultAccess = Bin_Or(ResultAccess, Access);
end
Suspend;
end
end^
set term ;^
commit;
select * from sp_test
DOCUMENT RESULTACCESS
======== ============
1 3
2 1
3 3
:)
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
----------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004
[Non-text portions of this message have been removed]
>Hello everybody.A Stored Procedure could be used ?
>...snip...
>But I need a way to obtain a bitwise addition instead of the arithmetical
>addition. (bitwise OR).
>Something like this: "SELECT DOCUMENT, BIT_OR(ACCESS) FROM TABLE"
>
>DOCUMENT ACCESS
> 1 3
> 2 1
> 3 3
>
>Does anyone know how to do this or how to write an aggregate UDF in
>Delphi/Kylix to accomplish it?
>
>Please your help.
if so....
try this...
I assume "Test" as table name and that bin_or UDF is declared in your
database...
set term ^;
create procedure sp_test returns (Document int, ResultAccess int) as
declare Access int;
begin
for select distinct Document from Test into :Document do begin
ResultAccess = 0;
for select distinct Access from Test where Document = :Document into
:Access do begin
ResultAccess = Bin_Or(ResultAccess, Access);
end
Suspend;
end
end^
set term ;^
commit;
select * from sp_test
DOCUMENT RESULTACCESS
======== ============
1 3
2 1
3 3
:)
>Thanks in advance.See You !
>
>Saludos,
>
>Eduardo Gamboa
>(Ecuador)
>
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
----------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004
[Non-text portions of this message have been removed]