"EXEC SQL DESCRIBE SELECT LIST" returns "Specified partition does not exist"

From: Jan <jan_newsgroup_at_yahoo.de>
Date: 20 Feb 2004 10:50:56 -0800
Message-ID: <1bfbfe4b.0402201050.5aebc75f_at_posting.google.com>


I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the database table, using dynamic sql.

Executing 'EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;' the error code -2149 is returned That means "Specified partition does not exist".

Does anybody know if it is a database problem or a problem of precompilation?

I use the follwing arguments for precompilation: PARSE=NONE VARCHAR=YES CODE=CPP FIPS=YES MODE=ANSI LINES=YES OBJECTS=NO PROGRAM till DECSCRIPE SELECT LIST:

/* getting the command from the database with embedded SQL

  • and executing the command with dynamic SQL */ QtStringData* DBCatalogAccess::execCommand(const char* command) throw (r_Error) { const int alias_len = db->alias_len; const int description_len = 255;

/* Maximum length of dynamic sql statement.

     It must be the same as len(dyn_statement) */   const int sql_com_len = 1024;

/* Definitons for dynamic sql*/
/* Maximum number of select-list items or bind variables. */
  const int max_items = 40;

/* Maximum lengths of the _names_ of the select-list items

     or indicator variables                                 */
  const int max_vname_len = 30;
  const int max_iname_len = 30;

/* Define NULL */

  const int nul = 0;

  //Declaration need to fetch the command   EXEC SQL BEGIN DECLARE SECTION;
  // Define a host structure for the output values   // of a SELECT statement
  struct comdat {
    char alias[20]; //alias_len
    char describtion[255]; //desciption_len     char sql_com[255]; //sql_com_len
  } comStruct;
  // Input host variables
  char *comInput;
  EXEC SQL END DECLARE SECTION;
  comInput = (char*) malloc(strlen(command));   strncpy(comInput, command, strlen(command));

  cout << "DBCatalogAccess::execCommand:Entered command name: " << command << endl << endl;
  //getting the command
  EXEC SQL SELECT alias, description, sqlcommand     INTO
    :comStruct
    FROM CATQUERY
    WHERE ALIAS=:comInput;
  //t->commit();
  cout << "Neues 1 " << endl;
  cout << "Errorcode: " << SQLCODE << endl;   // termnating if an error accures
  if (SQLCODE!=0)
    {

      //Fehler-Code muss noch an Anwender weitergeleitet werden.
      char* ret =  itoa(SQLCODE);
      
      return (new QtStringData
	      ("ORACLE ERROR; Modul: reladmin; Class: DBCatalogAccess;
Function: execCommand;"));

    }
  //Aufrufen des SQL-Befehls
  cout << "dbcatalogaccess.pc::execCommand:alias " << comStruct.alias << endl;

  /***********************************************************************************
   *Starting with dynamic sql
   ***********************************************************************************/
  EXEC SQL INCLUDE sqlda;
  EXEC SQL INCLUDE sqlca;

  EXEC SQL BEGIN DECLARE SECTION;
    char dyn_statement[1024];
    EXEC SQL VAR dyn_statement IS STRING(1024);   EXEC SQL END DECLARE SECTION;      SQLDA *bind_dp;
  SQLDA *select_dp;

/* Define a buffer to hold longjmp state info. */
  jmp_buf jmp_continue;

/* A global flag for hte error routine */
  int parse_flag = 0;

  cout << "DBCatalog::execCommand:Allocating descriptors" << endl;
/* Allocate memory for the select an bind descriptors. */
  if ((bind_dp = sqlaldt(SQL_SINGLE_RCTX, max_items, max_vname_len, max_iname_len)) == (SQLDA *) 0)

    return (new QtStringData("DBCatalogAccess::execCommand:Fehler beim Speicherallocieren für bind_dp"));

  if ((select_dp = sqlaldt(SQL_SINGLE_RCTX, max_items , max_vname_len, max_iname_len)) == (SQLDA *) 0)

    return (new QtStringData("DBCatalogAccess::execCommand:Fehler beim Speicherallocieren für select_dp"));

  select_dp->N = max_items;   

/* Allocate the pointers to the indicator variables and the actual
data. */
  int i;
  for(i = 0; i < max_items; i++)
    {

      bind_dp->I[i] = (short *) malloc(sizeof(short));
      select_dp->I[i] = (short *) malloc(sizeof(short));
      bind_dp->V[i] = (char *) malloc(1);
      select_dp->V[i] = (char *) malloc(1);
    }

/* setting dynamic statement */

  //dyn_statement = (char*) malloc(strlen(comStruct.sql_com));   cout << "SQL-statement: " << comStruct.sql_com << endl;   strncpy(dyn_statement, comStruct.sql_com, strlen(comStruct.sql_com));

/* Prepare the statement und declare the cursor */
  EXEC SQL PREPARE S FROM :dyn_statement;   EXEC SQL DECLARE C CURSOR FOR S;
/* Set the bind variables for any placeholders in the SQL statement.
*/
  bind_dp->N = max_items;
  EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;   cout << "DESCRIBE BIND VARIABLES; ErrorCode: " << SQLCODE << endl;
/* Set the maximum number fo array elements in the descriptor to the
number found. */
  bind_dp->N = bind_dp->F;

/* Get the value of each bind variable as a ...

  • C[i] contains the length of the bind variable name used in the SQL statement.
  • S[i] contains the actual name of the bind variable used in the SQL statement.
  • L[i] will contain the length of the data value entered.
  • V[i] will contain the address of the data value entered.
  • T[i] is always set to 1 because in this program data values for all bind
  • variables are stored as strings in the database.
  • I[i] will point to the indicator value, which is set to -1 when the bind variable value is "null". */ if (bind_dp->F > 0) { cout << "Bind variable found. Setting bind variable...";

      cout << "OK!" << endl;
    }
  else
    {
      cout << "No bind variable found" << endl;     }

  EXEC SQL OPEN C USING DESCRIPTOR bind_dp;

/* Set the select list items (output variables) in the select list*/
  select_dp->N = max_items;   

  EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;   cout << "DESCRIBE SELECT LIST; ErrorCode: " << SQLCODE << endl; Received on Fri Feb 20 2004 - 19:50:56 CET

Original text of this message