Hi,

I solved...

To create a trigger we don't need to change term. Just query the trigger like:

snprintf(ptr_cinfo->createsubschema[3], QUERY_LEN,
       " CREATE TRIGGER T1_BI FOR TEST_DATATYPES ACTIVE BEFORE INSERT
       "POSITION 0"
       " AS"
       " BEGIN"
       " if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_T1_ID, 1);"
       " END");

Thanks.


2009/7/11 João Henrique Freitas <joa...@gmail.com>:
> Hi,
>
> I am trying to put firebird to work with new test framework.
>
> Anybody uses libdbi with firebird driver to create a trigger?
>
> I need to do:
>
>    snprintf(ptr_cinfo->createsubschema[2], QUERY_LEN, "set term !!");
>    snprintf(ptr_cinfo->createsubschema[3], QUERY_LEN,
>        " CREATE TRIGGER T1_BI FOR TEST_DATATYPES ACTIVE BEFORE INSERT
> POSITION 0"
>        " AS"
>        " BEGIN"
>        " if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_T1_ID, 1);"
>        " END!!");
>    snprintf(ptr_cinfo->createsubschema[4], QUERY_LEN, "set term ; !!");
>
>
> [in some other place]
>
>  for ( i = 0; strlen(cinfo.createsubschema[i]) != 0 ; i++ ) {
>    if ((result = dbi_conn_query(conn, cinfo.createsubschema[i])) == NULL) {
>      errnum = dbi_conn_error(conn, &errmsg);
>      printf("Can't create sub schema data (%d)! %s\n", i, errmsg);
>      my_dbi_shutdown(dbi_instance);
>      exit(1);
>    }
>    dbi_result_free(result);
>  }
>
>
> The question is simple: I need change the default term from ; to !!.
> In my tests I can't do it. How I can create this trigger using libdbi
> firebird driver?
>
>> I guess you're better off using separate calls and wrap them into
>> transactions.
>>
>
> Yes, this is the way.
>
> Thanks.
>
>
> --
> -----------------------------------------------------------
> João Henrique Freitas - joaohf_at_gmail.com
> Campinas-SP-Brasil
> BSD051283
> LPI 1
> http://www.joaohfreitas.eti.br
>



-- 
-----------------------------------------------------------
João Henrique Freitas - joaohf_at_gmail.com
Campinas-SP-Brasil
BSD051283
LPI 1
http://www.joaohfreitas.eti.br

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel

Reply via email to