SQL Server Performance

Identity fields & RFX

Discussion in 'SQL Server 2008 General Developer Questions' started by chrisatwebb, Apr 13, 2009.

  1. chrisatwebb New Member

    Hello,

    My database skills are a bit rusty, so please be charitable if this is a dumb question...

    We have an identity column in our SQL Server 2008 SP1 database that is giving us exceptions when trying to update records ("Degree of derived table does not match column list"). If we comment out the RFX for this field, everything is fine... which would normally be ok... but we do want to actually read this value so we can use it in other places.

    As near as I can tell, there is no way to tell the DoFieldExchange to only read the value but not try to write it.

    I've tried Googling on all keyword combos that I can think of, but can't find anyone else having this situation.

    Any ideas?

    Here is the code - the identity field is "af_id":

    void Dbm_AF_RecordSet::DoFieldExchange( CFieldExchange *pFX )
    {
    //{{AFX_FIELD_MAP(Dbm_AF_RecordSet)
    pFX->SetFieldType(CFieldExchange::eek:utputColumn);

    RFX_Int(pFX, "AF_ID", mAF.mId );
    RFX_Text(pFX, "AF_AIRLINE_ALPHA", mAF.mAirlineAlpha );
    RFX_Text(pFX, "AF_FL_NUMBER", mAF.mFlightNumber );
    RFX_Date(pFX, "AF_ORIGINAL_TIME", mAF.mOriginalTime );
    //}}AFX_FIELD_MAP
    }

    With DoDataExchange for dialog boxes, there is at least a way to tell which direction the data is going and act accordingly, but there doesn't seem to be a similar directional indicator for databases... unless I'm missing something?

    Thanks!

  2. dhamu294 New Member

    Hi,
    we no need to explictly give values for identy column.
    if you required what is last inserted in the identify column use this function scope_identity( )
    and store it in a variable immediatly after insert.

Share This Page