AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • Example 1: Adding a record into a Customer file
  • Example 2: Transferring records between a data file and its alias
Example 1: Adding a record into a Customer file
PHPHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBConectores Nativos The customer form is displayed on the screen. ScreenToFile is used to load the values entered in memory.
// Add a record into a customer file
ScreenToFile()
IF HAdd(CUSTOMER) = False THEN
Error("Unable to add the customer")
END
Example 2: Transferring records between a data file and its alias
HFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBConectores Nativos A "Customer" file is created as well as its alias.
In the CUSTOMER file, a new record is created by fixing the automatic identifier (CUSTOMERID) to 1001.
In the CUSTOMERALIAS alias, the default management of automatic identifiers is kept: the automatic identifier starts from 1.
The records are copied from the alias into the CUSTOMER file by HCopyRecord. The automatic identifier of the record is kept during the copy (hCopyAutoId constant). Then, the copied record is added to the CUSTOMER file. The risks of duplicates are minimized.
// Create the CUSTOMER data file
HCreation(CUSTOMER)
// Assign the automatic identifier
CUSTOMER.CUSTOMERID = 1001
// Add a record into the Customer file
// without calculating the automatic identifier
// The first 1000 records are reserved
IF HAdd(CUSTOMER, hSetIdAuto) = False THEN
Error("Unable to add the customer")
// Find out the error details by checking
// HErrorDuplicates, HErrorIntegrity
// HErrorLock
END
// Create alias
HAlias(CUSTOMER, CUSTOMERALIAS)
HCreation(CUSTOMERALIAS)
// Add records into the CUSTOMERALIAS alias
// (the automatic identifier will be set to 1)
IF HAdd(CUSTOMERALIAS) = False THEN
  Error("Unable to add the customer")
  // Find out the error details by checking
// HErrorDuplicates, HErrorIntegrity
  // HErrorLock
END
 
// Other additions
...
 
// Copy the customers from CUSTOMERALIAS to CUSTOMER
i is int = 1
HRead(CUSTOMERALIAS, i)
// Copy the record
// as long as records are still found in the alias
// and as long as the identifier does not exceed 1000
WHILE NOT HOut(CUSTOMERALIAS) AND CUSTOMERALIAS.CustomerID < 1001
  // Copy the record from CUSTOMERALIAS to CUSTOMER
  HCopyRecord(CUSTOMER, CUSTOMERALIAS, hCopyAutoId)
  // Add the record
  IF HAdd(CUSTOMER, hSetIdAuto) = False THEN
Error("Unable to add the customer")
// Find out the error details by checking
// HErrorDuplicates, HErrorIntegrity
// HErrorLock
END
  // Next record of the alias
  i++
  HRead(CUSTOMERALIAS, i)
END
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Example
If Hadd(Customers) = true

toastdisplay("Gravou com sucesso")

else

info("Erro inesperador! "+ herrorinfo() + error())

end

/// or

ok is boolean = Hadd(Customers)
Boller
18 07 2020
Duplicar Registros
//Duplicar Registros

Nessa aula vou mostrar como eu faço para duplicar Registros

pedido.data_emissao=DateSys()
HAdd(pedido)
TableDisplay(TABLE_Pedido)

//Blog com Video e Exemplo

http://windevdesenvolvimento.blogspot.com.br/2016/10/aula-930-windev21-curso-246-dica.html

https://www.youtube.com/watch?v=gbFkTcVYeTA
De matos
04 10 2016

Última modificación: 14/06/2024

Señalar un error o enviar una sugerencia | Ayuda local