Execute stored proc with table parameter

Forum related to MS SQL Server

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
mtournay
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 02.08.2018, 15:28

Execute stored proc with table parameter

Post 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
mtournay
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 02.08.2018, 15:28

Re: Execute stored proc with table parameter

Post 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
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1962
Joined: 17.01.2011, 14:17

Re: Execute stored proc with table parameter

Post 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
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 799
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Execute stored proc with table parameter

Post 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.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
mtournay
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 02.08.2018, 15:28

Re: Execute stored proc with table parameter

Post 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.
Post Reply