FoxPro/Visual FoxPro - Cursor con Postgres

 
Vista:

Cursor con Postgres

Publicado por RJCA (2 intervenciones) el 06/04/2019 04:56:24
Necesito actualizar un cursor con el id autoincremental que me da la base de datos POSTGRES...

Este es el código:

PUBLIC conexion
conexion= SQLSTRINGCONNECT("Driver=PostgreSQL ANSI;Server=localhost;Port=5432;Database=prueba;Uid=postgres;BoolsAsChar=0;pwd=xxxxxx")

IF conexion>0

R=SQLEXEC(conexion, "CREATE TABLE IF NOT EXISTS A (id_a serial primary KEY, concepto CHAR(40))")

IF R=1

&& no se debe cargar toda la tabla, ya que requiero solo el registro nuevo insertado por eso pongo where id_a='0',,, esto se puede modificar
SQLEXEC(conexion,"select id_a, concepto from a where id_a='0' ORDER BY id_a","a")

CURSORSETPROP("Tables","a")
CURSORSETPROP("KeyfieldList","id_a", "a")
CURSORSETPROP("UpdaTableFieldList"," id_a, concepto", "a")
CURSORSETPROP("UpdateNameList","id_a a.id_a, "+"concepto a.concepto ", "a")
CURSORSETPROP("SendUpdates",.T., "a")

SET MULTILOCKS ON
CURSORSETPROP("buffering",3, "a")
CURSORSETPROP("UpdateType", 2, "a")
CURSORSETPROP("WhereType",3,"a")

SELECT a
APPEND BLANK && SE AGREGA UN NUEVO REGISTRO
&& ID_A ES AUTOINCREMENTAL POR LA BASE DE DATOS
REPLACE CONCEPTO WITH 'XXXXXX' && ASIGNO EL CONCEPTO
BROWSE NORMAL && EN ESTE BROWSE VEO EL NUEVO REGISTRO, PERO ID_A ESTÁ CERO
TABLEUPDATE(1,.T.) && ACTUALIZO EL CURSOR PARA PODER VER EL ID_A QUE ASIGNÓ LA BASE DE DATOS

BROWSE NORMAL

CURSORSETPROP("Refresh",0, 'a') && INTENTO ACTUALIZAR EL CAMPTO ID_A QUE ME DIO LA BASE DE DATOS... esto no funciona

&& aqui de alguna forma tengo que hacer un requery de la tabla para que me muestre el valor de id_a
&& debe ser en el mismo cursor, y en este momento, sin abrir otra vez la tabla u otro cursor
&& (entrarán a la vez varios registros desde varios equipos por lo que el ultimo no necesariamente será el agregado)


BROWSE NORMAL && BROWSE PARA VER SI YA SE ACTUALIZÓ ID_A, pero no me muestra el valor

USE IN a

ELSE
MESSAGEBOX('Error al crear la tabla')
ENDIF

ELSE
MESSAGEBOX('No se conecto a la bdd')
ENDIF

Muchas gracias por su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder