pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[INTERFACES] Use ecpg
5+ messages / 3 participants
[nested] [flat]

* [INTERFACES] Use ecpg
@ 1999-01-28 15:16  Margarita Barvinok <brita@math.lsa.umich.edu>
  0 siblings, 2 replies; 5+ messages in thread

From: Margarita Barvinok @ 1999-01-28 15:16 UTC (permalink / raw)
  To: pgsql-interfaces


Hello All,

I just began to use postgresql-6.4.2 and ecpg (version: 2.4.4).
I try t precompile simple
code ( I took it from a book) and get this error message:
prog:17: parse error
Perhaps this is stupid error, but I have no idea what to do, because I
don't have good manual on Embedded SQL. Can I find somewhere
documentation on C-Embedded SQL?
Thanks, in advance, for any help.

-Margarita Barvinok

File prog:

/*  *********************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define FAILURE 1
#define SUCCESS 0
 
void printError(void);
 
/* define the communication region   */
EXEC SQL INCLUDE sqlca;
 
int main()
{
  /* set error handler to bail out if we can't connect */
  EXEC SQL WHENEVER SQLERROR
    {                                            /* LINE 17     */
    printError();
    return FAILURE;
    };
 
  /* Connect to the database  */
  EXEC SQL CONNECT USER "dba" IDENTIFIED BY "sql";
  printf("test");
  EXEC SQL DISCONNECT;
  return SUCCESS;
}
/*
* printError()
* function to print a description of any SQL errors
*/
void printError()
{
  static char buffer[200];
  printf("SQL error -- %s\n", buffer,
          sqlerror_message( &sqlca, buffer, sizeof(buffer)));
}

/* ******************************************************************* */








^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [INTERFACES] Use ecpg
@ 1999-01-28 16:36  James Thompson <jamest@math.ksu.edu>
  parent: Margarita Barvinok <brita@math.lsa.umich.edu>
  1 sibling, 1 reply; 5+ messages in thread

From: James Thompson @ 1999-01-28 16:36 UTC (permalink / raw)
  To: Margarita Barvinok <brita@math.lsa.umich.edu>; +Cc: pgsql-interfaces

On Thu, 28 Jan 1999, Margarita Barvinok wrote:

> 
> Hello All,
> 
> I just began to use postgresql-6.4.2 and ecpg (version: 2.4.4).
> I try t precompile simple
> code ( I took it from a book) and get this error message:
> prog:17: parse error
> Perhaps this is stupid error, but I have no idea what to do, because I
> don't have good manual on Embedded SQL. Can I find somewhere
> documentation on C-Embedded SQL?

I'm kinda in the same boat.  I've been using the Oracle Pro*C precompiler
manual.  I don't have the URL here at work but I found an online copy
using www.google.com

>   /* set error handler to bail out if we can't connect */
>   EXEC SQL WHENEVER SQLERROR
>     {                                            /* LINE 17     */
>     printError();
>     return FAILURE;
>     };
>  

I don't think this will work.  I think you need to define an action for
the ecpg parser.  I asked one of the authors about the sqlerror option and
here's a snippet from the e-mail I got this morning

<snip>


> interested in the actions to whenever sqlerror.  I tried to look in the
> preproc.y file but I have no idea what I'm looking at.  I saw a DO and
> a CALL but can't find out what they mean.

The following actions are defined:

continue
sqlprint
stop
goto label
go to label
do break
do function(parameter)
call function(parameter)

</snip>

For me, the best documentation has been the test progs bundled in the
postgresql distro.  From memory the location is

postgresql-6.4.2/src/interfaces/ecpg/test

or something like that. There are two test programs and a preformace
program.

Hope this helps.  I you'd be so kind, mail me and let me know how things
work out, I'm working on error handling tonight.

->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson    138 Cardwell Hall  Manhattan, Ks   66506    785-532-0561 
Kansas State University                          Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<







^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [INTERFACES] Use ecpg
@ 1999-01-28 18:58  Michael Meskes <Michael_Meskes@usa.net>
  parent: James Thompson <jamest@math.ksu.edu>
  0 siblings, 0 replies; 5+ messages in thread

From: Michael Meskes @ 1999-01-28 18:58 UTC (permalink / raw)
  To: James Thompson <jamest@math.ksu.edu>; +Cc: Margarita Barvinok <brita@math.lsa.umich.edu>; pgsql-interfaces

On Thu, Jan 28, 1999 at 10:36:30AM -0600, James Thompson wrote:
> On Thu, 28 Jan 1999, Margarita Barvinok wrote:
> 
> > 
> > Hello All,
> > 
> > I just began to use postgresql-6.4.2 and ecpg (version: 2.4.4).
> > I try t precompile simple

Strange. For some reason I've never seen the original mail. Seems that's
just another of those typical usa.net mail losses. Could someone please
forward it to me. Thanks.

> >   /* set error handler to bail out if we can't connect */
> >   EXEC SQL WHENEVER SQLERROR
> >     {                                            /* LINE 17     */
> >     printError();
> >     return FAILURE;
> >     };

Sorry, but that's incorrect syntax. What you want to do is:

func()
{
printError();
return FAILURE;
}

EXEC SQL WHENEVER SQLERROR DO func();

BTW there is a function defined in libecpg named sqlerror() that prints a
clear text error message.

> ...
> 
> For me, the best documentation has been the test progs bundled in the
> postgresql distro.  From memory the location is
> 
> postgresql-6.4.2/src/interfaces/ecpg/test

Yup.

Michael

-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net          | Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [INTERFACES] Use ecpg
@ 1999-01-29 06:20  Michael Meskes <Michael_Meskes@usa.net>
  parent: Margarita Barvinok <brita@math.lsa.umich.edu>
  1 sibling, 1 reply; 5+ messages in thread

From: Michael Meskes @ 1999-01-29 06:20 UTC (permalink / raw)
  To: Margarita Barvinok <brita@math.lsa.umich.edu>; +Cc: pgsql-interfaces

On Thu, Jan 28, 1999 at 10:16:00AM -0500, Margarita Barvinok wrote:
> 
> Hello All,
> 
> I just began to use postgresql-6.4.2 and ecpg (version: 2.4.4).

Oops, the original mail cam later than the reply. So I got it now. I will
answer later.

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael.Meskes@gmx.net          | Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [INTERFACES] Use ecpg
@ 1999-01-29 14:38  Margarita Barvinok <brita@math.lsa.umich.edu>
  parent: Michael Meskes <Michael_Meskes@usa.net>
  0 siblings, 0 replies; 5+ messages in thread

From: Margarita Barvinok @ 1999-01-29 14:38 UTC (permalink / raw)
  To: Michael Meskes <Michael_Meskes@usa.net>; +Cc: pgsql-interfaces


Thank you, Michael. There were syntax mistakes. 
Now I found sample programs and know correct syntax. 

-Margarita

On Fri, 29 Jan 1999, Michael Meskes wrote:

> On Thu, Jan 28, 1999 at 10:16:00AM -0500, Margarita Barvinok wrote:
> > 
> > Hello All,
> > 
> > I just began to use postgresql-6.4.2 and ecpg (version: 2.4.4).
> 
> Oops, the original mail cam later than the reply. So I got it now. I will
> answer later.
> 
> Michael
> -- 
> Michael Meskes                         | Go SF 49ers!
> Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
> Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
> Email: Michael.Meskes@gmx.net          | Use PostgreSQL!
> 






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~1999-01-29 14:38 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-01-28 15:16 [INTERFACES] Use ecpg Margarita Barvinok <brita@math.lsa.umich.edu>
1999-01-28 16:36 ` James Thompson <jamest@math.ksu.edu>
1999-01-28 18:58   ` Michael Meskes <Michael_Meskes@usa.net>
1999-01-29 06:20 ` Michael Meskes <Michael_Meskes@usa.net>
1999-01-29 14:38   ` Margarita Barvinok <brita@math.lsa.umich.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox