Como se define um tempo limite para o Execute
Moderador: Moderadores
Como se define um tempo limite para o Execute
Pessoal,
Como se define um tempo limite para o Execute de um command (ADODB.Command)
Como se define um tempo limite para o Execute de um command (ADODB.Command)
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Nunca usei isso.
Mas se não me engano é na conexão.
Mas se não me engano é na conexão.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Como se define um tempo limite para o Execute
Olá!
Código: Selecionar todos
// Prepare the stored procedure
With Object oCmd := win_OleCreateObject("ADODB.Command")
:CommandText := "spMyStoredProcedure"
:CommandType := adCmdStoredProc
:CommandTimeout = 120 // default = 30 seconds
:parameters:append( :createParameter( 'cMarca', adVarChar, adParamInput, 1, 'V' ) )
:parameters:append( :createParameter( 'dtCotacao', adDate, adParamInput, 10, '2021-04-01' ) )
:parameters:append( :createParameter( 'cHrCotacao', adVarChar, adParamInput, 5, '00:00' ) )
:parameters:append( :createParameter( 'nIntervalo', adInteger, adParamInput, 4, 400 ) )
:ActiveConnection := oCn
End With
// Execute the stored procedure. This returns a recordset.
oRs := oCmd:Execute()
oCmd := NIL
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Tô pensando aqui uma coisa:
Não seria mais interessante alterar de procedure pra function?
Igual naquelas rotinas de extenso.
Ou a finalidade de procedure é diferente de function?
Ao invés disso tudo, seria
Não seria mais interessante alterar de procedure pra function?
Igual naquelas rotinas de extenso.
Ou a finalidade de procedure é diferente de function?
Ao invés disso tudo, seria
Código: Selecionar todos
cnMySQL:Execute( "function(" + param1 + ", " + Param2 + ", " + Param3 + ")" )
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Como se define um tempo limite para o Execute
Estou testando o FOR UPDATE colocando o controle de transação
Inicia a transação BeginTrans
Faz select com for update
...
Grava com update
Finaliza com CommitTrans
ou
RollBackTrans em caso de erro
Quando faz o execute e se aquele registro está com lock, o execute demora muito na resposta, no meu caso estou usando MariaDB
Inicia a transação BeginTrans
Faz select com for update
...
Grava com update
Finaliza com CommitTrans
ou
RollBackTrans em caso de erro
Quando faz o execute e se aquele registro está com lock, o execute demora muito na resposta, no meu caso estou usando MariaDB
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Provavelmente fica aguardando até que seja desbloqueado.asimoes escreveu:Quando faz o execute e se aquele registro está com lock, o execute demora muito na resposta
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Fiz um teste no MariaDB e deu certo.
Falta testar no MySQL 5.6
Assim fica padrão pra qualquer coisa, inclusive SQLMIX.
Ainda não uso STORED PROCEDURE, mas quando usar vou preferir assim.
Código: Selecionar todos
CREATE PROCEDURE ze_test( DtInicial DATE, dtFinal DATE )
BEGIN
SELECT * FROM jpfinan WHERE fidatemi BETWEEN dtinicial AND dtfinal;
END
Código: Selecionar todos
CALL ze_test( '2021-01-01', '2021-06-01' )
Assim fica padrão pra qualquer coisa, inclusive SQLMIX.
Ainda não uso STORED PROCEDURE, mas quando usar vou preferir assim.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Só NÃO deu certo algo assim
Código: Selecionar todos
SELECT * FROM
(
CALL ze_test( '2021-01-01', '2021-06-01' )
) as b
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
E consultando o fonte "create" no HeidiSQL, aparece assim:
Por default, quem criou é quem pode usar, então fica vinculado ao usuário.
Dependendo do caso, só o administrador vai conseguir cadastrar uma procedure/function pra uso geral.
Isso pode complicar, conforme o caso...
Código: Selecionar todos
CREATE DEFINER=`jpatecnologia`@`%` PROCEDURE `ze_test`(
IN `DtInicial` DATE,
IN `dtFinal` DATE
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT * FROM jpfinan WHERE fidatemi BETWEEN dtinicial AND dtfinal;
END
Dependendo do caso, só o administrador vai conseguir cadastrar uma procedure/function pra uso geral.
Isso pode complicar, conforme o caso...
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Esqueci de dizer:
Se entendi direito, tudo acima pode ser substituído por:
Código: Selecionar todos
// Prepare the stored procedure
With Object oCmd := win_OleCreateObject("ADODB.Command")
:CommandText := "spMyStoredProcedure"
:CommandType := adCmdStoredProc
:CommandTimeout = 120 // default = 30 seconds
:parameters:append( :createParameter( 'cMarca', adVarChar, adParamInput, 1, 'V' ) )
:parameters:append( :createParameter( 'dtCotacao', adDate, adParamInput, 10, '2021-04-01' ) )
:parameters:append( :createParameter( 'cHrCotacao', adVarChar, adParamInput, 5, '00:00' ) )
:parameters:append( :createParameter( 'nIntervalo', adInteger, adParamInput, 4, 400 ) )
:ActiveConnection := oCn
End With
// Execute the stored procedure. This returns a recordset.
oRs := oCmd:Execute()
oCmd := NIL
Código: Selecionar todos
cSQL := "call spMyStoredProcedure( 'V', '2021-04-01', '00:00', 400 )"
oRs := oCn:Execute( cSQL )
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Funciona também no MySQL 5.6
Falta o teste prático, porque nunca se sabe se o HeidiSQL faz alguma modificação nisso, como por exemplo a necessidade do DELIMITER que não faz parte do comando.
Falta o teste prático, porque nunca se sabe se o HeidiSQL faz alguma modificação nisso, como por exemplo a necessidade do DELIMITER que não faz parte do comando.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
Faltou dizer:
A conexão também tem essa configuração de timeout.
Não sei o que acontece ao definir diferente nesse outro ADODB.Command, já que faz uso da conexão.
A conexão também tem essa configuração de timeout.
Não sei o que acontece ao definir diferente nesse outro ADODB.Command, já que faz uso da conexão.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Como se define um tempo limite para o Execute
Descobri,
FOR UPDATE NOWAIT
O NOWAIT, resposta imediata.
FOR UPDATE NOWAIT
O NOWAIT, resposta imediata.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Como se define um tempo limite para o Execute
A tradução de NO WAIT é sem espera.
Ou atualiza pulando os bloqueados, ou apenas envia o comando sem esperar resposta.
Nos dois casos, acho que a atualização vai ser incompleta.
Ou atualiza pulando os bloqueados, ou apenas envia o comando sem esperar resposta.
Nos dois casos, acho que a atualização vai ser incompleta.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
Como se define um tempo limite para o Execute
Olá!
Vai pegar a última versão estável do registro. Se este registro estiver sendo atualização por outro processo, vai pegar sem as atualizações deste processo.
Using skip locked and nowait to handle hot rows
Vai pegar a última versão estável do registro. Se este registro estiver sendo atualização por outro processo, vai pegar sem as atualizações deste processo.
Using skip locked and nowait to handle hot rows
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)