Can anyone shed some light on what might cause the following 
function to return some other value than the ROWID of the new row?

I've tried it both ways, and gotten sporadic incorrect results.

Thanks
Spencer

- - - - - - - - - - - - code follows - - - - - - - - - - 

function DuplicateRow (ByVal t as string, 
                       ByVal r as integer) as integer
dim a as alias

a = t + ".rowid"

run command "select * from "+t+" where rowid = "+str$(r)+" into ROW2DUP
noselect"
run command "insert into "+t+" select * from ROW2DUP"
close table ROW2DUP

fetch last from t
DuplicateRow = a
end function

- - - - - - - - - - - - alternative (faster) code - - - - - - - - - - 

function DuplicateRow (ByVal t as string,
                             col (0) as string,
                       ByVal cols as smallint,
                       ByVal r as integer) as integer

dim a as alias
dim icols as string
dim qcols as string

qcols = t + "." + col (1)
icols = col(1)
if cols > 1
   then for i = 2 to cols
            qcols = qcols + "," + t + "." + col (i)
            icols = icols + "." + col (i)
        next
end if
a = t + ".rowid"

run command "fetch rec "+str$(r)+" from "+str$(t)
run command "insert into "+t+" ("+icols+") values ("+qcols+")" 

fetch last from t
DuplicateRow = a
end function


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 10282

Reply via email to