I am trying to insert the results of an Access DAO recordset into an Oracle table through OO4O. The code is detailed below, from which I keep getting the error
SQL execution error, ORA-00984: column not allowed here
I have checked for solutions on the net and all seem to point towards a problem with inserting data details, the last column in my code is date but it has been formatted as text so don't see why it's causing the error. I have run the insert directly in SQL*Plus and it works fine using the data as from the first record of the recordset.
Can anyone out there please help?
SQL execution error, ORA-00984: column not allowed here
I have checked for solutions on the net and all seem to point towards a problem with inserting data details, the last column in my code is date but it has been formatted as text so don't see why it's causing the error. I have run the insert directly in SQL*Plus and it works fine using the data as from the first record of the recordset.
Can anyone out there please help?
Code:
Dim OraSession As OraSession
Dim OraDatabase As OraDatabase
Dim OraDynaset As OraDynaset
Dim sqlStatement As OraSqlStmt
Dim rsDetails As Recordset
' Using OO4O
' ---------------------------
'Create the OraSession Object.
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
'Create the OraDatabase Object by opening a connection to Oracle.
Set OraDatabase = OraSession.OpenDatabase("mis1", "apeapp/oracle", 0&)
' Set to auto commit after running of sql
OraDatabase.AutoCommit = True
' Do the Appends to Max_Archive and PolicyPremium
If RsControl!QueryName = "U_Q00018" Then
strSQL = "SELECT DISTINCT DPOLICY.Year_no as Yrno, DPOLICY.Week_no as Wkno, 'DUB' AS SysType, DPOLICY.POL_NUMBER, DPOLICY.AGENT_NUMB," _
& "CobeType.Kind_Code as KC, CobeType.Version as Ver, CobeType.Product_Type as PType, StatusCodes.Indicator, DPOLICY.ANNUAL_P, DPOLICY.FREQUENCY, " _
& "DPOLICY.COBE as cobe1, DPOLICY.ADDL_CONT, cstr(format(DPOLICY.COMMENCE_DATE,'dd-mmm-yy')) as ComDate FROM (DPOLICY LEFT JOIN CobeType " _
& "ON DPOLICY.COBE = CobeType.COBE) LEFT JOIN StatusCodes ON DPOLICY.STATUS = StatusCodes.Code WHERE DPOLICY.Year_no=" & BaseTablesActualYear & " AND DPOLICY.Week_no=" & BaseTablesActualWeek & ";"
' openrecordset rsDetails from strSQL
Set rsDetails = db.OpenRecordset(strSQL)
' loop through rsDetails and append to PolicyPremium
Do Until rsDetails.EOF
OraDatabase.ExecuteSQL ("INSERT INTO PolicyPremium (YEAR_NO, WEEK_NO, SYSTEM_TYPE, POLICY_NO, AGENT_NO, KIND_CODE, VERSION, PRODUCT_TYPE, STATUS, PREMIUM, FREQ, COBE, ADD_CON, COMMENCE_DATE ) " _
& "values (rsDetails.yrno, rsDetails.wkno, rsDetails.systype, rsDetails.pol_number, rsDetails.agent_numb, rsDetails.kc, rsDetails.ver, rsDetails.ptype, rsDetails.indicator, rsDetails.annual_p, rsDetails.frequency, rsDetails.cobe1, rsDetails.addl_cont, rsDetails.comdate)")
Loop
ElseIf RsControl!QueryName = "U_Q00042" Then
strSQL = "SELECT Max.* FROM Max;"
' openrecordset rsDetails from strSQL
Set rsDetails = db.OpenRecordset(strSQL)
' loop through rsDetails and append to Max_Archive
Do Until rsDetails.EOF
OraDatabase.ExecuteSQL ("INSERT INTO Max_Archive ( YEAR_NO, WEEK_NO, MAX_YEAR_NO, MAX_WEEK_NO, SYSTEM_TYPE, POLICY_NO, KIND_CODE, VERSION, PRODUCT_TYPE, AGENT_NO, COMMENCE_DATE, STATUS, PREMIUM, FREQ, COBE, ADD_CON, PREMIUMAPETYPE, PREMIUMAPEAMOUNT, ADDCONAPETYPE, ADDCONAPEAMOUNT, APE, CONVERTED, CANCELLED ) " _
& "values (rsDetails.Year_no , rsDetails.Week_no, rsDetails.Max_Year_no, rsDetails.Max_Week_no, rsDetails.System_Type, rsDetails.Policy_no, rsDetails.Kind_Code, rsDetails.Version, rsDetails.Product_type, rsDetails.Agent_no, rsDetails.Commence_Date, rsDetails.Status, rsDetails.Premium, rsDetails.Freq, rsDetails.COBE, rsDetails.Add_Con, rsDetails.PremiumAPEType, rsDetails.PremiumAPEAmount, rsDetails.AddConAPEType, rsDetails.AddConAPEAmount, rsDetails.APE, rsDetails.Converted, rsDetails.Cancelled)")
Loop
End If
OraDatabase.Close