AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • Example 1: Adding a record to a customer data file
  • Example 2: Transferring records between a data file and its alias
Example 1: Adding a record to a customer data file
HFSQL ClassicHFSQL Client/ServerConectores Nativos The customer form is displayed on the screen. ScreenToFile is used to load the values entered in memory.
// Add a record to a customer data 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/ServerConectores Nativos A "Customer" data file is created, along with its alias.
In the "Customer" data file, a new record is created by setting the automation identifier (IDCLIENT) to 1001.
In the ALIASCLIENT alias, the default automatic identifier management is retained: the automatic identifier starts at 1.
Records are copied from the alias to the "Client" data file using the function HCopyRecord function.. The record's automation ID is retained during copying (constant hCopieIdAuto). The copied record is then added to the "Customer" data 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(CLIENT, 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 ALIASCLIENT record into the CLIENT data file
   	HCopyRecord(CLIENT, ALIASCLIENT, hCopyAutoID)
   	// Add the record
   	IF HAdd(CLIENT, 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: 06/12/2024

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