PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 22 → Example to Run an MS SQL Stored Procedure with Windev, Webdev using HExecuteSQLQuery (Exemplo para Executar uma MS SQL Stored Procedure com o Windev, Webdev usando o HExecuteSQLQuery)
Example to Run an MS SQL Stored Procedure with Windev, Webdev using HExecuteSQLQuery (Exemplo para Executar uma MS SQL Stored Procedure com o Windev, Webdev usando o HExecuteSQLQuery)
Débuté par adrianoboller, 08 jan. 2015 17:29 - 3 réponses
//hostimage.webdev.info/avatars/RrpZpplIAjR9ZZaAh1xcw
Membre enregistré
2 571 messages
Popularité : +89 (91 votes)
Posté le 08 janvier 2015 - 17:29
Example to Run an MS SQL Stored Procedure with Windev, Webdev using HExecuteSQLQuery (Exemplo para Executar uma MS SQL Stored Procedure com o Windev, Webdev usando o HExecuteSQLQuery)

CODIGO MSSQL:

--PEGA O VALOR DA ULTIMA CORRIDA

USE [producao]
GO

CREATE PROCEDURE NG0002_Procedure_UltimaCorrida
AS

DECLARE @num_corrida int;

SELECT @num_corrida = num_ultima_numera FROM numeracao WHERE ide_numera = 'ACT263_CORRIDA' AND num_ano_refere = year(getdate());

SELECT @num_corrida AS num_corrida;

return @num_corrida;

GO





CODIGO NO WINDEV, WEBDEV - USO EM WEBSERVICE:

//Executar procedure
numero_corrida is int = 0

MyProcedureUltimaCorrida is Data Source

IF HExecuteSQLQuery(MyProcedureUltimaCorrida, ConnNativa, hQueryWithoutCorrection,"NG0002_Procedure_UltimaCorrida") THEN

HReadFirst(MyProcedureUltimaCorrida, num_corrida)

WHILE HOut() = False
ok = HReadNext(MyProcedureUltimaCorrida, num_corrida)
numero_corrida = MyProcedureUltimaCorrida.num_corrida
END

ELSE
Error(HErrorInfo())
END

Trace(numero_corrida)


Veio valor sem dar erro no Trace()
//hostimage.webdev.info/avatars/RrpZpplIAjR9ZZaAh1xcw
Membre enregistré
2 571 messages
Popularité : +89 (91 votes)
Posté le 08 janvier 2015 - 17:30
:merci:
//hostimage.webdev.info/avatars/RrpZpplIAjR9ZZaAh1xcw
Membre enregistré
2 571 messages
Popularité : +89 (91 votes)
Posté le 08 janvier 2015 - 17:33
Informação adicional

http://doc.windev.com/en-US/…
//hostimage.webdev.info/avatars/RrpZpplIAjR9ZZaAh1xcw
Membre enregistré
2 571 messages
Popularité : +89 (91 votes)
Posté le 03 février 2017 - 14:46
Exemplo

Procedure Existdatabase(TOKEN, CNPJ)

ok is boolean = False

Resultado, Msg is string = ""

IF TOKEN = GloToken AND CNPJ <> "" AND Length(CNPJ) = 14 AND IsNumeric(CNPJ) = True

OkConn is boolean = HConnectionOpen(ConnModel)

IF OkConn = True THEN

SQL_Exec is string = [
sp_roteiroinicial01_existdatabase '@CNPJ@'
]

SQL_Exec = Replace(SQL_Exec,"@CNPJ@",CNPJ,IgnoreCase+WholeWord) //Instrucao SQL

QryAdriano is Data Source

ok = HExecuteSQLQuery(QryAdriano, ConnModel,hQueryWithoutCorrection, SQL_Exec) // <---Obrigatorio ter hQueryWithoutCorrection

Resultado = ErrorInfo() + " " + HErrorInfo()


IF ok = True THEN

FOR EACH QryAdriano
IF HFound(QryAdriano) = True
Msg = QryAdriano.Existe
END
END

HFreeQuery(QryAdriano)

END


ELSE
Msg = "Erro de conexão com o servidor"
END

ELSE

Msg = "Token errado ou CNPJ errado"

END

RESULT (Msg)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/