Forum > Databases
Parameters for a TSQLScript run?
(1/1)
Mario:
Hi,
I have a nice SQL script which does tons of stuff. I would like to have parameters in some of the statements, like in a regular TSQLQuery. Is there a simple way to do that?
I was thinking of something like this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---XScript.Script := ScriptText;XScript.SomethingSomething.ParamByName('foo', 42);XScript.Execute;
Is there something similar?
Mario:
Ok after some research and thought, I'll answer myself.
If you have SQL that is complex enough you want it in a script, and it needs parameters, you are better off installing a stored procedure in your SQL server, whatever its flavor. SQLite doesn't have stored procedures, but apparently you can fake them like this https://www.cafe-encounter.net/p3300/pretending-that-sqlite-has-stored-procedures-and-functions
Zvoni:
Looking at the the Inheritance-Tree of TSQLScript and its Methods and Properties, i think it's the wrong "tool" (Component) to use with Parameters.
1) TSQLScript is not returning a Result (Like for a SELECT)
2) It uses the Execute(Direct)-Method of its Database/Connection-Object, which in itself should only be used for non-Result Statements
i Think TSQLScript is useful for, say, reimporting a SQLDump.
All said: If you have (to use) Parameters, use TSQLQuery. Period!
Or as you said: Stored procedures if the DBMS supports it
EDIT: I was just reading that Link.
If you need help with registering your own Procedure/Function give a shout
Navigation
[0] Message Index