ECPG and CURSOR declaration

From: "Frost, Mr(dot) Michael (contractor)" <frost(at)nrlmry(dot)navy(dot)mil>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: ECPG and CURSOR declaration
Date: 2005-01-12 16:04:24
Message-ID: 5188F15076BC7A4DBB705747602058C11AA6D1@mailhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Benno Pütz 2005-01-13 16:53:40 How to detect NULL in VarChar (C function)
Previous Message Bruce Momjian 2005-01-07 05:44:06 Re: ECPGstatus documentation