Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help Urget  in Pro*c

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

810 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