Solved

Pro*C Date Problem

Posted on 2004-09-20
2
1,539 Views
Last Modified: 2012-06-27
Hi!

I have a date field in the database which I am trying to extract into a variable.

The variable to hold the data is defined as a char[20].

The function is:

int getNTLAllocations(accstmt_t* pAccStmt)
{

  char msg[STR255+1];


  EXEC SQL BEGIN DECLARE SECTION;
     char AccountNum[11+1];
     EXEC SQL VAR AccountNum IS STRING;
     int BillSeq;
     int Amount;
     char PaymentDate[20];
     EXEC SQL VAR PaymentDate IS STRING;
     short AccountPaymentSeq;
  EXEC SQL END DECLARE SECTION;

  strcpy(AccountNum, pAccStmt->ntlAccountNum);
  AccountNum[11] = '\0';
  PaymentDate[20] = '\0';


  BillSeq = pAccStmt->ntlBillSeq;


  EXEC SQL DECLARE accountpayments_cursor CURSOR FOR
     SELECT atb.amount_mny, ap.account_payment_dat
     FROM allocationtobill atb, accountpayment ap
     WHERE atb.account_num = :AccountNum
     AND   atb.bill_seq = :BillSeq
     AND   ap.account_num = atb.account_num
     AND   ap.account_payment_seq = atb.account_payment_seq;


  EXEC SQL OPEN accountpayments_cursor;
     EXEC SQL FETCH accountpayments_cursor INTO :Amount :PaymentDate ;
  EXEC SQL CLOSE accountpayments_cursor;


When i compile it I get:

Semantic error at line 791, column 58, file gpp_dbutil.pc:
     EXEC SQL FETCH accountpayments_cursor INTO :Amount :PaymentDate ;
.........................................................1
PCC-S-02367, This indicator variable must be declared as type short
make: The error code from the last command is 1.

I dont understand why this would have to be a datatype "short". Can anyone help?

Julian
0
Comment
Question by:stummj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
pratikroy earned 50 total points
ID: 12103318
Instead of
EXEC SQL FETCH accountpayments_cursor INTO :Amount :PaymentDate ;

You should have :

EXEC SQL FETCH accountpayments_cursor INTO :Amount, :PaymentDate ; /* Note the comma between two variables */

I believe you don't wish to keep/check the indicator variables, but by the syntax, it thinks that you are trying to populate the indicator variable :PaymentDate, which should be of type short. Ignore that error, and just put the comma. It should work !

Hope this helps !

0
 
LVL 9

Expert Comment

by:pratikroy
ID: 12103350
Now, don't ask what an indicator variable is. If you wish to know about it though, then refer to : http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a97269/pc_02prc.htm#1066
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question