OCLOperators sqlpassthrough
No edit summary |
No edit summary |
||
(15 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
Example of how the OCL | <message>Write the content here to display this box</message> | ||
SomeClass.sqlpassthrough('SqlExpression',Type1OfTupleResult,Type2OfTupleResult,...) | |||
'''Note''': There is also the operator, [[Documentation:OCLOperators PSEval|OCLOperators PSEval]], that uses OCL instead of SQL. | |||
'''Example of how the OCL looks like to call a stored procedure:''' | |||
Anvandare.sqlpassthrough('sp_Upd_Losen ' + self.AnvId.asString + ', \<nowiki>''</nowiki> + self.Anvandarnamn + '\', @aNyttLosenord', Int32) | Anvandare.sqlpassthrough('sp_Upd_Losen ' + self.AnvId.asString + ', \<nowiki>''</nowiki> + self.Anvandarnamn + '\', @aNyttLosenord', Int32) | ||
'''NOTES:''' | |||
* @aNyttLosenord here is automatically available because it's a variable available when the function is called | * @aNyttLosenord here is automatically available because it's a variable available when the function is called. | ||
* You need to quote strings to be passed (if they aren't variables), like ''self.Anvandarnamn'' above. The \' is an escaped quote in OCL ([[Escape codes]]) | * You need to quote strings to be passed (if they aren't variables), like ''self.Anvandarnamn'' above. The \' is an escaped quote in OCL ([[Documentation:Escape codes|Escape codes]]). | ||
* Int32 at the end is the SQL server return code | * [[Documentation:Int32|Int32]] at the end is the [[Documentation:SQL|SQL]] server return code. | ||
A use case and examples of using sqlPassThrough can be found here "[[PSExpression , or how to do things in the DB from MDriven]]" | * Your expression starts with a '''[[Documentation:Class|class]],''' not an [[Documentation:Objects|object]]. | ||
A use case and examples of using sqlPassThrough can be found here: "[[Documentation:PSExpression , or how to do things in the DB from MDriven|PSExpression, or how to do things in the DB from MDriven]]" | |||
Also look here [[OCLOperators sqlpassthroughobjects]] | '''Note also''' that the sqlPassthrough can create [[Documentation:Tuple|tuples]]: | ||
AccountPlan.SQLPassthrough('select somekey,sum(somestuff),sum(someotherstuff) from table1,2,3 where ...',String,Integer,Integer)->collect(xtuple|let xobject=SomeNewTransient.Create in (xobject.Key:=xtuple.Part1;xobject.SomeSum:=xtuple.Part2)) | |||
'''Also, look here:''' [[Documentation:OCLOperators sqlpassthroughobjects|OCLOperators sqlpassthroughobjects]], [[Documentation:OCLOperators PSEval|PSEval]], [[Documentation:OCLOperators PSEvalValue|PSEvalValue]], [[Documentation:OCLOperators PSEvalTuples|PSEvalTuples]] | |||
[[Category:OCLOperators]] | [[Category:OCLOperators]] | ||
{{Edited|July|12|2025}} |
Latest revision as of 05:40, 4 February 2025
This page was created by Hans.karlsen@mdriven.net on 2018-01-08. Last edited by Stephanie@mdriven.net on 2025-02-04.
SomeClass.sqlpassthrough('SqlExpression',Type1OfTupleResult,Type2OfTupleResult,...)
Note: There is also the operator, OCLOperators PSEval, that uses OCL instead of SQL.
Example of how the OCL looks like to call a stored procedure:
Anvandare.sqlpassthrough('sp_Upd_Losen ' + self.AnvId.asString + ', \'' + self.Anvandarnamn + '\', @aNyttLosenord', Int32)
NOTES:
- @aNyttLosenord here is automatically available because it's a variable available when the function is called.
- You need to quote strings to be passed (if they aren't variables), like self.Anvandarnamn above. The \' is an escaped quote in OCL (Escape codes).
A use case and examples of using sqlPassThrough can be found here: "PSExpression, or how to do things in the DB from MDriven"
Note also that the sqlPassthrough can create tuples:
AccountPlan.SQLPassthrough('select somekey,sum(somestuff),sum(someotherstuff) from table1,2,3 where ...',String,Integer,Integer)->collect(xtuple|let xobject=SomeNewTransient.Create in (xobject.Key:=xtuple.Part1;xobject.SomeSum:=xtuple.Part2))
Also, look here: OCLOperators sqlpassthroughobjects, PSEval, PSEvalValue, PSEvalTuples