用codesmith能否生成访问oracle的存储过程?

不知道能不能用,我看provider只有2种,一种为sqlSchemaprovider,还有一个为adoxschemaprovider,模板写好后,编译就提示错误,


在对应所需名称或序数的集合中,未找到项目。

An error of type "COMException" occured while attempting to execute this template.  To enable Just-In-Time debugging on this template set the "Debug" attribute to "True" in the "CodeTemplate" directive and add a "Debugger.Break()" statement in the template.

下面为我的模板
<%@ CodeTemplate Language="C#" TargetLanguage="T-SQL"
      Description="Generates a update stored procedure." %>
 
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema"
      Category="Context"
      Description="Table that the stored procedures should be based on." %>
 
<%@ Assembly Name="SchemaExplorer" %>
 
<%@ Import Namespace="SchemaExplorer" %>
     
<script runat="template">
public string GetSqlParameterStatement(ColumnSchema column)
{
      string param = "@" + column.Name + " " + column.NativeType;
 
      switch (column.DataType)
      {
            case DbType.Decimal:
            {
                  param += "(" + column.Precision + ", " + column.Scale + ")";
                  break;
            }
            default:
            {
                  if (column.Size > 0)
                  {
                        param += "(" + column.Size + ")";
                  }
                  break;
            }
      }
 
      return param;
}
</script>
 
-----------------------------------------------------------------
-- Date Created: <%= DateTime.Now.ToLongDateString() %>
-- Created By:   Generated by CodeSmith
-----------------------------------------------------------------
 
CREATE PROCEDURE dbo.Update<%= SourceTable.Name %>
      <% for (int i = 0; i < SourceTable.Columns.Count; i++) { %>
      <%= GetSqlParameterStatement(SourceTable.Columns[i]) %><% if (i < SourceTable.Columns.Count - 1) { %>,<% } %>
      <% } %>
AS
 
UPDATE [<%= SourceTable.Name %>] SET
      <% for (int i = 0; i < SourceTable.NonPrimaryKeyColumns.Count; i++) { %>
      [<%= SourceTable.NonPrimaryKeyColumns[i].Name %>] = @<%= SourceTable.NonPrimaryKeyColumns[i].Name %><% if (i < SourceTable.NonPrimaryKeyColumns.Count - 1) { %>,<% } %>
      <% } %>
WHERE
      <% for (int i = 0; i < SourceTable.PrimaryKey.MemberColumns.Count; i++) { %>
      <% if (i > 0) { %>AND <% } %>
      [<%= SourceTable.PrimaryKey.MemberColumns[i].Name %>] = @<%= SourceTable.PrimaryKey.MemberColumns[i].Name %>
      <% } %>
sql server已经通过了。oracle则提示上面的错误。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值