Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Return Value in Oracle Stored Procedure When Calling in VC

Return Value in Oracle Stored Procedure When Calling in VC

From: <faisal.aslam_at_usa.net>
Date: Tue, 01 Sep 1998 15:02:54 GMT
Message-ID: <6sh2au$jed$1@nnrp1.dejanews.com>


Hi I am using ODBC API like SQLConnect , SQLBindParameter , SQLExecDirect in VC to connect and run store procedure on Oracle Server (7.3 ver) . They are working fine (input as well as working ) except that they are not returning values .Can any body help me . I am just writing a sample code here. (without

error tracking to make it small) ____________________________________ 
#include <stdio.h>  #include <conio.h>	#include <windows.h>  #include
<sql.h>  #include <sqlext.h>  HENV  henv;  HDBC  hdbc;	HSTMT  hstmt; 
RETCODE retcode;  SWORD bufout;  // Output buffer  SDWORD nativeerror;	//
Native error  SQLCHAR ID[11];  // Agency name  SQLINTEGER iNum1=SQL_NTS; 
long  iNum2=4;	int read123(void);  void connect123();

 void main()
{

 connect123();
}

void connect123()
{

      retcode = SQLAllocEnv(&henv);              /* Environment handle */
       retcode = SQLAllocConnect(henv, &hdbc); /* Connection handle */
       retcode = SQLConnect(hdbc,(UCHAR*)"madta", SQL_NTS,(UCHAR*)"faisal",
SQL_NTS, (UCHAR*)"lasiaf", SQL_NTS);
    			read123();
			SQLFreeStmt (hstmt,SQL_DROP);
                        SQLDisconnect(hdbc);
                        SQLFreeConnect(hdbc);
                         SQLFreeEnv(henv);

}

int read123()
{

	SQLInteger output;
	SQLAllocStmt (hdbc, &hstmt);
	strcpy(ID,"fff");
        retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
        SQL_C_CHAR , SQL_CHAR, 10, 0, ID, 11, &iNum1);
    	retcode=SQLBindParameter(hstmt,2, SQL_PARAM_OUTPUT,
        SQL_C_DEFAULT, SQL_INTEGER,0,0,&output,0,&iNum2);
	printf("\n\n %i \n",output);
	retcode = SQLExecDirect(hstmt,"{call ALI2(?,?)}", SQL_NTS);
        printf("\n\n %i \n",output);

}

here is a SPC and a Table associated with it.

CREATE OR REPLACE
PROCEDURE ALI2(
INV IN CHAR ,
OUTV OUT INTEGER
)
IS
VAR2 INTEGER:=90;
BEGIN
OUTV:=11;
DELETE FROM ALI WHERE ID=INV;
INSERT INTO ALI (N1 , N2 , ID ) VALUES (OUTV , VAR2 , INV); EXCEPTION
WHEN OTHERS THEN

	OUTV:=12;
	INSERT INTO ALI (N1 , N2 , ID ) VALUES (10 , 10 , 'EEE');
END ALI2;
/

Here is the table associated with it

DROP TABLE ALI;
CREATE TABLE ALI (N1 INTEGER , N2 INTEGER , ID VARCHAR2(10));


Please help me. U can mail me at faisal.aslam_at_usa.net

Faisal Aslam

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Tue Sep 01 1998 - 10:02:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US