Solved

Help Urget  in Pro*c

Posted on 2000-03-08
1
739 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 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

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

Suggested Solutions

Title # Comments Views Activity
chcp 65001 File encoding 66 321
change colour of repeater control in asp.net c# 7 156
What is atomic operation? 6 73
Why  my code (program) build with old compiler? 11 145
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…
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 reading 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.

739 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