pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frost, Mr. Michael (contractor) <frost@nrlmry.navy.mil>
To: pgsql-interfaces@postgresql.org
Subject: ECPG and CURSOR declaration
Date: Wed, 12 Jan 2005 08:04:24 -0800
Message-ID: <5188F15076BC7A4DBB705747602058C11AA6D1@mailhost> (raw)

Hi All.  The following code compiles and works fine on 7.3.  However,
with 7.4 it doesn't make it through the compiler.  With 7.4 it seems to
want the cursor declare to be in the same subroutine as the fetch.

========================================================================
===========
#include <stdio.h>

void driver ( ) {
  void prepareIt ( char * );
  EXEC SQL BEGIN DECLARE SECTION;
      char sElect_G[2048];
      long lSubCenter_L, lProductionCenter_L, lModel_L, lGrid_L;
      char szModelName_L[64];
      char szProductCenterName_L[64];
  EXEC SQL END DECLARE SECTION;

  sprintf ( sElect_G, "SELECT %s %s FROM MDGRIDModels, MDGRIDProdCenters
WHERE MDGRIDModels.centerID = MDGRIDProdCenters.centerID AND
MDGRIDModels.subcenterID = MDGRIDProdCenters.subcenterID",
            "MDGRIDModels.centerID, MDGRIDModels.subcenterID,",
            "generatingProc, gridID, modelName, productionCenter");

  prepareIt ( sElect_G );

             EXEC SQL FETCH CUR4LL INTO :lProductionCenter_L,
                              :lSubCenter_L,
                              :lModel_L,
                              :lGrid_L,
                              :szModelName_L,
                              :szProductCenterName_L;


}

void prepareIt ( char *myString ) {
  EXEC SQL BEGIN DECLARE SECTION;
      char sElect_G[2048];
  EXEC SQL END DECLARE SECTION;


   EXEC SQL PREPARE sQLstatement FROM :sElect_G;
   EXEC SQL DECLARE CUR4LL CURSOR FOR sQLstatement;
   EXEC SQL OPEN CUR4LL;

}
========================================================================
=========


Thanks,
Michael Frost

Attachments:

  [application/x-pkcs7-signature] smime.p7s (3.8K, ../5188F15076BC7A4DBB705747602058C11AA6D1@mailhost/2-smime.p7s)
  download

view thread (2+ messages)  latest in thread

Message-ID: <5188F15076BC7A4DBB705747602058C11AA6D1@mailhost>
Permalink:  ../5188F15076BC7A4DBB705747602058C11AA6D1@mailhost/
Also on:    postgresql.org/message-id/5188F15076BC7A4DBB705747602058C11AA6D1@mailhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: frost@nrlmry.navy.mil
  Subject: Re: ECPG and CURSOR declaration
  In-Reply-To: <5188F15076BC7A4DBB705747602058C11AA6D1@mailhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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