Solved

Pro*C Date Problem

Posted on 2004-09-20
2
1,523 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

739 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