Code Generation of Stored Procedures with examples

This is an article on code generation of stored procedures with examples.

 

Here is the main outline of the stored procedure generation template

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;
<xsl:output method=”text” standalone=”yes”>
<xsl:preserve-space elements=”row”>
<xsl:template match=”/”>

</xsl:template>

</xsl:preserve-space>

</xsl:output>

!— BODY

This is how to construct the insert body.

INSERT INTO <xsl:value-of select=”$name”> (<xsl:for-each select=”columns/row”>
<xsl:value-of select=”@COLUMN_NAME”>
<xsl:if test=”position() != last()”>, </xsl:if>
</xsl:value-of>)
VALUES (<xsl:for-each select=”columns/row”>@<xsl:value-of select=”@COLUMN_NAME”>
<xsl:if test=”position() != last()”>, </xsl:if>
</xsl:value-of>)
</xsl:for-each></xsl:for-each></xsl:value-of>

 

With this as a stub it will be easy to create the script. 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s