Can codesmith be used to generate a stored procedure for accessing oracle?

Source: Internet
Author: User
I don't know if it can be used. I think there are only two types of providers, one is sqlschemaprovider and the other is adoxschemaprovider. After the template is written, an error is prompted during compilation,


The project cannot be found in the set of names or ordinal numbers.

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
"True" in the "codetemplate" directive and add a "Debugger. Break ()"
Statement in the template.

The following is my 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 shoshould 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 %>
<% }%>
The SQL Server has passed. Oracle prompts the above error.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.