Questions tagged [ecpg]

ECPG - Embedded SQL in C for PostgreSQL

ECPG is an embedded SQL package in C for PostgreSQL.

Read more about ECPG on this page: http://www.postgresql.org/docs/9.4/static/ecpg.html

Read more general information about embedded SQL on this page: http://en.wikipedia.org/wiki/Embedded_SQL

28 questions
4
votes
3 answers

PostgreSQL ecpg program doesn't save changes to the database

I am using using postgresql server on my laptop, and trying to connect with the database through my C program, using epcg. I wrote the following commands to precompile, compile and run the my .pgc program. PRE-COMPIILE - epcg sql.pgc COMPILE - …
vidzi
  • 185
  • 2
  • 14
2
votes
1 answer

Postgres ECPG char[] vs. VARCHAR[]

We are using ECPG and host variables to connect to a postgres database. We're trying to understand when to use char[] vs VARCHAR[] as our host binding variable. The documentation doesn't provide any pros/cons or use-cases. For example: Given…
Stanton
  • 497
  • 3
  • 14
2
votes
1 answer

Postgresql mode INFORMIX or INFORMIX_SE

In PostgreSQL, with ecpg, there are two compatibility modes: INFORMIX, INFORMIX_SE. Is there a difference between INFORMIX setting mode and INFORMIX_SE setting mode? I do not see any detail about this Postgresql Doc Thanks.
toch
  • 67
  • 6
1
vote
0 answers

WHENEVER SQLERROR of postgresql causes INTO assignment to fail

This is a piece of ecpg code. When using fetch to traverse the data, because of the use of WHENEVER SQLERROR DO sqlerr(), if an error occurs, it will be judged by the sqlerr method that it is a 22002 error, and the error will be ignored and the…
kldd
  • 39
  • 5
1
vote
1 answer

ECPG invocation of stored procedure with an array argument

I have a ECPG client attempting to obtain data. It uses a a prepared statement with a subselect clause using a stored function "getsipid" that takes 4 arguments. I have had this working with the 4th argument declared as a simple varchar. I have…
Dave
  • 31
  • 3
1
vote
2 answers

How to call PostgreSQL function from C code (ECPG)?

We are porting Oracle Pro*C code to PostgreSQL ECPG. We had several Oracle stored procedures that were ported into PostgreSQL functions like: db1.update_some_logic(double precision, double precision, text, text) On the C file I've tried several…
1
vote
1 answer

PostgreSQL ECPG database connection issue

I am trying to connect to PostgreSQL database using ecpg program and I am getting below error. cc testecpg.c /tmp/ccSzqgA7.o: In function `main': testecpg.c:(.text+0x5d): undefined reference to `ECPGconnect' testecpg.c:(.text+0x62): undefined…
skotian
  • 45
  • 6
1
vote
1 answer

Converting SQLDA from DB2 to PostgreSQL

I have the following code that currently works against DB2. There's the SQLDA declaration... extern struct sqlca sqlca; struct{struct sqlda daNM; struct sqlvar vaNM[6]; } C_NM={"SQLDA ",280,6,6, 492, …
J. Allen
  • 602
  • 1
  • 7
  • 24
1
vote
2 answers

PostgreSQL ecpg: How to call function with several out parameters

Suppose I have stored function foobar: create or replace function foobar( out p_foo varchar, out p_bar varchar ) returns record as $func$ begin p_foo := 'foo'; p_bar := 'bar'; end; $func$ language plpgsql; What ist the idiomatic way to call…
Erich Kitzmueller
  • 36,381
  • 5
  • 80
  • 102
1
vote
1 answer

ecpg can't find includes unless executed from the directory containing the source files

ecpg can find EXEC SQL INCLUDE header files just fine when run from the directory containing the source, but not from any other directory. Here is an illustration. Successful compile: > ecpg -o dbconnect.c dbconnect.pgc Missing include parameter…
kithril
  • 1,183
  • 2
  • 12
  • 22
0
votes
2 answers

why does this error "LNK1104 cannot open file 'C:\Program Files\PostgreSQL\14\lib.obj" occur when I compiled a c project which created from ECPG file

I was trying to compile a c project in visual studio which generated by ECPG file then I got this error LNK1104 cannot open file 'C:\Program Files\PostgreSQL\14\lib.obj even though I added this line C:\Program Files\PostgreSQL\14\lib in Additional…
0
votes
1 answer

Unexpected output of embedded SQL program

I'm trying to implement an absolute basic toy example using ECPG to run an embedded SQL query in C. This is my code: int main() { EXEC SQL WHENEVER NOT FOUND DO BREAK; EXEC SQL BEGIN DECLARE SECTION; char v_country_iso2[2], v_name[32]; …
Christian
  • 3,239
  • 5
  • 38
  • 79
0
votes
0 answers

PostgreSQL executes select count(*) report ERROR: invalid value for parameter "client_encoding": "SJIS"

I use ecpg to query how many pieces of data there are in the table, the code is as follows EXEC SQL BEGIN DECLARE SECTION; long tblCnt; EXEC SQL END DECLARE SECTION; EXEC SQL SELECT COUNT(*) INTO :tblCnt FROM …
kldd
  • 39
  • 5
0
votes
1 answer

Error (sqlca.sqlcode == ECPG_DUPLICATE_KEY) Handling In Ecpg PostgreSQL

Need to handle a error while inserting records into table (Ecpg PostgreSQL), but job should not abort/commit/rollback if any duplicate record (Primary Key).Job should skip and continue for next. Note:SQL_CODE = sqlca.sqlcode if ( SQL_CODE == -403 )…
Munu
  • 103
  • 5
  • 15
0
votes
0 answers

PostgreSQL reports an error out of memory using EXEC SQL

I use EXEC SQL to execute a very long SQL (6000 characters) in PGC file, sometimes error SQLSTATE=[YE001] SQLERRM=[out of memory on line 400], sometimes it works fine. Use vmstat to view memory -------------memory---------- swpd free buff…
kldd
  • 39
  • 5
1
2