The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Logs access in windows fetching the data from a unix server alvida Shell Programming and Scripting 1 07-16-2009 06:31 AM
fetching data from sybase using perl wadhwa.pooja Shell Programming and Scripting 3 07-03-2009 09:48 AM
enable 64bit long type for gcc patiobarbecue High Level Programming 6 12-20-2008 02:21 AM
Emacs set-cursor-color in iTerm problem pepperjacl OS X (Apple) 0 07-17-2008 08:57 AM
FILE data type milhan High Level Programming 6 01-28-2005 08:49 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
manbt manbt is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
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; 4 Weeks Ago at 10:31 AM.. Reason: code tags, please...
  #2 (permalink)  
Old 4 Weeks Ago
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
It may be a data problem - if there is an ASCII NUL ( ASC(0)) character embedded in the data, C will terminate the string at that point. You are using strcpy() which will do that for example.

FWIW: avoid LONG, it has numerous issues; use CLOB datatype instead.
Oracle LONG CLOB Convert
  #3 (permalink)  
Old 4 Weeks Ago
manbt manbt is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 2
Thanks Jim for replying.

This is an old application I am maintaining so people dont want to move it to CLOB.

Regarding the data problem, it does not seems to be it as the data which is getting cut is a single word.

eg. at 22751 bytes data there is this word "...DOWN RESPONSE" and I am getting till "...DOW". So it does not seem to be ascii(0) issue.

Cheers!
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0