Solved

Help Urget  in Pro*c

Posted on 2000-03-08
1
731 Views
Last Modified: 2012-06-21
Hi,
CREATE OR REPLACE PACKAGE SPK_GET_CONTR_TABLE AS
TYPE CONTR_TABLE IS TABLE OF VARCHAR2(50);
PROCEDURE PROC_GET_CONTR_TABLE (OUT_TABLE OUT CONTR_TABLE);
END;
/
show error;
/
CREATE OR REPLACE PACKAGE BODY SPK_GET_CONTR_TABLE AS
PROCEDURE PROC_GET_CONTR_TABLE (OUT_TABLE OUT CONTR_TABLE) IS
I NUMBER(10);
CURSOR GET_TPA
IS
  SELECT
        SERVICE_CONTRACT_NO||' ' ||
        S_C_LINE_ITEM_NO
  FROM SV.SVC_CONTR_CVRG_CA
  WHERE ROWNUM < 5;
BEGIN
  I := 1;
  OPEN GET_TPA;
  WHILE I < 4 LOOP
    FETCH GET_TPA
    INTO OUT_TABLE(I);
    I := I+1;
  END LOOP;
  CLOSE GET_TPA;
END;
END;
/
show error;
/

Above is the package procedure I had compiled. Now I want to call tha above procedure from a pro*c program.

I'm trying to call like this

#include <stdio.h>
#include <sqlca.h>

main()
{
 char SDATE[20];

EXEC SQL DECLARE tempBuffer TYPE AS OBJECT (bUFFER VARCHAR2(50));
EXEC SQL DECLARE tempBuffer1 TABLE OF tempBuffer;
ConnectToOracle();
EXEC SQL SELECT SYSDATE INTO SDATE FROM DUAL;
 printf("SYSDATE = %s" , SDATE);
 EXEC SQL  EXECUTE
 BEGIN
SV.SPK_GET_CONTR_TABLE.PROC_GET_CONTR_TABLE(tempBuffer1.bUFFER);
        END;
 END-EXEC;
 printf("SQLCODE = %d" , SQLCA.SQLCODE);
}

I'm not very sure how to pass the parameter to the procedure.  

Thanks,
Kotamraju
0
Comment
Question by:kotamraju
1 Comment
 

Accepted Solution

by:
jayak earned 150 total points
ID: 2603265
Kotamraju,

You can call the procedure in Pro* C as
below

Exec SQL Begin Declare Section
    Static  temp_variable varchar2(10);
Exec SQL End Declare Section

EXEC SQL  EXECUTE
 BEGIN
/* Package_Name.Procedure_name(variable) */
SPK_GET_CONTR_TABLE.PROC_GET_CONTR_TABLE(:temp_variable);
 END;
END-EXEC;

I hope it will do for you. If you have any doubts please leave comments

Jaya
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

830 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