To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=62956
                  Issue #:|62956
                  Summary:|SQLException can cause C++ runtime error
                Component:|Database access
                  Version:|OOo 2.0.2
                 Platform:|All
                      URL:|
               OS/Version:|Windows XP
                   Status:|UNCONFIRMED
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|none
              Assigned to:|dbaneedsconfirm
              Reported by:|atjensen





------- Additional comments from [EMAIL PROTECTED] Wed Mar  8 23:17:58 -0800 
2006 -------
The following situation can cause OO.o to terminate with a Visual C++ runtime 
error.

First - you need to copy the follwoing basic procedures into a library

sub onClickApplyAllAdjustments( oEv as variant )
        dim tmpAdjustments as variant

        tmpAdjustments = oEv.Source.Model.Parent
        with tmpAdjustments
                'if .RowInserted then
                if .isNew then
                        .InsertRow
                end if
                do
                        .First
                        
spInvAdjustment(tmpAdjustments.Columns.getByName("ProductID").getInt , _
                                        
tmpAdjustments.Columns.getByName("AdjDate").getDate, _
                                        
tmpAdjustments.Columns.getByName("AdjType").getInt, _
                                        
tmpAdjustments.Columns.getByName("Units").getInt, _
                                        tmpAdjustments.ActiveConnection )       
                        .DeleteRow
                loop until .isAfterLast
        end with

end sub

sub spInvAdjustment( ProductID AS INTEGER, AdjDate AS new
com.sun.star.util.Date, AdjType AS INTEGER, Units AS INTEGER, dbConnection as
variant )
                ' just for convienence a string
                ' to build our sql commands
        dim sSQL as string
                ' a variable for the stock adjustment 
                ' type to perform
        dim StockType as integer
                ' and some constants for what it means
                ' for readability
        const cPullDown         = 1
        const cReplenish        = 2
                ' a variable for a prepared statement
                ' object that lets us apply SQL 
                ' commands to the databse
        dim pStmt as variant
                ' a record set variable
        dim rs as variant
                ' a variable for the amount
                ' to change the inventory by
        dim StkUnits as integer

        sSQL = "Select ""StockType"" FROM ""AdjustmentTypes"" WHERE ""AdjType"" 
= ? "
        pStmt = dbConnection.PrepareStatement( sSQL )
        pStmt.setInt( 1, AdjType )
        rs = pStmt.ExecuteQuery
                ' we should have gotten back one record
        if not rs.isBeforeFirst then
                ' if we are not before the first record
                ' then we got back zero records
                print "oops I don't know that Adjustment type"
                exit sub
        else
                ' move to the first record
                ' and retrive the value from 
                ' the frist column as an integer
                rs.next
                StockType = rs.getInt( 1 )
        end if
                ' so the next step is to actually
                ' write our data to the InvAdjustments
                ' table - we can resuse our prepared 
                ' statement for this
        sSQL = "INSERT INTO ""InvAdjustments"" ( ""ProductID"", ""AdjDate"",
""AdjType"", ""Units"" ) VALUES ( ?,?,?,? ) "
        pStmt = dbConnection.PrepareStatement( sSQL )
        pStmt.setInt( 1, ProductID )
        pStmt.setDate( 2, AdjDate )
        pStmt.setInt( 3, AdjType )
        pStmt.setInt( 4, Units )
        pStmt.executeUpdate
                ' here we decide what we will do
                ' about the inventory items in stock
        select case StockType
                case cPullDown
                        StkUnits = Units * -1.0
                case cReplenish
                        StkUnits = Units                
        end select
        sSQL = "UPDATE ""Products"" SET ""UnitsInStock"" = ""UnitsInStock"" + ? 
WHERE
""ProductID"" = ? "
        pStmt = dbConnection.PrepareStatement( sSQL )   
        pStmt.setInt( 1, StkUnits )
        pStmt.setInt( 2, ProductID )
        pStmt.executeUpdate
end sub

Now open the attached database, you will need to edit the form
frmMutipleAdjustments, change the buttons 'when initializing'  event entry to
point to wherever you put the procedure onClickApplyAllAdjustments.

Alright, open the form - you should see two records. Click the button.

Now, I realize that the code in the onClickApplyAllAdjustments procedure is
wrong, it loops one to many times. However, when the command .First is called
this 'once to often' time the following errors are generated.

Basic runtime error.
An exception occured
Type: com.sun.star.sdbc.SQLException
Message: The cursor points to before the first or after the last row...

Microsoft Viusal C++ Runtime Library
Runtime Error!

This applicaton has requested the Runtime to terminate it in an unusal way.
Please contact the applications support team for more information.

When OO.o is restarted the file recovery routine runs, however no crash report
is available and not offer to send such is made.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to