<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Elton's Ark : MDAC</title><link>http://blogs.msdn.com/elton/archive/tags/MDAC/default.aspx</link><description>Tags: MDAC</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>work-around on PLS-00103 error</title><link>http://blogs.msdn.com/elton/archive/2006/07/31/683624.aspx</link><pubDate>Mon, 31 Jul 2006 04:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:683624</guid><dc:creator>Elton</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/elton/comments/683624.aspx</comments><wfw:commentRss>http://blogs.msdn.com/elton/commentrss.aspx?PostID=683624</wfw:commentRss><description>&lt;P&gt;If&amp;nbsp;a stored procedure has a default value parameter defined&amp;nbsp;in Oracle (8i)&amp;nbsp;backend and you want to call this stored procedure using ADO with MSDAORA provider, it may fail and return a error message for some scenarios, for example:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Stored Procedure:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;CREATE OR REPLACE PROCEDURE SP001( InParam IN NUMBER DEFAULT 25, OutParam OUT NUMBER) AS&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;BEGIN &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;OutParam := InParam; &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;END SP001;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client side program:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Sub Main()&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Dim cn As New ADODB.Connection&lt;BR&gt;Dim cmd As New ADODB.Command&lt;BR&gt;Dim vExpected As Variant&lt;BR&gt;Dim vActual As Variant&lt;BR&gt;Dim iInParamVal As Integer&lt;BR&gt;Dim iOutParamVal As Integer&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;cn.Open "Provider=MSDAORA.1;Password=******;User ID=******;Data Source=ORA81EN"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;On Error GoTo ERR_HANDLER&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;cmd.ActiveConnection = cn&lt;BR&gt;cmd.CommandText = "SP001"&lt;BR&gt;cmd.CommandType = adCmdStoredProc&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;' Setup input param&lt;BR&gt;Set param = cmd.CreateParameter(stInParamName, adInteger, adParamInput, 4, &lt;FONT color=#ff0000&gt;&lt;STRONG&gt;Empty&lt;/STRONG&gt;&lt;/FONT&gt;)&lt;BR&gt;cmd.Parameters.Append param&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;' Setup output param&lt;BR&gt;Set param = cmd.CreateParameter(stOutParamName, adInteger, adParamOutput, 4)&lt;BR&gt;cmd.Parameters.Append param&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;cmd.Execute&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;vExpected = 25&lt;BR&gt;vActual = cmd(0).Value&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;If vExpected &amp;lt;&amp;gt; vActual Then MsgBox "compare failed"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;cn.Close&lt;BR&gt;Exit Sub&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ERR_HANDLER:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox Err.Number &amp;amp; "&amp;nbsp; &amp;lt;-&amp;gt;&amp;nbsp; " &amp;amp; Err.Description&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resume Next&lt;BR&gt;End Sub&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;After execute the client program,&amp;nbsp;an error message returned:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color=#ff0000&gt;-2147217900, ORA-06550: line **, column **:&lt;BR&gt;PLS-00103: Encountered the symbol "&amp;gt;" when expecting one of the following:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;. ( ) , * @ % &amp;amp; = - + &amp;lt; / &amp;gt; at in mod not rem&lt;BR&gt;&amp;lt;an exponent (**)&amp;gt; &amp;lt;&amp;gt; or != or ~= &amp;gt;= &amp;lt;= &amp;lt;&amp;gt; and or like&lt;BR&gt;between is null is not || is dangling&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This case works fine with SQL Server backend or use MSDASQL-ORA driver with Oracle backend, but it fails with MSDAORA provider. Then how could we do if want to use the default value of the stored procedure in this scenario?&lt;/P&gt;
&lt;P&gt;The solution (or work-around) is to re-define the stored procedure and transpose the input parameter and output parameter,&amp;nbsp;just like this:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;CREATE OR REPLACE PROCEDURE SP001(&lt;FONT color=#ff0000&gt;&lt;STRONG&gt;OutParam OUT NUMBER,&amp;nbsp;InParam IN NUMBER DEFAULT 25&lt;/STRONG&gt;&lt;/FONT&gt;) AS&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;BEGIN &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;OutParam := InParam; &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;END SP001;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;##########################&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In client program, only append the output parameter and execute the COMMAND to call the stored procedure. Then the case will run successfully.&lt;/P&gt;
&lt;P&gt;The reason I guess may be this:&lt;/P&gt;
&lt;P&gt;In PL/SQL, if you want to call this stored procedure, the code should be like "SP001(OutParam =&amp;gt; variable)", variable is used to store the output value. After we transpose the input and output parameter, the calling code could be like "SP001(variable)". I guess MSDAORA provider compose an invalid SQL clause. (maybe use "=" instead of "=&amp;gt;")&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=683624" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/elton/archive/tags/MDAC/default.aspx">MDAC</category></item></channel></rss>