[INTERFACES] Use ecpg
[INTERFACES] Use ecpg
От:
Margarita Barvinok <brita@math.lsa.umich.edu>
Дата:
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
#include
#include
#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)));
}
/* ******************************************************************* */
Re: [INTERFACES] Use ecpg
От:
James Thompson <jamest@math.ksu.edu>
Дата:
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
> 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)
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
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
Re: [INTERFACES] Use ecpg
От:
Michael Meskes <Michael_Meskes@usa.net>
Дата:
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!
Re: [INTERFACES] Use ecpg
От:
Michael Meskes <Michael_Meskes@usa.net>
Дата:
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!
Re: [INTERFACES] Use ecpg
От:
Margarita Barvinok <brita@math.lsa.umich.edu>
Дата:
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! >