Calling a database stored function or stored proc that returns a valueOutput Parameter not Returned from Stored ProcFunction vs. Stored Procedure in SQL ServerDateTime parameter when calling stored function from java codeCalling a stored proc that returns a recordset from within a stored procC# SQL Server - Passing a list to a stored procedurecalling Oracle stored procedures in R - how to get the result set?Oracle query in a proc not returning resultsUsage of stored functions in entity frameworkUnable to retrieve out params from Oracle stored procedure in C#Call SQL stored proc with OUTPUT param from another stored proc
Why is the Digital 0 not 0V in computer systems?
In Germany, how can I maximize the impact of my charitable donations?
What is the CR of a Metallic Dragon that used Change Shape?
What was redacted in the Yellowhammer report? (Point 15)
How do EVA suits manage water excretion?
Is there a reliable way to hide/convey a message in vocal expressions (speech, song,...)
Stucturing information on this trade show banner
What is the purpose of this tool?
What hard drive connector is this?
"Literally" Vs "In the true sense of the word"
Why don't Wizards use wrist straps to protect against disarming charms?
Why does the speed of sound decrease at high altitudes although the air density decreases?
Write a function that returns an iterable object of all valid points 4-directionally adjacent to (x, y)
Diffraction of a wave passing through double slits
How to stabilise the bicycle seatpost and saddle when it is all the way up?
Can a warforged druid use composite plating?
Are scroll bars dead in 2019?
What officially disallows US presidents from driving?
How do email clients "send later" without storing a password?
Is a suit against a University Dorm for changing policies on a whim likely to succeed (USA)?
Why do sellers care about down payments?
Were Roman public roads build by private companies?
A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?
What's the biggest organic molecule that could have a smell?
Calling a database stored function or stored proc that returns a value
Output Parameter not Returned from Stored ProcFunction vs. Stored Procedure in SQL ServerDateTime parameter when calling stored function from java codeCalling a stored proc that returns a recordset from within a stored procC# SQL Server - Passing a list to a stored procedurecalling Oracle stored procedures in R - how to get the result set?Oracle query in a proc not returning resultsUsage of stored functions in entity frameworkUnable to retrieve out params from Oracle stored procedure in C#Call SQL stored proc with OUTPUT param from another stored proc
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Using linq2db with an oracle 12 database, how can I call a stored function or a stored procedure that returns a value? From the info I could find, the solution seemed to be to use:
IEnumerable<T> QueryProc<T>(
this DataConnection connection,
string sql,
params DataParameter[] parameters);
But it doesn't work with functions and with a stored proc, I do not receive the output value from the proc.
create or replace PROCEDURE TESTPROC(inputParm VARCHAR2, outputParm OUT VARCHAR2)
IS
BEGIN
outputParm := 'TEST OUTPUT STRING';
END TESTPROC;
I call it with linq2db the following way:
DataParameter[] para = new DataParameter("inputParm", "some_string", DataType.VarChar), new DataParameter("outputParm", "", DataType.VarChar) ;
var res = myDataContext.QueryProc<string>("TESTPROC", para).FirstOrDefault();
What am I doing wrong?
c# oracle stored-procedures stored-functions linq2db
add a comment
|
Using linq2db with an oracle 12 database, how can I call a stored function or a stored procedure that returns a value? From the info I could find, the solution seemed to be to use:
IEnumerable<T> QueryProc<T>(
this DataConnection connection,
string sql,
params DataParameter[] parameters);
But it doesn't work with functions and with a stored proc, I do not receive the output value from the proc.
create or replace PROCEDURE TESTPROC(inputParm VARCHAR2, outputParm OUT VARCHAR2)
IS
BEGIN
outputParm := 'TEST OUTPUT STRING';
END TESTPROC;
I call it with linq2db the following way:
DataParameter[] para = new DataParameter("inputParm", "some_string", DataType.VarChar), new DataParameter("outputParm", "", DataType.VarChar) ;
var res = myDataContext.QueryProc<string>("TESTPROC", para).FirstOrDefault();
What am I doing wrong?
c# oracle stored-procedures stored-functions linq2db
add a comment
|
Using linq2db with an oracle 12 database, how can I call a stored function or a stored procedure that returns a value? From the info I could find, the solution seemed to be to use:
IEnumerable<T> QueryProc<T>(
this DataConnection connection,
string sql,
params DataParameter[] parameters);
But it doesn't work with functions and with a stored proc, I do not receive the output value from the proc.
create or replace PROCEDURE TESTPROC(inputParm VARCHAR2, outputParm OUT VARCHAR2)
IS
BEGIN
outputParm := 'TEST OUTPUT STRING';
END TESTPROC;
I call it with linq2db the following way:
DataParameter[] para = new DataParameter("inputParm", "some_string", DataType.VarChar), new DataParameter("outputParm", "", DataType.VarChar) ;
var res = myDataContext.QueryProc<string>("TESTPROC", para).FirstOrDefault();
What am I doing wrong?
c# oracle stored-procedures stored-functions linq2db
Using linq2db with an oracle 12 database, how can I call a stored function or a stored procedure that returns a value? From the info I could find, the solution seemed to be to use:
IEnumerable<T> QueryProc<T>(
this DataConnection connection,
string sql,
params DataParameter[] parameters);
But it doesn't work with functions and with a stored proc, I do not receive the output value from the proc.
create or replace PROCEDURE TESTPROC(inputParm VARCHAR2, outputParm OUT VARCHAR2)
IS
BEGIN
outputParm := 'TEST OUTPUT STRING';
END TESTPROC;
I call it with linq2db the following way:
DataParameter[] para = new DataParameter("inputParm", "some_string", DataType.VarChar), new DataParameter("outputParm", "", DataType.VarChar) ;
var res = myDataContext.QueryProc<string>("TESTPROC", para).FirstOrDefault();
What am I doing wrong?
c# oracle stored-procedures stored-functions linq2db
c# oracle stored-procedures stored-functions linq2db
edited Apr 1 at 8:44
Uwe Keim
28.2k33 gold badges142 silver badges228 bronze badges
28.2k33 gold badges142 silver badges228 bronze badges
asked Mar 28 at 10:30
John VolkyaJohn Volkya
5233 gold badges11 silver badges29 bronze badges
5233 gold badges11 silver badges29 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
Update: updated answer to be correct
IEnumerable<T> QueryProc<T>(...)
return value is a data set, returned by procedure/function by select statement.
If your procedure doesn't return table, you need to use non-generic version of ExecuteProc
, which just returns number of affected records.
To get output parameter value you need to access parameter in command:((IDbDataParameter)dataConnection.Command.Parameters["parameter_name"]).Value
below is an example of procedure call helper from linq2db tests, generatedd by T4 template:
public static int OUTREFTEST(this DataConnection dataConnection, decimal? PID, out decimal? POUTPUTID, ref decimal? PINPUTOUTPUTID, string PSTR, out string POUTPUTSTR, ref string PINPUTOUTPUTSTR)
var ret = dataConnection.ExecuteProc("TESTUSER.OUTREFTEST",
new DataParameter("PID", PID, DataType.Decimal),
new DataParameter("POUTPUTID", null, DataType.Decimal) Direction = ParameterDirection.Output, Size = 22 ,
new DataParameter("PINPUTOUTPUTID", PINPUTOUTPUTID, DataType.Decimal) Direction = ParameterDirection.InputOutput, Size = 22 ,
new DataParameter("PSTR", PSTR, DataType.NVarChar),
new DataParameter("POUTPUTSTR", null, DataType.NVarChar) Direction = ParameterDirection.Output ,
new DataParameter("PINPUTOUTPUTSTR", PINPUTOUTPUTSTR, DataType.NVarChar) Direction = ParameterDirection.InputOutput );
POUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTID"]). Value);
PINPUTOUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTID"]). Value);
POUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTSTR"]). Value);
PINPUTOUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTSTR"]).Value);
return ret;
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395359%2fcalling-a-database-stored-function-or-stored-proc-that-returns-a-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update: updated answer to be correct
IEnumerable<T> QueryProc<T>(...)
return value is a data set, returned by procedure/function by select statement.
If your procedure doesn't return table, you need to use non-generic version of ExecuteProc
, which just returns number of affected records.
To get output parameter value you need to access parameter in command:((IDbDataParameter)dataConnection.Command.Parameters["parameter_name"]).Value
below is an example of procedure call helper from linq2db tests, generatedd by T4 template:
public static int OUTREFTEST(this DataConnection dataConnection, decimal? PID, out decimal? POUTPUTID, ref decimal? PINPUTOUTPUTID, string PSTR, out string POUTPUTSTR, ref string PINPUTOUTPUTSTR)
var ret = dataConnection.ExecuteProc("TESTUSER.OUTREFTEST",
new DataParameter("PID", PID, DataType.Decimal),
new DataParameter("POUTPUTID", null, DataType.Decimal) Direction = ParameterDirection.Output, Size = 22 ,
new DataParameter("PINPUTOUTPUTID", PINPUTOUTPUTID, DataType.Decimal) Direction = ParameterDirection.InputOutput, Size = 22 ,
new DataParameter("PSTR", PSTR, DataType.NVarChar),
new DataParameter("POUTPUTSTR", null, DataType.NVarChar) Direction = ParameterDirection.Output ,
new DataParameter("PINPUTOUTPUTSTR", PINPUTOUTPUTSTR, DataType.NVarChar) Direction = ParameterDirection.InputOutput );
POUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTID"]). Value);
PINPUTOUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTID"]). Value);
POUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTSTR"]). Value);
PINPUTOUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTSTR"]).Value);
return ret;
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
add a comment
|
Update: updated answer to be correct
IEnumerable<T> QueryProc<T>(...)
return value is a data set, returned by procedure/function by select statement.
If your procedure doesn't return table, you need to use non-generic version of ExecuteProc
, which just returns number of affected records.
To get output parameter value you need to access parameter in command:((IDbDataParameter)dataConnection.Command.Parameters["parameter_name"]).Value
below is an example of procedure call helper from linq2db tests, generatedd by T4 template:
public static int OUTREFTEST(this DataConnection dataConnection, decimal? PID, out decimal? POUTPUTID, ref decimal? PINPUTOUTPUTID, string PSTR, out string POUTPUTSTR, ref string PINPUTOUTPUTSTR)
var ret = dataConnection.ExecuteProc("TESTUSER.OUTREFTEST",
new DataParameter("PID", PID, DataType.Decimal),
new DataParameter("POUTPUTID", null, DataType.Decimal) Direction = ParameterDirection.Output, Size = 22 ,
new DataParameter("PINPUTOUTPUTID", PINPUTOUTPUTID, DataType.Decimal) Direction = ParameterDirection.InputOutput, Size = 22 ,
new DataParameter("PSTR", PSTR, DataType.NVarChar),
new DataParameter("POUTPUTSTR", null, DataType.NVarChar) Direction = ParameterDirection.Output ,
new DataParameter("PINPUTOUTPUTSTR", PINPUTOUTPUTSTR, DataType.NVarChar) Direction = ParameterDirection.InputOutput );
POUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTID"]). Value);
PINPUTOUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTID"]). Value);
POUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTSTR"]). Value);
PINPUTOUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTSTR"]).Value);
return ret;
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
add a comment
|
Update: updated answer to be correct
IEnumerable<T> QueryProc<T>(...)
return value is a data set, returned by procedure/function by select statement.
If your procedure doesn't return table, you need to use non-generic version of ExecuteProc
, which just returns number of affected records.
To get output parameter value you need to access parameter in command:((IDbDataParameter)dataConnection.Command.Parameters["parameter_name"]).Value
below is an example of procedure call helper from linq2db tests, generatedd by T4 template:
public static int OUTREFTEST(this DataConnection dataConnection, decimal? PID, out decimal? POUTPUTID, ref decimal? PINPUTOUTPUTID, string PSTR, out string POUTPUTSTR, ref string PINPUTOUTPUTSTR)
var ret = dataConnection.ExecuteProc("TESTUSER.OUTREFTEST",
new DataParameter("PID", PID, DataType.Decimal),
new DataParameter("POUTPUTID", null, DataType.Decimal) Direction = ParameterDirection.Output, Size = 22 ,
new DataParameter("PINPUTOUTPUTID", PINPUTOUTPUTID, DataType.Decimal) Direction = ParameterDirection.InputOutput, Size = 22 ,
new DataParameter("PSTR", PSTR, DataType.NVarChar),
new DataParameter("POUTPUTSTR", null, DataType.NVarChar) Direction = ParameterDirection.Output ,
new DataParameter("PINPUTOUTPUTSTR", PINPUTOUTPUTSTR, DataType.NVarChar) Direction = ParameterDirection.InputOutput );
POUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTID"]). Value);
PINPUTOUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTID"]). Value);
POUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTSTR"]). Value);
PINPUTOUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTSTR"]).Value);
return ret;
Update: updated answer to be correct
IEnumerable<T> QueryProc<T>(...)
return value is a data set, returned by procedure/function by select statement.
If your procedure doesn't return table, you need to use non-generic version of ExecuteProc
, which just returns number of affected records.
To get output parameter value you need to access parameter in command:((IDbDataParameter)dataConnection.Command.Parameters["parameter_name"]).Value
below is an example of procedure call helper from linq2db tests, generatedd by T4 template:
public static int OUTREFTEST(this DataConnection dataConnection, decimal? PID, out decimal? POUTPUTID, ref decimal? PINPUTOUTPUTID, string PSTR, out string POUTPUTSTR, ref string PINPUTOUTPUTSTR)
var ret = dataConnection.ExecuteProc("TESTUSER.OUTREFTEST",
new DataParameter("PID", PID, DataType.Decimal),
new DataParameter("POUTPUTID", null, DataType.Decimal) Direction = ParameterDirection.Output, Size = 22 ,
new DataParameter("PINPUTOUTPUTID", PINPUTOUTPUTID, DataType.Decimal) Direction = ParameterDirection.InputOutput, Size = 22 ,
new DataParameter("PSTR", PSTR, DataType.NVarChar),
new DataParameter("POUTPUTSTR", null, DataType.NVarChar) Direction = ParameterDirection.Output ,
new DataParameter("PINPUTOUTPUTSTR", PINPUTOUTPUTSTR, DataType.NVarChar) Direction = ParameterDirection.InputOutput );
POUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTID"]). Value);
PINPUTOUTPUTID = Converter.ChangeTypeTo<decimal?>(((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTID"]). Value);
POUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["POUTPUTSTR"]). Value);
PINPUTOUTPUTSTR = Converter.ChangeTypeTo<string> (((IDbDataParameter)dataConnection.Command.Parameters["PINPUTOUTPUTSTR"]).Value);
return ret;
edited Apr 1 at 14:03
answered Apr 1 at 8:39
DLukDLuk
6694 silver badges10 bronze badges
6694 silver badges10 bronze badges
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
add a comment
|
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
It doesn't work with a function, I get an error saying the proc is not found. If I use a proc with out parameter, the result is not set in the para[1].Value as you mention.
– John Volkya
Apr 1 at 12:37
my bad, updated answer
– DLuk
Apr 1 at 14:03
my bad, updated answer
– DLuk
Apr 1 at 14:03
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
Thanks! It seems to be working like this.
– John Volkya
Apr 1 at 15:57
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395359%2fcalling-a-database-stored-function-or-stored-proc-that-returns-a-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown