Solved

Help Urget  in Pro*c

Posted on 2000-03-08
1
705 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now