Sponsored Content
Top Forums Programming Problem FETCHing Long data type using CURSOR Post 302366365 by manbt on Thursday 29th of October 2009 10:14:51 AM
Old 10-29-2009
Problem FETCHing Long data type using CURSOR

Currently my Pro*c program is fetching a cloumn which is defined as LONG in oracle db. The data in the column is around 65k. But when I am FETCHing it to a varchar[200kb] variable, I am only getting 22751 bytes of data using cursor.

Is there any limitation on the data which is fetched by a cursor in pro*C or do I need to do some thing more in coding to get all 65k of data present in the table column.

RVSN_DESC_LEN = 200*1024+1;
ETT_RVSN_TEXT.RVSN_DESC column contains 65k size data

Here is the code snippet:
Code:
VARCHAR rvsnLablName[RVSN_LABL_NAME_LEN];
    short rvsnLablName_ind = 0;
    VARCHAR rvsnLablText[RVSN_LABL_TEXT_LEN];
    short rvsnLablText_ind = 0;
    VARCHAR rvsnDesc[RVSN_DESC_LEN];
    short rvsnDesc_ind = 0;
 
:
:
 
EXEC SQL END DECLARE SECTION;
  EXEC SQL WHENEVER SQLERROR GOTO error;
  EXEC SQL DECLARE sbdvRvsnDescInfoCur CURSOR FOR
 SELECT 
  ETT_CELL_HDR.CELL_HDR_CODE, 
  ETT_CELL_HDR.CELL_HDR_TTL, 
  ETT_RVSN_TEXT.RVSN_DESC
 FROM
  ETT_CELL_HDR,
  ETT_RVSN_TEXT
 WHERE
  ETT_RVSN_TEXT.GENL_ORD_ID = :genlOrdID_i AND
  ETT_CELL_HDR.CELL_HDR_ID = ETT_RVSN_TEXT.CELL_HDR_ID(+)
 ORDER BY 
  ETT_CELL_HDR.PRNT_SEQ_NBR, ETT_RVSN_TEXT.PRNT_SEQ_NBR;
  EXEC SQL OPEN sbdvRvsnDescInfoCur;
  EXEC SQL WHENEVER NOT FOUND DO break;
  i = 0;
  *rvsnDescInfo_iop = NULL;
  for (;;)
  {
#ifdef DEBUG
    fprintf(outFile_gp, "reallocing, i = %d\n", i);
    fprintf(outFile_gp, "sizeof(RvsnDescInfoType) = %d\n", sizeof(RvsnDescInfoType));
    fflush(outFile_gp);
#endif /* DEBUG */
    *rvsnDescInfo_iop = (RvsnDescInfoType*) realloc(*rvsnDescInfo_iop, 
    (i+1)*sizeof(RvsnDescInfoType));
    if (NULL == *rvsnDescInfo_iop)
    {
      fprintf(stderr, "db_retrieveAddRvsnDescInfo: realloc() failed. errno = %d\n", errno);
      fflush(stderr);
      return FAIL;
    }
    memset(&rvsnDescInfo_iop[0][i], '\0', sizeof(RvsnDescInfoType));
    EXEC SQL FETCH sbdvRvsnDescInfoCur
    INTO
 :rvsnLablName:rvsnLablName_ind,
 :rvsnLablText:rvsnLablText_ind,
 :rvsnDesc:rvsnDesc_ind;
    rvsnLablName.arr[rvsnLablName.len] = '\0';
    rvsnLablText.arr[rvsnLablText.len] = '\0';
    if (rvsnDesc.len < RVSN_DESC_LEN)
    {
      rvsnDesc.arr[rvsnDesc.len] = '\0';
    }
    else
    {
      rvsnDesc.arr[RVSN_DESC_LEN - 1] = '\0';
    }

#ifdef DEBUG
    fprintf(outFile_gp, "rvsnLablName.len = %d\n", rvsnLablName.len);
    fprintf(outFile_gp, "rvsnLablText.len = %d\n", rvsnLablText.len);
    fprintf(outFile_gp, "rvsnDesc.len = %d\n", rvsnDesc.len);
    fflush(outFile_gp);
#endif /* DEBUG */
    if (-1 != rvsnLablName_ind)
      strcpy(rvsnDescInfo_iop[0][i].rvsnLablName, rvsnLablName.arr);
    else
      strcpy(rvsnDescInfo_iop[0][i].rvsnLablName, " ");
    if (-1 != rvsnLablText_ind)
      strcpy(rvsnDescInfo_iop[0][i].rvsnLablText, rvsnLablText.arr);
    else
      strcpy(rvsnDescInfo_iop[0][i].rvsnLablText, " ");
    if (-1 != rvsnDesc_ind)
      strcpy(rvsnDescInfo_iop[0][i].rvsnDesc, rvsnDesc.arr);
    else
      strcpy(rvsnDescInfo_iop[0][i].rvsnDesc, " ");
    i++;
  }
  EXEC SQL CLOSE sbdvRvsnDescInfoCur;
  return i;

When I display rvsnDesc.arr, I get 22751 as size.

Any help in this issue will be highly appreciated.

Thanks!

Last edited by pludi; 10-29-2009 at 11:31 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. Programming

enable 64bit long type for gcc

hey, I believe I once saw a post in this forum, about enable an GCC option to enable long types. I simply cannot find it any more. Can anybody give me a hint? I am on 32bit Ubuntu, and I would like my int be really long. Also I need malloc() take long int argument too. I found it is necessary to... (6 Replies)
Discussion started by: patiobarbecue
6 Replies

2. Shell Programming and Scripting

fetching data from sybase using perl

How can I fetch and retreive data(of each result set) of multiple result set from sybase by calling a stored procedure using perl DBI module on an unix solaris environment????? Please help (3 Replies)
Discussion started by: wadhwa.pooja
3 Replies

3. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

4. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (0 Replies)
Discussion started by: dear_abhi2007
0 Replies

5. Shell Programming and Scripting

Fetching data from .csv file

Hi Experts, I have created a table with columns as empname,empid,phone,shiftname. Now I am having a .csv file format which contains the shift datas of the employees. I have to fetch this file and compare with the table I created to send an alert to the specified user. (2 Replies)
Discussion started by: micky3112
2 Replies

6. Shell Programming and Scripting

Fetching data from file

Hi All, I'm facing issue while using script. Chk_Etl_Status=`cat /dstage/questnet/qnetdv/input/Etl_Status.dat|cut -d"," -f1` echo Chk_Etl_Status=$Chk_Etl_Status above result is giving me sometime value as 1 and sometime error message as Chk_Etl_Status= dsjoblaunch.sh: test: Specify a... (5 Replies)
Discussion started by: Amit786
5 Replies

7. Shell Programming and Scripting

Fetching data particular data from the file.

Hi All, I have one fine which contaning the record as below, I need to fetch the number which is in Bold and from second line only URL need to pick. :ABCD C7QyzBXIs58k 1 fdmlksdlkfn ... (4 Replies)
Discussion started by: Riverstone
4 Replies

8. Red Hat

Double data type C Red Hat platform problem

I'm converting a binary file to ASCII using c code. The folllowing block of code prints correct double value 00000.000000000 on HPUNIX platform. longi double; /* C79 - Price Per Minute */ memcpy(&longi,&rbuff,8); fprintf(wfp,"%015.9f ",longi); prints : 00000.000000000 ... (6 Replies)
Discussion started by: krk
6 Replies

9. Shell Programming and Scripting

Fetching the required data out of a tabular form

Hello Gurus, I am trying to fetch a required number of lines from an output of a command which is in tabular form. Below is the command for reference along with how the result is being shown on UNIX shell. /usr/openv/volmgr/bin/vmquery -b -p 5 The result of the above command is as... (6 Replies)
Discussion started by: Ali Sarwar
6 Replies

10. Shell Programming and Scripting

Extracting LONG Data Type from DB via UNIX Script

Hi, I want to extract a XML file which is stored in the database having a data Type as "LONG" via UNIX Scripting. But when i am triggering the SQL via UNIX it is fetching only the first Line and not the complete XML. Can you please suggest if the parameters that i have used needs any... (2 Replies)
Discussion started by: Barbara1234
2 Replies
PDO.EXEC(3)								 1							       PDO.EXEC(3)

PDO
::exec - Execute an SQL statement and return the number of affected rows SYNOPSIS
public int PDO::exec (string $statement) DESCRIPTION
PDO.exec(3) executes an SQL statement in a single function call, returning the number of rows affected by the statement. PDO.exec(3) does not return results from a SELECT statement. For a SELECT statement that you only need to issue once during your program, consider issuing PDO.query(3). For a statement that you need to issue multiple times, prepare a PDOStatement object with PDO.prepare(3) and issue the statement with PDOStatement.execute(3). PARAMETERS
o $statement - The SQL statement to prepare and execute. Data inside the query should be properly escaped. RETURN VALUES
PDO.exec(3) returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO.exec(3) returns 0. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. The following example incorrectly relies on the return value of PDO.exec(3), wherein a statement that affected 0 rows results in a call to die(3): <?php $db->exec() or die(print_r($db->errorInfo(), true)); ?> EXAMPLES
Example #1 Issuing a DELETE statement Count the number of rows deleted by a DELETE statement with no WHERE clause. <?php $dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); /* Delete all rows from the FRUIT table */ $count = $dbh->exec("DELETE FROM fruit WHERE colour = 'red'"); /* Return number of rows that were deleted */ print("Deleted $count rows. "); ?> The above example will output: Deleted 1 rows. SEE ALSO
PDO.prepare(3), PDO.query(3), PDOStatement.execute(3). PHP Documentation Group PDO.EXEC(3)
All times are GMT -4. The time now is 07:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy