Return output parameters in VC++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ravysters
    New Member
    • May 2008
    • 27

    #1

    Return output parameters in VC++

    hi... i am using VC++ to connect to my database and i am trying to insert a new row into a table. I am also using the returning statement available in postgres to return a column of the currently inserted record.. i have to output this.. can i do this.. here is my code.. i am getting an exception when i run this code.. there is no probs when i only use the insert statement.. but when i use the insert statement with the returning clause i get the errors...



    pcmd->ActiveConnecti on = pConn;

    //pcmd->

    pcmd->CommandText = "insert into testing(emp_id, emp_name,emp_sa l) values(?,?,?) returning emp_id into ?";

    param = pcmd->CreateParamete r("empid",adInt eger,adParamInp ut,10,long(1));
    pcmd->Parameters->Append(param );
    param1 = pcmd->CreateParamete r("empname",adV arChar,adParamI nput,15,"ravi") ;
    pcmd->Parameters->Append(param1) ;
    param2 = pcmd->CreateParamete r("e",adInteger ,adParamInput,1 0,long(23));
    pcmd->Parameters->Append(param2) ;
    param3 = pcmd->CreateParamete r("output",adIn teger,adParamRe turnValue, sizeof(int));
    pcmd->Parameters->Append(param3) ;


    pcmd->Execute(NULL,N ULL,adCmdText);



    in the above code if i remove the returning statement the code works fine.. but it wont work if i use the returning statement.. how can i make this work..

    thanks for any posts....
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I'm not an expert here, but it appears like your CreateParameter arguments do not jibe with the doeumentation. That is, I don't see any VARIANTs.

    http://msdn.microsoft.com/en-us/libr...09(VS.85).aspx.

    Comment

    Working...