Scopo
Ritorna il comando SQL precedentemente assegnato al Prepared Statement.
Sintassi
string comando = "" // Leggo il comando assegnato
//
comando := PreparedStatement.GetCommand()
//
comando := PreparedStatement.GetCommand()
Argomenti
Questa funzione non ha argomenti.Valore di ritorno
Viene ritornata una stringa contenente il comando SQL precedentemente assegnato al Prepared Statement tramite SetCommand.
Esempio di codice
// ****************************************************************************
// La procedura assegna tutti i prodotti correntemente selezionati alla
// categoria relativa all'ID passato a parametro, facendo uso di
// PreparedStatement
// ****************************************************************************
public void Prodotti.ImpostaCategoriaaProdotti(
int CategorieIdcategoria // Identificatore univoco della categoria
)
{
PreparedStatement stmt = new() //
int idx = 1 // Usato per identificare la riga corrente
//
stmt.SetCommand(update prodotti set IDCategoria = ? where IDProdotto = ?
)
//
// Per ogni prodotto del pannello
for each row (Prodotti)
{
record Prodotto
...
//
if Prodotti.IsRowSelected(idx)
{
// Svuoto eventuali parametri precedenti
stmt.ClearParameters()
//
// Aggiungo i parametri nello stesso ordine in cui sono usati nel
// comando SQL
stmt.AddParameter(CategorieIdcategoria)
stmt.AddParameter(Prodotto.IdProdotto)
//
Scrivo i valori del parametri usati nel log
{
string parametri = "" //
int PIdx = 0 // Indice del parametro (parte da 0)
//
// Finché ci sono parametri
while PIdx < stmt.ParameterCount()
{
parametri := parametri +c stmt.GetParameter(PIdx) +c C;
PIdx := PIdx + ONE
}
//
EsempiGL.DTTLogMessage(FormatMessage(Il comando assegnato ...,
stmt.GetCommand(), parametri, ??, ??, ??), ??, ??)
}
//
// Possibili errori nel database
try
...
catch // Metto nel log l'errore ritornato dal db
...
}
idx := idx + ONE
}
Prodotti.RefreshQuery()
}
// La procedura assegna tutti i prodotti correntemente selezionati alla
// categoria relativa all'ID passato a parametro, facendo uso di
// PreparedStatement
// ****************************************************************************
public void Prodotti.ImpostaCategoriaaProdotti(
int CategorieIdcategoria // Identificatore univoco della categoria
)
{
PreparedStatement stmt = new() //
int idx = 1 // Usato per identificare la riga corrente
//
stmt.SetCommand(update prodotti set IDCategoria = ? where IDProdotto = ?
)
//
// Per ogni prodotto del pannello
for each row (Prodotti)
{
record Prodotto
...
//
if Prodotti.IsRowSelected(idx)
{
// Svuoto eventuali parametri precedenti
stmt.ClearParameters()
//
// Aggiungo i parametri nello stesso ordine in cui sono usati nel
// comando SQL
stmt.AddParameter(CategorieIdcategoria)
stmt.AddParameter(Prodotto.IdProdotto)
//
Scrivo i valori del parametri usati nel log
{
string parametri = "" //
int PIdx = 0 // Indice del parametro (parte da 0)
//
// Finché ci sono parametri
while PIdx < stmt.ParameterCount()
{
parametri := parametri +c stmt.GetParameter(PIdx) +c C;
PIdx := PIdx + ONE
}
//
EsempiGL.DTTLogMessage(FormatMessage(Il comando assegnato ...,
stmt.GetCommand(), parametri, ??, ??, ??), ??, ??)
}
//
// Possibili errori nel database
try
...
catch // Metto nel log l'errore ritornato dal db
...
}
idx := idx + ONE
}
Prodotti.RefreshQuery()
}
- Questa funzione ritorna il comando SQL così come è stato passato al Prepared Statement con SetCommand. Nel caso di comando parametrico il codice ritornato ha ancora i parametri nel codice, e non il valore assegnato loro mediante il metodo AddParameter.
Ultima modifica: 23/03/2021 / Validità: da 6.5.2680