Page 1 of 1

Execute stored proc with table parameter

Posted: 03.02.2021, 17:39
by mtournay
Hi everybody

I have to execute this through lazarus

Code: Select all

DECLARE @result int;
DECLARE @liste AS MMEA_tableauProduits;

insert into @liste (CodeCIP, quantite) VALUES ('3400935955838', 1),('4052199014111', 1);

exec	[dbo].[MMEA_ajouteDocVente] 
		@IDF_CIP = '1234567',
		@DO_Ref = 'test',
		@Do_Type = 1,
		@listeProduits = @liste,
		@result = 0
Some explanations :
- MMEA_tableauProduits is a user defined table type
- result is output, but I don't care about it, the stored proc throw exception in case of problem

Environnement :
- lazarus 2.0.10
- zeos 7.2.8
- mssql >2012 (various prod env.)
- ntwdblib ( so far so good, no issues or missing features for the moment. AND i cannot find binaries for freetds )
- Windows !

I have no clue how i can achive this ! I may use ZStoredProc for executing the proc, ok, but how to do the beginning of the script ? Am I missing a script component ?

I've tried executing zquery for the 3 first lines, and it's not working (I've tried knowing it would fail)

Best regards

Re: Execute stored proc with table parameter

Posted: 04.02.2021, 15:46
by mtournay
Hello

I finaly found zprocessor !

I have errors, but not sure from where it comes. The code above executes well in MSSM, but not from my pascal code ...
Can't share code of the proc, so i'm on my own

Bye

Re: Execute stored proc with table parameter

Posted: 04.02.2021, 21:35
by marsupilami
Hello,

with that kind of code it might make sense to wrap it in StartTransaction / Commit. Otherwise Variables and the like might get destroyed before the next statement.

Best regards,

Jan

Re: Execute stored proc with table parameter

Posted: 04.02.2021, 22:54
by aehimself
mtournay wrote: 03.02.2021, 17:39AND i cannot find binaries for freetds )
https://ci.appveyor.com/project/FreeTDS/freetds
Choose the flavor (x86, x64, VS dependency version), click on "Artifacts" and download.
Took me a while to figure it out.

Re: Execute stored proc with table parameter

Posted: 07.02.2021, 11:06
by mtournay
Hi aehimself
aehimself wrote: 04.02.2021, 22:54 https://ci.appveyor.com/project/FreeTDS/freetds
Choose the flavor (x86, x64, VS dependency version), click on "Artifacts" and download.
Took me a while to figure it out.
I found this later that day, after cliking on all buttons and link in appveyor pages :)

Thanx !

Best regards.