[firebird-support] Re: EXECUTE STATEMENT ON EXTERNAL 'ODBC://odbc_datasource_name'

2014-08-30 Thread Dmitry Yemanov dim...@users.sourceforge.net [firebird-support]
30.08.2014 14:25, bert_herngr...@yahoo.com wrote:

 Should the Execute statement work on an ODBC datasource already with FB 3.0?

No.

 The ability to access foreign database engines using providers should
 not be overlooked, either. It might seem
 strange to consider this, given the number of tools available for this
 sort of task. Think about the ability to
 access other Firebird databases using EXECUTE STATEMENT, that became
 available in Firebird 2.5. With
 a provider to ODBC or other common tool to access various data sources
 it is within reach to use EXECUTE
 STATEMENT to get direct access from procedures and triggers, to data
 from any database having a driver for the chosen access tool.

There are no providers developed for ODBC yet.


Dmitry





Re: [firebird-support] Re: execute statement

2012-08-10 Thread Milan Babuskov
Alexandre Benson Smith wrote:
 To achieve what he wants he will need to write an app (or stored 
 procedure, or whatever) that loops trough the fields and generate the 
 trigger PSQL code like

No need to write anything. In FlameRobin, you can right-click the table, 
select Generate code and then Create change trigger for table.

It will display a dialog to select the desired columns and it will 
generate to complete trigger code.

HTH

-- 
Milan Babuskov

==
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==



[firebird-support] Re: execute statement

2012-08-09 Thread Sergio
 EXECUTE STATEMENT is for executing queries only, your code is not just a 
 query as it contains an IF statement. I think for your purposes you need 
 to use EXECUTE BLOCK 
 http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-execblock.html

Thanks Mark!

Yes... I've been reading it before, but I didn't found any example similar of 
what I want to do...

Perhaps is no possible at all?

Anyway, I was inspired in a firebird FAQ

http://www.firebirdfaq.org/faq133/





Re: [firebird-support] Re: execute statement

2012-08-09 Thread Mark Rotteveel
On 9-8-2012 22:13, Sergio wrote:
 EXECUTE STATEMENT is for executing queries only, your code is not just a
 query as it contains an IF statement. I think for your purposes you need
 to use EXECUTE BLOCK
 http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-execblock.html

 Thanks Mark!

 Yes... I've been reading it before, but I didn't found any example similar of 
 what I want to do...

 Perhaps is no possible at all?

I think you need to create an EXECUTE BLOCK statement as text and then 
execute that using EXECUTE STATEMENT, however I am not actually sure if 
that would give you access to the NEW and OLD context tables.

 Anyway, I was inspired in a firebird FAQ

 http://www.firebirdfaq.org/faq133/

That is more an example of how you can use a query to write the trigger 
code, but the result of that query will still be the normal code inside 
the trigger.

Mark
-- 
Mark Rotteveel


Re: [firebird-support] Re: execute statement

2012-08-09 Thread Alexandre Benson Smith
Em 9/8/2012 17:19, Mark Rotteveel escreveu:
 I think you need to create an EXECUTE BLOCK statement as text and then
 execute that using EXECUTE STATEMENT, however I am not actually sure if
 that would give you access to the NEW and OLD context tables.

 Mark 

There is no way to access NEW and OLD context variables inside EXECUTE 
STATEMENT.

To achieve what he wants he will need to write an app (or stored 
procedure, or whatever) that loops trough the fields and generate the 
trigger PSQL code like


CREATE OR ALTER trigger tlm_maestro_au0 for tlm_maestro
active after update position 0 AS
declare variable loc_nuevo_id id;
declare variable loc_ejecutar descripcion_larga;
begin
 
 loc_nuevo_id = gen_id(gen_tlm_maestro_hist,1);

 insert into tlm_maestro_hist (id,modificado) values (:loc_nuevo_id, 
current_timestamp);


IF (new.Field1 is distinct from old.Field1) then
   update tlm_maestro_hist set Field1 = old.Field1 where ID = 
:Loc_Nuevo_ID;

IF (new.Field2 is distinct from old.Field2) then
   update tlm_maestro_hist set Field2 = old.Field2 where ID = :Loc_Nuevo_ID;

IF (new.Field3 is distinct from old.Field3) then
   update tlm_maestro_hist set Field3 = old.Field3 where ID = :Loc_Nuevo_ID;

end