?
Solved

Help Urget  in Pro*c

Posted on 2000-03-08
1
Medium Priority
?
745 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
[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
1 Comment
 

Accepted Solution

by:
jayak earned 450 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

Technology Partners: 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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

801 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