Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Valor retorno SP SQL Server
Message
 
To
13/09/2006 17:20:33
Humberto Ramirez
H. Ayuntamiento de Colima
Colima, Mexico
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01153527
Message ID:
01153555
Views:
14
Para obtener el Identity de SQL server tenes la función IDENT_CURRENT()
la sintaxis para SQL P.T. sería algo por el estilo:
SQLEXEC(nHandle,"select IDENT_CURRENT('miTabla') AS valor","cur_identity")
? cur_identity.valor
Es un poco delicado en un entorno concurrente, sería bueno ponerlo dentro de una transaccion (siempre hablando de SQL PT) , por ejemplo:
SQLEXEC(nHandle,"begin tran vfprv")
SQLEXEC(nHandle,"insert into miTabla (miCol) values (?cValor)")
SQLEXEC(nHandle,"select IDENT_CURRENT('miTabla') AS valor","cur_identity")
? cur_identity.valor
SQLEXEC(nHandle,"commit tran vfprv")
Tambien tenes
@@IDENTITY
y
SCOPE_IDENTITY
Espero que sirva.
Saludos,

>Qué tal, ¿cómo hago para poder obtener un valor de retorno desde un SP de SQL Server en VFP? Tengo una tabla con un campo ID de tipo Identity (incremental), tengo un SP que agrega datos a la tabla, me gustaría obtener el ID asignado al registro recién agregado a través de una variable de salida. Estoy leyendo los libros en pantalla de SQL Server, mi duda mayor está en la sintaxis de VFP a través de SQL Pass-Through.
>
>De antemano gracias y saludos.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform