Click here to Skip to main content
15,898,826 members
Home / Discussions / Database
   

Database

 
GeneralRe: Oracle SP coding style Pin
Mycroft Holmes24-Aug-11 4:59
professionalMycroft Holmes24-Aug-11 4:59 
GeneralRe: Oracle SP coding style Pin
GuyThiebaut24-Aug-11 5:56
professionalGuyThiebaut24-Aug-11 5:56 
GeneralRe: Oracle SP coding style Pin
PIEBALDconsult24-Aug-11 3:05
mvePIEBALDconsult24-Aug-11 3:05 
GeneralRe: Oracle SP coding style Pin
GuyThiebaut24-Aug-11 3:32
professionalGuyThiebaut24-Aug-11 3:32 
GeneralRe: Oracle SP coding style Pin
Mycroft Holmes24-Aug-11 5:03
professionalMycroft Holmes24-Aug-11 5:03 
AnswerRe: Oracle SP coding style Pin
jschell24-Aug-11 8:16
jschell24-Aug-11 8:16 
GeneralRe: Oracle SP coding style Pin
Mycroft Holmes24-Aug-11 12:30
professionalMycroft Holmes24-Aug-11 12:30 
QuestionOLE DB and return value from stored procedure Pin
kurlyak21-Aug-11 5:54
kurlyak21-Aug-11 5:54 
I have code and return value == 0. Why? It must be 99!
C++
ALTER PROCEDURE [dbo].[myproc] 
(
@mykod INT
)
RETURNS INT
AS
BEGIN 
select * from table1 where kod=@mykod
RETURN 99
END

//----------------------------------

ICommandText*   pICommandText;
hr = pIDBCreateCommand->CreateCommand(NULL, IID_ICommandText,(IUnknown**) &pICommandText);
if (FAILED(hr)) AfxMessageBox("Command Create Command Failed");




WCHAR* wSQLString = L"{?=CALL myproc(?)}";

pICommandText->SetCommandText(DBGUID_DBSQL, wSQLString);

 SPROCPARAMS         sprocparams = {0, 2};

  
    // Command parameter data.
    DBPARAMS            Params;
    const ULONG         nParams = 2;
//-----------------

typedef struct tagSPROCPARAMS
    {
    long        lReturnValue;
    long 	lkodValue;
    } SPROCPARAMS;




   

DBBINDING           acDBBinding[nParams];
    DBBINDSTATUS        acDBBindStatus[nParams];


    for (ULONG i = 0; i < nParams; i++)
        {
        acDBBinding[i].obLength = 0;
        acDBBinding[i].obStatus = 0;
        acDBBinding[i].pTypeInfo = NULL;
        acDBBinding[i].pObject = NULL;
        acDBBinding[i].pBindExt = NULL;
        acDBBinding[i].dwPart = DBPART_VALUE;
        acDBBinding[i].dwMemOwner = DBMEMOWNER_CLIENTOWNED;
        acDBBinding[i].dwFlags = 0;
        acDBBinding[i].bScale = 0;
        }


    acDBBinding[0].iOrdinal = 1;
    acDBBinding[0].obValue = offsetof(SPROCPARAMS, lReturnValue);
    acDBBinding[0].eParamIO = DBPARAMIO_OUTPUT;
    acDBBinding[0].cbMaxLen = sizeof(long);
    acDBBinding[0].wType = DBTYPE_I4;
    acDBBinding[0].bPrecision = 11;
	

	acDBBinding[1].iOrdinal = 2;
    acDBBinding[1].obValue = offsetof(SPROCPARAMS, lkodValue);
    acDBBinding[1].eParamIO = DBPARAMIO_INPUT;
    acDBBinding[1].cbMaxLen = sizeof(long);
    acDBBinding[1].wType = DBTYPE_I4;
	acDBBinding[1].bPrecision = 11;


    // Get the IAccessor interface, then create the accessor for
    // the defined parameters.

	IAccessor*  pIAccessor; 
HACCESSOR   hAccessor; 


pICommandText->QueryInterface(IID_IAccessor,
        (void**) &pIAccessor);
	if(FAILED(hr)) AfxMessageBox("Failed Query Interface IId_IAccessor");
	
	

    hr = pIAccessor->CreateAccessor(DBACCESSOR_PARAMETERDATA,
        nParams, acDBBinding, sizeof(SPROCPARAMS), &hAccessor,
        acDBBindStatus);
	if(FAILED(hr)) AfxMessageBox("Failed Create Accessor");
    
    // Fill the DBPARAMS structure for the command execution.
    Params.pData = &sprocparams;
    Params.cParamSets = 1;
    Params.hAccessor = hAccessor;

	LONG      cRowsAffected;

	IRowset*    pIRowset;


hr = pICommandText->Execute(NULL, IID_IRowset, &Params,&cRowsAffected, (IUnknown**) &pIRowset);
if (FAILED(hr)) AfxMessageBox("Execute Failed");

CString str;
str.Format("%d",sprocparams.lReturnValue);
//return 0 !!!!!!!!!!!!!!!!!!!!!!!!!!
AfxMessageBox(str);	
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

pIRowset->Release();


str.Format("%d",sprocparams.lReturnValue);
//return 0 !!!!!!!!!!!!!!!!!!!!!!!!!!
AfxMessageBox(str);	
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Íà ôîðóìå ÿ èùó ïðîãðàìû ïî Ñ++.

QuestionDTS Package Pin
current199919-Aug-11 5:10
current199919-Aug-11 5:10 
AnswerRe: DTS Package Pin
Simon_Whale19-Aug-11 5:19
Simon_Whale19-Aug-11 5:19 
GeneralRe: DTS Package Pin
current199919-Aug-11 7:43
current199919-Aug-11 7:43 
GeneralRe: DTS Package Pin
S Douglas19-Aug-11 12:51
professionalS Douglas19-Aug-11 12:51 
Questionjoint Pin
vinodh.K19-Aug-11 0:39
vinodh.K19-Aug-11 0:39 
AnswerRe: joint Pin
Blue_Boy19-Aug-11 0:40
Blue_Boy19-Aug-11 0:40 
AnswerRe: joint PinPopular
Richard MacCutchan19-Aug-11 0:46
mveRichard MacCutchan19-Aug-11 0:46 
AnswerRe: joint Pin
Pete O'Hanlon19-Aug-11 1:14
mvePete O'Hanlon19-Aug-11 1:14 
GeneralRe: joint Pin
Tim Carmichael19-Aug-11 4:00
Tim Carmichael19-Aug-11 4:00 
AnswerRe: joint Pin
Mycroft Holmes19-Aug-11 3:10
professionalMycroft Holmes19-Aug-11 3:10 
AnswerRe: joint Pin
S Douglas19-Aug-11 12:58
professionalS Douglas19-Aug-11 12:58 
AnswerRe: joint Pin
Ganu Sharma15-Sep-11 21:20
Ganu Sharma15-Sep-11 21:20 
QuestionCreate a trigger Pin
lionelcyril18-Aug-11 18:29
lionelcyril18-Aug-11 18:29 
AnswerRe: Create a trigger Pin
Wendelius18-Aug-11 19:07
mentorWendelius18-Aug-11 19:07 
GeneralRe: Create a trigger Pin
lionelcyril18-Aug-11 19:12
lionelcyril18-Aug-11 19:12 
GeneralRe: Create a trigger Pin
Wendelius18-Aug-11 19:18
mentorWendelius18-Aug-11 19:18 
AnswerRe: Create a trigger [modified] Pin
Shameel18-Aug-11 23:03
professionalShameel18-Aug-11 23:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.