Skip site navigation (1) Skip section navigation (2)

Core dump when I run a program that uses embedded sql

From: "Ligia Pimentel" <lmpimentel(at)yahoo(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Core dump when I run a program that uses embedded sql
Date: 2001-08-29 16:08:24
Message-ID: 9mj7rp$14t2$1@news.tht.net (view raw or flat)
Thread:
Lists: pgsql-interfaces
Hello.
I'm using postgres 7.1, and I'm on my first try to use embedded sql. Here's
my problem.

I'm trying to use an example I copied from the web:

/**************************************************
   Example program
   for embedded SQL: tryit.pgc
 **************************************************/

#include <stdio.h>

EXEC SQL INCLUDE sqlca;

main () {
    EXEC SQL BEGIN DECLARE SECTION;
    int sup_id;
    int sales;
    int total;
    float price;
    VARCHAR cof_name[33];
    EXEC SQL END DECLARE SECTION;

    EXEC SQL CONNECT 'TarjetaDebito' ;
    if(sqlca.sqlcode) {
       printf("Error al connectar a la base de datos.\n");
      exit(0);
    }

    printf("Solicitud: ");
    scanf("%d", &sup_id);

    EXEC SQL SELECT nombreenplastico, correlativo INTO :cof_name, :price
                  FROM tarjeta WHERE correlativo = :sup_id ;
    if (sqlca.sqlcode==0) {
       printf("Result: %s tarjeta con solicitud  $%5.2f\n", cof_name.arr,
price);
    }
    else {
       printf("Error #%d: %s\n", sqlca.sqlerrm.sqlerrml,
sqlca.sqlerrm.sqlerrmc);
    }
}

Nothing fancy as you can see... (of course I changed the names of the tables
and the fields to be able to find them on my server).

Then I precompile it (ecpg ...) successfully, and after that I compile it
with gcc (also everything OK aparently), and when I try to run my program, I
get
SEGMENTATION FAULT (core dumped).

I don't know where to start. Could you help me?

Thank you.

Ligia Pimentel




Responses

pgsql-interfaces by date

Next:From: DI HasenöhrlDate: 2001-08-29 19:51:37
Subject: link tables from DB1 to DB2
Previous:From: Marc G. FournierDate: 2001-08-29 15:00:38
Subject: List archives moved and cleaned up ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group