Solved

Pro*C Date Problem

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-12560: TNS:protocol adapter error 8 132
Oracle DATE Column Space 11 80
Processing of multiple cursor 6 47
oracle 11g 23 84
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

822 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