Finally I have done a mix.
Step 1.- changed Update and tabsequence column properties to let user modify the data column
Step 2.- Searched the key columns and autoidentity ones in the marvelous INFORMATION_SCHEMA for set key columns and not let change the autoidentity, if any.
Step 3. Changed both updatetable and updatewhere properties
It works fine!!
Thanks Mike, Chris and Olan
Long fila_ds, filas_ds
integer pos_where, pos_from, n_objeto
string claves_primarias, msg_error,tabla, column
string objetos, objeto, tipo_objeto
//Paso 1: Actualizamos el actualizado y la secuencia de todas las columnas, pera que se pueda escribir.
objetos = dw_maestro.Describe('DataWindow.Objects') // Lista de objetos
objetos += '~t' // Adiciona un TAB al final para tomar hasta el último control
Do While Pos(objetos, '~t') > 0
n_objeto++
objeto = Left(objetos, Pos(objetos, '~t') - 1) // Nombre del control
if dw_maestro.Describe(objeto+'.Type') = 'column' then
dw_maestro.Modify(objeto + ".Update= Yes")
dw_maestro.Modify(objeto + ".tabsequence=" +string(n_objeto * 10))
end if
objetos = Mid(objetos, LenA(objeto) + 2) // Actualiza lista de objetos
loop
//Paso 2: Buscamos la clave primaria, para actualizar.
pos_from = Pos(upper(consulta),"FROM") + 4 //4: longitud del from
pos_where = Pos(upper(consulta)," WHERE ")
if pos_where = 0 then pos_where = len(consulta)
tabla = trim(mid(upper(consulta), pos_from, pos_where - pos_from))
claves_Primarias = " SELECT KU.table_name as TABLENAME,column_name as PRIMARYKEYCOLUMN, " + &
" COLUMNPROPERTY (OBJECT_ID('" + tabla + "'),COLUMN_NAME ,'IsIdentity') AS ident " + &
" FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC " + &
" INNER JOIN " + &
" INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU " + &
" ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND " + &
" TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME AND " + &
" KU.table_name='" + tabla + "'" + &
" ORDER BY KU.TABLE_NAME, KU.ORDINAL_POSITION "
datastore ds_claves
ds_claves = create datastore
if uf_id_createds(ds_claves,claves_Primarias,"") < 0 then
msg_error = "Error al crear el datastore en sintaxis"
return -1
end if
ds_claves.SetTransObject(sqlca)
filas_ds = ds_claves.retrieve()
for fila_ds = 1 to filas_ds
column = ds_claves.getitemstring(fila_ds,'PRIMARYKEYCOLUMN')
dw_maestro.Modify(column + ".Key= Yes")
if ds_claves.getitemnumber(fila_ds,'ident') = 1 then
dw_maestro.Modify(column + ".tabsequence= 0")//El autonumérico, no dejamos modificar.
end if
next
dw_maestro.Modify('DataWindow.Table.UpdateTable = "' +tabla + '"')
dw_maestro.Modify ("DataWindow.Table.UpdateWhere= '1'" )
imo, it should work consistently. So if PS doesn't do that then it should be reported
Yes, if that's not the case in PowerServer - then a Support Ticket should be created.
Regards ... Chris