Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv554
Modified Files:
PgCommand.cs PgCommandBuilder.cs
Log Message:
Added stored procedure execution using only the sp name.
Index: PgCommand.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PgCommand.cs 12 Aug 2003 19:30:13 -0000 1.3
--- PgCommand.cs 15 Aug 2003 17:49:05 -0000 1.4
***************
*** 22,25 ****
--- 22,26 ----
using System.Collections;
using System.ComponentModel;
+ using System.Text;
using System.Text.RegularExpressions;
***************
*** 307,311 ****
if (Transaction != null)
{
- // throw new InvalidOperationException("Command must have a valid Transaction.");
if (!Connection.Equals(Transaction.Connection))
{
--- 308,311 ----
***************
*** 461,468 ****
statement.Status == PgStatementStatus.Error)
{
! if (commandType == CommandType.StoredProcedure &&
! !CommandText.ToUpper().StartsWith("SELECT * FROM "))
{
! CommandText = "SELECT * FROM " + CommandText;
}
--- 461,467 ----
statement.Status == PgStatementStatus.Error)
{
! if (commandType == CommandType.StoredProcedure)
{
! CommandText = parseSPCommandText();
}
***************
*** 582,585 ****
--- 581,617 ----
#region PRIVATE_METHODS
+
+ private string parseSPCommandText()
+ {
+ string result = CommandText;
+
+ if (!commandText.Trim().ToLower().StartsWith("select "))
+ {
+ StringBuilder paramsText = new StringBuilder();
+
+ // Append the stored proc parameter name
+ paramsText.Append(CommandText);
+ paramsText.Append("(");
+ for (int i = 0; i < parameters.Count; i++)
+ {
+ if (parameters[i].Direction == ParameterDirection.Input ||
+ parameters[i].Direction == ParameterDirection.InputOutput)
+ {
+ // Append parameter name to parameter list
+ paramsText.Append(parameters[i].ParameterName);
+ if (i != parameters.Count - 1)
+ {
+ paramsText = paramsText.Append(",");
+ }
+ }
+ }
+ paramsText.Append(")");
+ paramsText.Replace(",)", ")");
+
+ result = "select * from " + paramsText.ToString();
+ }
+
+ return result;
+ }
private string getStmtName()
Index: PgCommandBuilder.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommandBuilder.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgCommandBuilder.cs 5 Aug 2003 17:59:07 -0000 1.2
--- PgCommandBuilder.cs 15 Aug 2003 17:49:05 -0000 1.3
***************
*** 191,196 ****
}
- string paramsText = String.Empty;
-
command.Parameters.Clear();
--- 191,194 ----
***************
*** 210,219 ****
parameter.Direction = ParameterDirection.Input;
-
- paramsText = paramsText + parameter.ParameterName;
- if ((i + 1) != parameterCount)
- {
- paramsText = paramsText + ",";
- }
}
--- 208,211 ----
***************
*** 227,232 ****
parameter.Direction = ParameterDirection.Output;
}
-
- command.CommandText = command.CommandText + "(" + paramsText + ")";
}
}
--- 219,222 ----
|