Re: Using embedded SQL.

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: "Robert J(dot) Sprawls" <sprawlsr(at)worldnet(dot)att(dot)net>
Cc: pgsql-general <pgsql-general(at)hub(dot)org>
Subject: Re: Using embedded SQL.
Date: 2000-06-05 15:37:17
Message-ID: 20000605173717.A3899@fam-meskes.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jun 03, 2000 at 05:37:32PM -0500, Robert J. Sprawls wrote:
> I'm trying to learn embedded SQL in C. However, it's not working
> and reading the documentation is not answering my question(s). Here is my

Please check the test cases in the source tree. They help a little bit.

> #include <stdlib.h>
> #include <stdio.h>
> exec sql include sqlca;
>
> int main( int argc, char *argv[] ) {
>
> exec sql whenever sqlerror sqlprint;
> exec sql connect tootle;

The correct syntax is

exec sql connect to tootle;

> exit( 0 );
> exec sql disconnect sprawlsr;

Sorry, I do not understand that line. At first your program will never
disconnect from that database since it exists before it can execute that
statement. And second you never connected to sprawlsr so how can you
dissconnect?

> }
>
> And here is what I get back:
>
> sql error Could not connect to database <DEFAULT> in line 25.
>
> What am I doing wrong? Yes, the database does exist as tootle.

Yup, that's one of those Oracle compatibility hacks. If you use connect
without 'to' ecpg expects the following term to a oracle like user
specification.

Michael
--
Michael Meskes
Michael(at)Fam-Meskes(dot)De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Meskes 2000-06-05 15:38:08 Re: Compiling Error
Previous Message Fernando Caamaño 2000-06-05 15:13:06 RE: a very big field