473,734 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ECPG - bug in EXEC SQL WHENEVER NOT FOUND?

Today I ran into problems when combining a C program with SQL statements
with the ECPG interface of PostgreSQL:

According to the documentation, it should be possible with
EXEC SQL WHENEVER NOT FOUND action
to trigger an action when a query does not return a row.

This does not seem to function. Here is the C program I tested:

----------------------------------------------------------------
/* Test for ecpg interface */
/* An empty table
t (n INTEGER);
must exist in the database
*/
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
int i;
EXEC SQL END DECLARE SECTION;
int main ()
{ int c;
ECPGdebug(1,std out);
EXEC SQL WHENEVER SQLERROR SQLPRINT;
EXEC SQL WHENEVER NOT FOUND GOTO notfound;
EXEC SQL CONNECT TO unix:postgresql ://localhost/mydb USER rank;
EXEC SQL SELECT n INTO :i FROM t;
printf ("%d\n", i);
EXEC SQL DISCONNECT;
exit (0);
notfound:
printf ("no data found\n");
EXEC SQL DISCONNECT;
exit (0);
}
----------------------------------------------------------------

When running this program on an empty table t in the database, it produces:

[1116]: ECPGdebug: set to 1
[1116]: ECPGconnect: opening database mydb on <DEFAULT> port <DEFAULT>
for user rank
[1116]: ECPGexecute line 16: QUERY: select n from t on connection mydb
[1116]: ECPGexecute line 16: Correctly got 0 tuples with 1 fields
[1116]: raising sqlcode 100 in line 16, 'No data found in line 16.'.
0
[1116]: ecpg_finish: Connection mydb closed.

We can see that sqlcode is set correctly, but the jump to the C-label
notfound does not occur.

Is this a bug in ECPG or am I doing something wrong?

Thanks in advance for your help,
Christian Rank

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #1
0 2693

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2142
by: Slava Gorski | last post by:
Hi all, It seems that get diagnostics is not supported by ecpg in postgresql 7.3, I always get the following error when trying to use it: ERROR: parse error at or near "diagnostics" For example, the following code does not compile: #include <stdio.h>
2
2351
by: Thierry Missimilly | last post by:
Hi, I'm not sure it's a bug or it's normal, so i don't send it to pgsq-bugs. Well, i have written pgbench in PRO*C to have a common pgbench.pgc source for Postgres and Oracle. However, there are some differences between the Postgres Pro*c and Oracle Pro*c. So, i use #ifdef ORACLE #else #endif preprocessing instructions to
4
2341
by: Thierry Missimilly | last post by:
Hi, This is the wrong mailing list but I don't sent it to pgsql-bugs with success. ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings
3
2636
by: Carmen Gloria Sepulveda Dedes | last post by:
Hello. I have a problem with ecpg precompiler. In a code like: **** main() { .... some calls to EXEC SQL
3
2001
by: Lynn.Tilby | last post by:
The following program produces the output below... It is built with: vrfy_prob: vrfy_prob.cpg /usr/local/pgsql/bin/ecpg -I/usr/local/pgsql/include -o vrfy_prob.c vrfy_prob.cpg gcc -g${DEBUG} -I/usr/include/pgsql -o vrfy_prob -lm -lc -lecpg -lpq vrfy_prob.c I am not using a BEGIN/END block, though the error messages indicate that I am.
3
1410
by: Lynn.Tilby | last post by:
I am running 7.1.3... The docs for ecpg in 7.1.3 don't have the -e option in them! YET, ecpg -e WORKS!!! for solving the vacuum problem. Just WHAT does the -e option in ecpg do???? Thanks for the info... Lynn
0
1661
by: bmay2068 | last post by:
I'm currently trying to insert binary data into postgres using the ecpg interface and standard embedded sql. I have a table defined as... CREATE TABLE bintest ( fsize numeric, bindata bytea );
1
349
by: George Gensure | last post by:
I wanted to ask this on here before going any further. I've got functions that return rowsets, which from the psql shell require me to write selects with AS TBL( ... ) to define the return types. When I try to put a query together in ECPG to get values from these functions, I discovered some nasty ecpg behavior. EXEC SQL SELECT * FROM foo() AS TBL( c int );
0
1397
by: Valerie Schneider DSI/DEV | last post by:
Hi, I have a set of libraries and C/C++ programs with embedded access to a PG database. I'm using ecpg. I'm working on a Linux RedHat9 platform. Until now I was in PG 7.4.2 : $ ecpg --version ecpg (PostgreSQL 7.4.2) 3.1.1 $ g++ --version g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.