How to use Handlers and what does sp_prepexec stored procedure will do ?

  • Hi There,

    Can anyone please help me out in debugging or finding out how the sp_prepexec stored procedure will function, i could not find any related information in BOL also.

    In the below mentioned script, a field called TXTFIELD is getting filled with a Handler value. Am not able to understand how these handlers are used and handled. I would like to take over the control of this handler and edit the values so that i can fill the above mentioned field with my required values than getting filled with the values what the handler contains.

    Or is there any way to find out how this handler is getting filled?

    declare @P1 int

    set @P1=19

    exec sp_prepexec @P1 output, N'@P1 text', N'BEGIN INSERT INTO TWO.dbo.CN100200 (USERID, CUSTNMBR, TXTFIELD) VALUES ( ''printSA'', ''A00057'', @P1) ;  SELECT @@IDENTITY ;  END ', '  14/10/2005SALE'

    select @P1

    Thanks in Advance.

    Subhash

  • This was removed by the editor as SPAM

  • sp_prepexec is a utility implemented by the ODBC driver and should not be used directly. If you need to perform such a task you need to use ODBC on your programing front end like:

     SQLREAL       Price;

    SQLUINTEGER   PartID;

    SQLINTEGER    PartIDInd = 0, PriceInd = 0;

    // Prepare a statement to update salaries in the Employees table.

    SQLPrepare(hstmt, "UPDATE Parts SET Price = ? WHERE PartID = ?", SQL_NTS);

    // Bind Price to the parameter for the Price column and PartID to

    // the parameter for the PartID column.

    SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_FLOAT, SQL_REAL, 7, 0,

                      &Price, 0, &PriceInd);

    SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 10, 0,

                      &PartID, 0, &PartIDInd);

    // Repeatedly execute the statement.

    while (GetPrice(&PartID, &Price)) {

       SQLExecute(hstmt);

    }

    But if your  front end uses some other interface I think you should stick to common programing TSQL

     

     


    * Noel

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply