Oracle stored procedure owned by user with same name as reserved word fools llblgen

Posts   
 
    
like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 08-May-2006 17:02:57   

I (rather foolishly) called my oracle schema "IF" which is an oracle reserved word. I now have a package whoose full name is "IF".IF_UTILS.WOULD_BE_RELATED_TO_ITSELF. The llblgen generated code attempts to call this as:

IF.IF_UTILS.WOULD_BE_RELATED_TO_ITSELF.

which results in the error:


Source Error: 


Line 142:                   connectionOpenedLocally = True
Line 143:               End If
Line 144:               toReturn = Command.ExecuteNonQuery()
Line 145:           Finally
Line 146:               command.Dispose()


Source File: d:\Data\vss\Interfaces\InterfacesSolution\DAL\HelperClasses\DbUtils.vb Line: 144 

Stack Trace: 


[OracleException: ORA-06550: line 1, column 15:
PLS-00103: Encountered the symbol "IF" when expecting one of the following:

   ( - + case mod new not null <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> avg
   count current exists max min prior sql stddev sum variance
   execute forall merge time timestamp interval date
   <a string literal with character set specification>
   <a number> <a single-quoted SQL string> pipe
The symbol "<an identifier> was inserted before "IF" to continue.]
   Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
   Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
   Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   Fluor.Interfaces.DAL.HelperClasses.DbUtils.CallActionStoredProcedure(String storedProcedureToCall, OracleParameter[] parameters, ITransaction transactionToUse) in d:\Data\vss\Interfaces\InterfacesSolution\DAL\HelperClasses\DbUtils.vb:144
   Fluor.Interfaces.DAL.StoredProcedureCallerClasses.ActionProcedures.UtilsWouldBeRelatedToItself(Int32 pIfId, Int32 pParentIfId, Byte& returnValue) in d:\Data\vss\Interfaces\InterfacesSolution\DAL\StoredProcedureCallerClasses\ActionProcedures.vb:125
   Interfaces.EditInterfaceControl.UpdateRecord() in D:\Data\vss\Interfaces\InterfacesSolution\Interfaces\Controls\EditInterfaceControl.ascx.vb:345
   Interfaces.EditInterfaceControl.btnUpdate_Click(Object sender, EventArgs e) in D:\Data\vss\Interfaces\InterfacesSolution\Interfaces\Controls\EditInterfaceControl.ascx.vb:439
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain() +1292

I can "fix" the problem by editing my ActionsProcedures.vb to add " chars around the IF as follows:


    Public Shared Function UtilsWouldBeRelatedToItself(pIfId As System.Int32, pParentIfId As System.Int32, ByRef returnValue As System.Byte) As Integer
            ' create parameters
            Dim parameters() As OracleParameter = New OracleParameter(3 - 1) {}
            parameters(0) = New OracleParameter("RETURN_VALUE", OracleDbType.Byte, 0, ParameterDirection.ReturnValue, True, 0, 0, "",  DataRowVersion.Current, returnValue)
            parameters(1) = New OracleParameter("P_IF_ID", OracleDbType.Decimal, 0, ParameterDirection.Input, True, 9, 0, "",  DataRowVersion.Current, pIfId)
            parameters(2) = New OracleParameter("P_PARENT_IF_ID", OracleDbType.Decimal, 0, ParameterDirection.Input, True, 9, 0, "",  DataRowVersion.Current, pParentIfId)
            ' Call the stored proc.
            Dim toReturn As Integer = DbUtils.CallActionStoredProcedure("""IF"".IF_UTILS.WOULD_BE_RELATED_TO_ITSELF", parameters, Nothing)
            If Not parameters(0).Value Is System.DBNull.Value Then
                returnValue = CType(ValueConverter.Convert(parameters(0)), System.Byte)
            End If
            Dim i As Integer = 0
            For i=0 To 3-1
                If Not parameters(i) Is Nothing Then
                    parameters(i).Dispose()
                End If
            Next i
            Return toReturn
        End Function

flushed I feel almost guilty "reporting" this as a bug, but thought that you would "like" to know.

Graham

reserved word ActionProcedure.vb Encountered the symbol "IF" when expecting

Posts: 94
Joined: 26-Feb-2006
# Posted on: 08-May-2006 17:25:49   

Please Try and name your Table "WHEN" or may be WTF!

sunglasses

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39897
Joined: 17-Aug-2003
# Posted on: 08-May-2006 20:23:18   

I think you'd better rename the schema. You can do that without a lot of problems. After renaming the schema in Oracle, rename the schema in the catalog explorer to the new name, then refresh the catalog.

Frans Bouma | Lead developer LLBLGen Pro