...

Поиск
Список
Период
Сортировка
От Warwick Johnston
Тема ...
Дата
Msg-id LAW2-F258gnLVLYwXA9000069a7@hotmail.com
обсуждение исходный текст
Список pgsql-bugs
Hi, Warwick Johnston here, and thanks in advance for any assistance you can
provide.

I'm trying to run postgresql, and am having trouble with the embedded c
compiler. First the facts: I'm running PostgreSQL 6.5.3 on
i686-pc-linux-gnu, compiled by gcc egcs-2.91.66, as stated by the version
information. I'm on a linux OS, and postgres came with Linux 6.2. Following
the directions in the online book accessible from the
http://www.postgresql.org/docs/aw_pgsql_book/node189.html website, and using
a program detailed later, I have come unstuck when trying to precompile the
source code.

when i type ecpg temp.pgc
the system responds
Error: Cannot open include file sqlca in line 29

at line 29 is the command
EXEC SQL INCLUDE sqlca ;

the C libraries stdlib.h, stdio.h, and string.h have been included.
the sqlca.h file is located in directory /usr/include/pgsql/sqlca.h

YOu may also be interesed to know that if I remove the leading whitespace
before the colon in line 29, ie
EXEC SQL INCLUDE sqlca;

the error message becomes
in line 29ot open include file sqlca;

This is all extremely frustrating as I cannot continue to debug my code
before I get rid of this error.

This is the file I am trying to precompile. Obviously I don't want you to
debug it for me, I thought it may help you, that's all:
temp.pgc


/*
* A simple Embedded SQL example using the banking_example database
* described in Database System Concepts by Silberschatz, Korth and
* Sudarshan.
*
* Written by:  Evan Harris <evan@cs.mu.oz.au>
* Last update: 27 April 1998
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "/usr/include/sys/socket.h"  /* for lcompat lks */
#include "/usr/include/pgsql/sqlca.h"


/*
* These lengths must be the length of the string defined in the
* database schema + 1 for the null (string terminating) character.
*/
#define ACCOUNT_NUMBER_LENGTH 16
#define BRANCH_NAME_LENGTH 31

/*
* Some instructions to SQL about error messages and error conditions.
* Be sure to include this.
*/
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR STOP;


int
main(int argc, char** argv)
{
    /*
     * All variables (and their corresponding structures) that will be
     * used by SQL.
     *
     * If it is used (preceded by a colon), it must be declared here.
     */
    EXEC SQL BEGIN DECLARE SECTION;

    struct
    {
    char pname[MAX_NAME_LENGTH];
    char pinit;
    int ffnum;
    char suburb[MAX_NAME_LENGTH];
    }
    passenger_record;

    int minimum_balance = 0;
    char arg[80];

    /*
     * This indicates whether any of the returned structure values are NULL.
     * There must be one element for each field.
     */
    short null_indicator[3];

    EXEC SQL END DECLARE SECTION;


    /*
     * Parse any program arguments.
     */
    if (argc == 2)
    {
    strcpy(arg, argv[1]);
    }
    else if (argc > 2)
    {
    fprintf(stderr, "Usage: %s Branch-name", argv[0]);
    exit(EXIT_FAILURE);
    }

    printf("%s", arg);
    /*
     * Declaring a cursor allows us to step through the result tuples
     * of a query one at a time.  The query may also have GROUP BY,
     * HAVING, etc., clauses.
     *
     * Note that the cursor variable can not be named "cursor" because
     * the embedded SQL compiler confuses it with the CURSOR keyword.
     */
    EXEC SQL DECLARE cursor1 CURSOR FOR
    select name, m.descript as WLAN, n.descript as GPS
    from mapping m, mapping n, person p, locat l, locat lo
    where p.id = l.id
    and l.coord = m.coord
    and l.method = 'WLAN'
    and p.id = lo.id
    and lo.coord = n.coord
    and lo.method = 'GPS';

    /*
     * We must connect to the database that we will be accessing.
     */
    EXEC SQL CONNECT locationDB;


    /*
     * This is a trivial example of how to use the cursor facility.
     *
     * sqlca.sqlcode, the error code, is 0 providing an error
     * (including EOF) has not occurred.  That is, more tuples are
     * available for reading from the cursor.
     *
     * We assume that the meaning of sqlca.sqlcode != 0 is similar to
     * "EOF" of C.
     */
    EXEC SQL OPEN cursor1;
    EXEC SQL CLOSE cursor1;

    /*
     * If we wished we could now open the cursor again.  If we did so
     * after changing the value of the "minimum_balance" variable, we'd
     * get a different set of tuples back.
     */

    /*
     * We must disconnect from the database before finishing.
     */
    EXEC SQL DISCONNECT;

    exit(EXIT_SUCCESS);
}

Thanks for your help.
_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Rainer Mager"
Дата:
Сообщение: Postgres 7 pgdump problems with views
Следующее
От: mohamed hgug
Дата:
Сообщение: bug with postgresql