Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Location
    Moscow
    Posts
    8

    Unanswered: How to get conn ptr in C-lang external function?

    Hi again )

    I have C-language external function in which I need to execute some SQL commands like SELECT\UPDATE\DELETE.

    To do this via libpq.dll I need *conninfo. Is there any way to get it inside the external function? Or may be is there any another way to execute some SQL commands inside the external C-language function?

  2. #2
    Join Date
    Jan 2008
    Location
    Moscow
    Posts
    8
    I solve it myself again. : )

    There is SPI (server programming interface) for these purposes.

    To execute an SQL command in external function u should first include "executor/spi.h", then
    Code:
    SPI_connect();
    SPI_execute(...);
    SPI_finish();
    And it should work... If only u will not get linker error as I do : (

    Code:
    trigf.obj : error LNK2001: unresolved external symbol _SPI_finish
    trigf.obj : error LNK2001: unresolved external symbol _SPI_execute
    trigf.obj : error LNK2001: unresolved external symbol _SPI_connect
    Looks like I miss some libraries or .def files...

  3. #3
    Join Date
    Jan 2008
    Location
    Moscow
    Posts
    8
    Last problem was solved after compiling postgres.lib from PostgreSQL sources and including it into library modules in project settings.

    Or it also can be solved using plpgsql.dll (from PostgreSQL binaries), but in this way u'll have to use LoadLibrary() and etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •