Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Component Script is only reading 1 row in the oracle data reader

$
0
0

I am using  Foreach ADO enumerator that brings back a small amount claim id's into a data flow. I then run those claims id's in the script component below which is a datasource. Each claim can have from 0 to 5 rows of data. it works find for zero and one row of data. It doesn't work for multiple rows of data. See Script below - I am probably doing something wrong in the CreateNewOutputRows section. 

I get the following error when it runs into a claim with multiple rows. It writes the first row to the distinction - and then stops.

I don't believe this is actual error - since there are no columns set to Int32

   at Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSBuffer100.AddRow(IntPtr ppRowStart)

   at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.AddRow()

   at ScriptMain.CreateNewOutputRows()

   at UserComponent.PrimeOutput(Int32 Outputs, Int32[] OutputIDs, PipelineBuffer[] Buffers, OutputNameMap OutputMap)

   at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers)

Script is below

#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Diagnostics;
using System.Data.OracleClient;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
    string Claimid = string.Empty;
    private IDTSConnectionManager100 connMgr;
    private OracleConnection oracleConn;
    private OracleCommand oracleCmd;
    private OracleDataReader oracleRdr;
    public override void AcquireConnections(object Transaction)
    {
        connMgr = this.Connections.ORCL;
        oracleConn = (OracleConnection)connMgr.AcquireConnection(Transaction);
    }
    public override void PreExecute()
    {
        base.PreExecute();
        /*
         * Add your code here
         */
        //string claimid = Convert.ToString(dts.Variables["User::ClaimID"].Value);
        //this.VariableDispenser.LockForRead("User::ClaimID");
        Claimid = this.Variables.ClaimID;
        //MessageBox.Show (Claimid);
               string sql = "SELECT CMC_SBSB_SUBSC.SBSB_ID, CMC_CLED_EDI_DATA.CLED_EXT_REF, CMC_CLED_EDI_DATA.CLED_TRAD_PARTNER, CMC_CLED_EDI_DATA.CLCL_ID, CMC_MECB_COB.MCRE_ID, CMC_MCRE_RELAT_ENT.MCRE_NAME, CMC_MECB_COB.MECB_EFF_DT, CMC_MECB_COB.MECB_TERM_DT, CMC_MECB_COB.MECB_POLICY_ID, cast(CMC_MECB_COB.MEME_CK as nvarchar2(25)) FROM    fac.CMC_CLED_EDI_DATA LEFT JOIN fac.CMC_CLCL_CLAIM ON fac.CMC_CLED_EDI_DATA.CLCL_ID = fac.CMC_CLCL_CLAIM.CLCL_ID LEFT JOIN fac.CMC_SBSB_SUBSC ON fac.CMC_CLCL_CLAIM.SBSB_CK = fac.CMC_SBSB_SUBSC.SBSB_CK LEFT JOIN fac.CMC_MEME_MEMBER ON fac.CMC_SBSB_SUBSC.SBSB_CK = fac.CMC_MEME_MEMBER.SBSB_CK LEFT JOIN fac.CMC_MECB_COB ON fac.CMC_MEME_MEMBER.MEME_CK = fac.CMC_MECB_COB.MEME_CK LEFT JOIN fac.CMC_MCRE_RELAT_ENT ON fac.CMC_MECB_COB.MCRE_ID = fac.CMC_MCRE_RELAT_ENT.MCRE_ID WHERE fac.CMC_MECB_COB.MCRE_ID In ('10542', '11593', '11605', '11610', '11746', '11753', '19055', '19283', '19302', '19977', '20028', '20031', '20211', '20241', '20501', '20636', '20894', '20911', '24336', '24658', '20633', '27759', '27762', '24349')   AND  fac.CMC_CLED_EDI_DATA.CLCL_ID = '" + Claimid + "'";
        //MessageBox.Show(sql);
        oracleCmd = new OracleCommand(sql, oracleConn);
    }
    private string ToString(object sQLCommand)
    {
        throw new NotImplementedException();
    }
    public override void PostExecute()
    {
        base.PostExecute();
        /*
         * Add your code here
          sqlReader.Close(); 
                   
         */
        oracleCmd.Dispose();
    }
    public override void ReleaseConnections()
    {
        connMgr.ReleaseConnection(oracleConn);
    }
    public override void CreateNewOutputRows()
    {
        /*
            Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
            For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
       */
        oracleRdr = oracleCmd.ExecuteReader();
        while (oracleRdr.Read())
        {
            {
                MyOutPutBuffer.AddRow();
                MyOutPutBuffer.SBSBID  = oracleRdr.GetString(0);
                MyOutPutBuffer.CLEDEXTREF = oracleRdr.GetString(1);
                MyOutPutBuffer.CLEDTRADPARTNER = oracleRdr.GetString(2);
                MyOutPutBuffer.CLCLID = oracleRdr.GetString(3);
                MyOutPutBuffer.MCREID = oracleRdr.GetString(4);
                MyOutPutBuffer.MCRENAME = oracleRdr.GetString(5);
                MyOutPutBuffer.MECBEFFDT = oracleRdr.GetDateTime(6);
                MyOutPutBuffer.MECBTERMDT = oracleRdr.GetDateTime(7);
                MyOutPutBuffer.MECBPOLICYID = oracleRdr.GetString(8);
                MyOutPutBuffer.MEMECK = oracleRdr.GetString(9);
            }
            MyOutPutBuffer.SetEndOfRowset();
        }
    }
                   
}


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>