Problem calling a ref cursor that is in a stored procedure

I have a stored procedure that returns a ref cursor as follows and I want to call it from another procedure in the same package. It compiles, but when I run it, it gets errors.
procedure procGetRefCursor(p_string in varchar2, p_int in integer, p_return out sys_refcursor) AS
l_subrefcursor l_refcursor;
begin
open l_subrefcursor for
SELECT myval
FROM mytab a
WHERE myval1 = p_string;
end procGetRefCursor;
The following code compiles, but when I run it it errors out on the fetch.
ERROR at line 1:
ORA-01001: invalid cursor
I also tried opening the cursor first and that does not compile. I also tried
fetch p_return.myval in l_myval
that does not compile
procedure callGetRefCursor(p_string in varchar2,p_int in integer) is
p_return sys_refcursor;
l_myval varchar2(100);
begin
procGetRefCursor(p_string, p_int, p_return);
loop
fetch p_return into l_myval;
dbms_output.put_line('myval '||l_myval);
exit when p_return%notfound;
end loop;
end;

Where is l_refcursor defined?
And why?
Aren't you using SYS_REFCURSOR?

Similar Messages

  • REF CURSOR as IN parameter to stored procedure

    Currently, ODP.NET supports REF CURSOR parameter as OUT parameter only.
    Based on the project requirements it is necessary to pass
    multiple records to the stored procedure.
    In this case REF CURSOR as IN parameter is useful.
    What are the plans to implement REF CURSOR as IN parameter to stored procedure?
    What is the work around in case it is necessary to pass several different
    record types as arrays to stored procedure?

    ODP.NET does not limit REF Cursor parameters to IN parameters. This is a known PL/SQL limitation.
    An excerpt from Application Developer's Guide:
    "If you pass a host cursor variable to PL/SQL, you cannot fetch from it on the server side unless you also open it there on the same server call".

  • Problem in Inserting the Value in the column through Stored Procedure

    stored procedure is created and i need
    to insert data into the SALES_TRADEIN, from the parent table (Flatfile_sales),through COMMAND PROMPT.
    I have 2 details TradeIn_1 and TradeIn_2.
    I need to insert details of TradeIn_1 in SALES_TRADEIN
    TABLE if the column of TradeIn_1 is null then i need to insert TradeIn_2 details.
    If the TradeIn_1 is not null then i have insert
    TradeIn_1 details and go to next column.
    This is the Scenario but i wrote the Script
    so anyone please view it and give the solution how to change that insert statement.
    -- =============================================
    -- Stored Procedure for Flatfile_Sales
    -- =============================================
    ---==========Sales_Cursor
    --USE [IconicMarketing]
    --GO
    DECLARE
    @FileType varchar(50),
    @ACDealerID varchar(50),
    @ClientDealerID varchar(50),
    @DMSType varchar(50),
    @DealNumber varchar(50),
    @CustomerNumber varchar(50),
    @CustomerName varchar(50),
    @CustomerFirstName varchar(50),
    @CustomerLastName varchar(50),
    @CustomerAddress varchar(50),
    @CustomerCity varchar(50),
    @CustomerState varchar(50),
    @CustomerZip varchar(50),
    @CustomerCounty varchar(50),
    @CustomerHomePhone varchar(50),
    @CustomerWorkPhone varchar(50),
    @CustomerCellPhone varchar(50),
    @CustomerPagerPhone varchar(50),
    @CustomerEmail varchar(50),
    @CustomerBirthDate varchar(50),
    @MailBlock varchar(50),
    @CoBuyerName varchar(50),
    @CoBuyerFirstName varchar(50),
    @CoBuyerLastName varchar(50),
    @CoBuyerAddress varchar(50),
    @CoBuyerCity varchar(50),
    @CoBuyerState varchar(50),
    @CoBuyerZip varchar(50),
    @CoBuyerCounty varchar(50),
    @CoBuyerHomePhone varchar(50),
    @CoBuyerWorkPhone varchar(50),
    @CoBuyerBirthDate varchar(50),
    @Salesman_1_Number varchar(50),
    @Salesman_1_Name varchar(50),
    @Salesman_2_Number varchar(50),
    @Salesman_2_Name varchar(50),
    @ClosingManagerName varchar(50),
    @ClosingManagerNumber varchar(50),
    @F_AND_I_ManagerNumber varchar(50),
    @F_AND_I_ManagerName varchar(50),
    @SalesManagerNumber varchar(50),
    @SalesManagerName varchar(50),
    @EntryDate varchar(50),
    @DealBookDate varchar(50),
    @VehicleYear varchar(50),
    @VehicleMake varchar(50),
    @VehicleModel varchar(50),
    @VehicleStockNumber varchar(50),
    @VehicleVIN varchar(50),
    @VehicleExteriorColor varchar(50),
    @VehicleInteriorColor varchar(50),
    @VehicleMileage varchar(50),
    @VehicleType varchar(50),
    @InServiceDate varchar(50),
    @HoldBackAmount varchar(50),
    @DealType varchar(50),
    @SaleType varchar(50),
    @BankCode varchar(50),
    @BankName varchar(50),
    @SalesmanCommission varchar(50),
    @GrossProfitSale varchar(50),
    @FinanceReserve varchar(50),
    @CreditLifePremium varchar(50),
    @CreditLifeCommision varchar(50),
    @TotalInsuranceReserve varchar(50),
    @BalloonAmount varchar(50),
    @CashPrice varchar(50),
    @AmountFinanced varchar(50),
    @TotalOfPayments varchar(50),
    @MSRP varchar(50),
    @DownPayment varchar(50),
    @SecurityDesposit varchar(50),
    @Rebate varchar(50),
    @Term varchar(50),
    @RetailPayment varchar(50),
    @PaymentType varchar(50),
    @RetailFirstPayDate varchar(50),
    @LeaseFirstPayDate varchar(50),
    @DayToFirstPayment varchar(50),
    @LeaseAnnualMiles varchar(50),
    @MileageRate varchar(50),
    @APRRate varchar(50),
    @ResidualAmount varchar(50),
    @LicenseFee varchar(50),
    @RegistrationFee varchar(50),
    @TotalTax varchar(50),
    @ExtendedWarrantyName varchar(50),
    @ExtendedWarrantyTerm varchar(50),
    @ExtendedWarrantyLimitMiles varchar(50),
    @ExtendedWarrantyDollar varchar(50),
    @ExtendedWarrantyProfit varchar(50),
    @FrontGross varchar(50),
    @BackGross varchar(50),
    @TradeIn_1_VIN varchar(50),
    @TradeIn_2_VIN varchar(50),
    @TradeIn_1_Make varchar(50),
    @TradeIn_2_Make varchar(50),
    @TradeIn_1_Model varchar(50),
    @TradeIn_2_Model varchar(50),
    @TradeIn_1_ExteriorColor varchar(50),
    @TradeIn_2_ExteriorColor varchar(50),
    @TradeIn_1_Year varchar(50),
    @TradeIn_2_Year varchar(50),
    @TradeIn_1_Mileage varchar(50),
    @TradeIn_2_Mileage varchar(50),
    @TradeIn_1_Gross varchar(50),
    @TradeIn_2_Gross varchar(50),
    @TradeIn_1_Payoff varchar(50),
    @TradeIn_2_Payoff varchar(50),
    @TradeIn_1_ACV varchar(50),
    @TradeIn_2_ACV varchar(50),
    @Fee_1_Name varchar(50),
    @Fee_1_Fee varchar(50),
    @Fee_1_Commission varchar(50),
    @Fee_2_Name varchar(50),
    @Fee_2_Fee varchar(50),
    @Fee_2_Commission varchar(50),
    @Fee_3_Name varchar(50),
    @Fee_3_Fee varchar(50),
    @Fee_3_Commission varchar(50),
    @Fee_4_Name varchar(50),
    @Fee_4_Fee varchar(50),
    @Fee_4_Commission varchar(50),
    @Fee_5_Name varchar(50),
    @Fee_5_Fee varchar(50),
    @Fee_5_Commission varchar(50),
    @Fee_6_Name varchar(50),
    @Fee_6_Fee varchar(50),
    @Fee_6_Commission varchar(50),
    @Fee_7_Name varchar(50),
    @Fee_7_Fee varchar(50),
    @Fee_7_Commission varchar(50),
    @Fee_8_Name varchar(50),
    @Fee_8_Fee varchar(50),
    @Fee_8_Commission varchar(50),
    @Fee_9_Name varchar(50),
    @Fee_9_Fee varchar(50),
    @Fee_9_Commission varchar(50),
    @Fee_10_Name varchar(50),
    @Fee_10_Fee varchar(50),
    @Fee_10_Commission varchar(50),
    @ContractDate varchar(50),
    @InsuranceName varchar(50),
    @InsuranceAgentName varchar(50),
    @InsuranceAddress varchar(50),
    @InsuranceCity varchar(50),
    @InsuranceState varchar(50),
    @InsuranceZip varchar(50),
    @InsurancePhone varchar(50),
    @InsurancePolicyNumber varchar(50),
    @InsuranceEffectiveDate varchar(50),
    @InsuranceExpirationDate varchar(50),
    @InsuranceCompensationDeduction varchar(50),
    @TradeIn_1_InteriorColor varchar(50),
    @TradeIn_2_InteriorColor varchar(50),
    @PhoneBlock varchar(50),
    @LicensePlateNumber varchar(50),
    @Cost varchar(50),
    @InvoiceAmount varchar(50),
    @FinanceCharge varchar(50),
    @TotalPickupPayment varchar(50),
    @TotalAccessories varchar(50),
    @TotalDriveOffAmount varchar(50),
    @EmailBlock varchar(50),
    @ModelDescriptionOfCarSold varchar(50),
    @VehicleClassification varchar(50),
    @ModelNumberOfCarSold varchar(50),
    @GAPPremium varchar(50),
    @LastInstallmentDate varchar(50),
    @CashDeposit varchar(50),
    @AHPremium varchar(50),
    @LeaseRate varchar(50),
    @DealerSelect varchar(50),
    @LeasePayment varchar(50),
    @LeaseNetCapCost varchar(50),
    @LeaseTotalCapReduction varchar(50),
    @DealStatus varchar(50),
    @CustomerSuffix varchar(50),
    @CustomerSalutation varchar(50),
    @CustomerAddress2 varchar(50),
    @CustomerMiddleName varchar(50),
    @GlobalOptOut varchar(50),
    @LeaseTerm varchar(50),
    @ExtendedWarrantyFlag varchar(50),
    @Salesman_3_Number varchar(50),
    @Salesman_3_Name varchar(50),
    @Salesman_4_Number varchar(50),
    @Salesman_4_Name varchar(50),
    @Salesman_5_Number varchar(50),
    @Salesman_5_Name varchar(50),
    @Salesman_6_Number varchar(50),
    @Salesman_6_Name varchar(50),
    @APRRate2 varchar(50),
    @APRRate3 varchar(50),
    @APRRate4 varchar(50),
    @Term2 varchar(50),
    @SecurityDeposit2 varchar(50),
    @DownPayment2 varchar(50),
    @TotalOfPayments2 varchar(50),
    @BasePayment varchar(50),
    @JournalSaleAmount varchar(50),
    @IndividualBusinessFlag varchar(50),
    @InventoryDate varchar(50),
    @StatusDate varchar(50),
    @ListPrice varchar(50),
    @NetTradeAmount varchar(50),
    @TrimLevel varchar(50),
    @SubTrimLevel varchar(50),
    @BodyDescription varchar(50),
    @BodyDoorCount varchar(50),
    @TransmissionDesc varchar(50),
    @EngineDesc varchar(50),
    @TypeCode varchar(50),
    @SLCT2 varchar(50),
    @DealDateOffset varchar(50),
    @AccountingDate varchar(50),
    @CoBuyerCustNum varchar(50),
    @CoBuyerCell varchar(50),
    @CoBuyerEmail varchar(50),
    @CoBuyerSalutation varchar(50),
    @CoBuyerPhoneBlock varchar(50),
    @CoBuyerMailBlock varchar(50),
    @CoBuyerEmailBlock varchar(50),
    @RealBookDate varchar(50),
    @CoBuyerMiddleName varchar(50),
    @CoBuyerCountry varchar(50),
    @CoBuyerAddress2 varchar(50),
    @CoBuyerOptOut varchar(50),
    @CoBuyerOccupation varchar(50),
    @CoBuyerEmployer varchar(50),
    @Country varchar(50),
    @Occupation varchar(50),
    @Employer varchar(50),
    @Salesman2Commission varchar(50),
    @BankAddress varchar(50),
    @BankCity varchar(50),
    @BankState varchar(50),
    @BankZip varchar(50),
    @LeaseEstimatedMiles varchar(50),
    @AFTReserve varchar(50),
    @CreditLifePrem varchar(50),
    @CreditLifeRes varchar(50),
    @AHRes varchar(50),
    @Language varchar(50),
    @BuyRate varchar(50),
    @DMVAmount varchar(50),
    @Weight varchar(50),
    @StateDMVTotFee varchar(50),
    @ROSNumber varchar(50),
    @Incentives varchar(50),
    @CASS_STD_LINE1 varchar(50),
    @CASS_STD_LINE2 varchar(50),
    @CASS_STD_CITY varchar(50),
    @CASS_STD_STATE varchar(50),
    @CASS_STD_ZIP varchar(50),
    @CASS_STD_ZIP4 varchar(50),
    @CASS_STD_DPBC varchar(50),
    @CASS_STD_CHKDGT varchar(50),
    @CASS_STD_CART varchar(50),
    @CASS_STD_LOT varchar(50),
    @CASS_STD_LOTORD varchar(50),
    @CASS_STD_URB varchar(50),
    @CASS_STD_FIPS varchar(50),
    @CASS_STD_EWS varchar(50),
    @CASS_STD_LACS varchar(50),
    @CASS_STD_ZIPMOV varchar(50),
    @CASS_STD_Z4LOM varchar(50),
    @CASS_STD_NDIAPT varchar(50),
    @CASS_STD_NDIRR varchar(50),
    @CASS_STD_LACSRT varchar(50),
    @CASS_STD_ERROR_CD varchar(50),
    @NCOA_AC_ID varchar(50),
    @NCOA_COA_ADDSRC varchar(50),
    @NCOA_COA_MATCH varchar(50),
    @NCOA_COA_MOVTYP varchar(50),
    @NCOA_COA_DATE varchar(50),
    @NCOA_COA_DELCD varchar(50),
    @NCOA_COA_RTYPE varchar(50),
    @NCOA_COA_RTNCD varchar(50),
    @NCOA_COA_LINE1 varchar(50),
    @NCOA_COA_LINE2 varchar(50),
    @NCOA_COA_CITY varchar(50),
    @NCOA_COA_STATE varchar(50),
    @NCOA_COA_ZIP varchar(50),
    @NCOA_COA_ZIP4 varchar(50),
    @NCOA_COA_DPBC varchar(50),
    @NCOA_COA_CHKDGT varchar(50),
    @NCOA_COA_CART varchar(50),
    @NCOA_COA_LOT varchar(50),
    @NCOA_COA_LOTORD varchar(50),
    @NCOA_COA_URB varchar(50),
    @NCOA_COA_Z4LOM varchar(50),
    @NCOA_COA_ACTION varchar(50),
    @NCOA_COA_QNAME varchar(50),
    @NCOA_DPV_AA varchar(50),
    @NCOA_DPV_A1 varchar(50),
    @NCOA_DPV_BB varchar(50),
    @NCOA_DPV_CC varchar(50),
    @NCOA_DPV_M1 varchar(50),
    @NCOA_DPV_M3 varchar(50),
    @NCOA_DPV_N1 varchar(50),
    @NCOA_DPV_P1 varchar(50),
    @NCOA_DPV_P3 varchar(50),
    @NCOA_DPV_RR varchar(50),
    @NCOA_DPV_R1 varchar(50),
    @NCOA_DPV_STATUS varchar(50),
    @NCOA_DPV_F1 varchar(50),
    @NCOA_DPV_G1 varchar(50),
    @NCOA_DPV_U1 varchar(50),
    @SalesID int;
    DECLARE Sales_Cursor CURSOR FOR
    SELECT * from FLATFILE_SALES;
    OPEN Sales_Cursor
    FETCH NEXT FROM Sales_Cursor
    INTO @FileType ,
    @ACDealerID ,
    @ClientDealerID ,
    @DMSType ,
    @DealNumber ,
    @CustomerNumber ,
    @CustomerName ,
    @CustomerFirstName ,
    @CustomerLastName ,
    @CustomerAddress ,
    @CustomerCity ,
    @CustomerState ,
    @CustomerZip ,
    @CustomerCounty ,
    @CustomerHomePhone ,
    @CustomerWorkPhone ,
    @CustomerCellPhone ,
    @CustomerPagerPhone ,
    @CustomerEmail ,
    @CustomerBirthDate ,
    @MailBlock ,
    @CoBuyerName ,
    @CoBuyerFirstName ,
    @CoBuyerLastName ,
    @CoBuyerAddress ,
    @CoBuyerCity ,
    @CoBuyerState ,
    @CoBuyerZip ,
    @CoBuyerCounty ,
    @CoBuyerHomePhone ,
    @CoBuyerWorkPhone ,
    @CoBuyerBirthDate ,
    @Salesman_1_Number ,
    @Salesman_1_Name ,
    @Salesman_2_Number ,
    @Salesman_2_Name ,
    @ClosingManagerName ,
    @ClosingManagerNumber ,
    @F_AND_I_ManagerNumber ,
    @F_AND_I_ManagerName ,
    @SalesManagerNumber ,
    @SalesManagerName ,
    @EntryDate ,
    @DealBookDate ,
    @VehicleYear ,
    @VehicleMake ,
    @VehicleModel ,
    @VehicleStockNumber ,
    @VehicleVIN ,
    @VehicleExteriorColor ,
    @VehicleInteriorColor ,
    @VehicleMileage ,
    @VehicleType ,
    @InServiceDate ,
    @HoldBackAmount ,
    @DealType ,
    @SaleType ,
    @BankCode ,
    @BankName ,
    @SalesmanCommission ,
    @GrossProfitSale ,
    @FinanceReserve ,
    @CreditLifePremium ,
    @CreditLifeCommision ,
    @TotalInsuranceReserve ,
    @BalloonAmount ,
    @CashPrice ,
    @AmountFinanced ,
    @TotalOfPayments ,
    @MSRP ,
    @DownPayment ,
    @SecurityDesposit ,
    @Rebate ,
    @Term ,
    @RetailPayment ,
    @PaymentType ,
    @RetailFirstPayDate ,
    @LeaseFirstPayDate ,
    @DayToFirstPayment ,
    @LeaseAnnualMiles ,
    @MileageRate ,
    @APRRate ,
    @ResidualAmount ,
    @LicenseFee ,
    @RegistrationFee ,
    @TotalTax ,
    @ExtendedWarrantyName ,
    @ExtendedWarrantyTerm ,
    @ExtendedWarrantyLimitMiles ,
    @ExtendedWarrantyDollar ,
    @ExtendedWarrantyProfit ,
    @FrontGross ,
    @BackGross ,
    @TradeIn_1_VIN ,
    @TradeIn_2_VIN ,
    @TradeIn_1_Make ,
    @TradeIn_2_Make ,
    @TradeIn_1_Model ,
    @TradeIn_2_Model ,
    @TradeIn_1_ExteriorColor ,
    @TradeIn_2_ExteriorColor ,
    @TradeIn_1_Year ,
    @TradeIn_2_Year ,
    @TradeIn_1_Mileage ,
    @TradeIn_2_Mileage ,
    @TradeIn_1_Gross ,
    @TradeIn_2_Gross ,
    @TradeIn_1_Payoff ,
    @TradeIn_2_Payoff ,
    @TradeIn_1_ACV ,
    @TradeIn_2_ACV ,
    @Fee_1_Name ,
    @Fee_1_Fee ,
    @Fee_1_Commission ,
    @Fee_2_Name ,
    @Fee_2_Fee ,
    @Fee_2_Commission ,
    @Fee_3_Name ,
    @Fee_3_Fee ,
    @Fee_3_Commission ,
    @Fee_4_Name ,
    @Fee_4_Fee ,
    @Fee_4_Commission ,
    @Fee_5_Name ,
    @Fee_5_Fee ,
    @Fee_5_Commission ,
    @Fee_6_Name ,
    @Fee_6_Fee ,
    @Fee_6_Commission ,
    @Fee_7_Name ,
    @Fee_7_Fee ,
    @Fee_7_Commission ,
    @Fee_8_Name ,
    @Fee_8_Fee ,
    @Fee_8_Commission ,
    @Fee_9_Name ,
    @Fee_9_Fee ,
    @Fee_9_Commission ,
    @Fee_10_Name ,
    @Fee_10_Fee ,
    @Fee_10_Commission ,
    @ContractDate ,
    @InsuranceName ,
    @InsuranceAgentName ,
    @InsuranceAddress ,
    @InsuranceCity ,
    @InsuranceState ,
    @InsuranceZip ,
    @InsurancePhone ,
    @InsurancePolicyNumber ,
    @InsuranceEffectiveDate ,
    @InsuranceExpirationDate ,
    @InsuranceCompensationDeduction ,
    @TradeIn_1_InteriorColor ,
    @TradeIn_2_InteriorColor ,
    @PhoneBlock ,
    @LicensePlateNumber ,
    @Cost ,
    @InvoiceAmount ,
    @FinanceCharge ,
    @TotalPickupPayment ,
    @TotalAccessories ,
    @TotalDriveOffAmount ,
    @EmailBlock ,
    @ModelDescriptionOfCarSold ,
    @VehicleClassification ,
    @ModelNumberOfCarSold ,
    @GAPPremium ,
    @LastInstallmentDate ,
    @CashDeposit ,
    @AHPremium ,
    @LeaseRate ,
    @DealerSelect ,
    @LeasePayment ,
    @LeaseNetCapCost ,
    @LeaseTotalCapReduction ,
    @DealStatus ,
    @CustomerSuffix ,
    @CustomerSalutation ,
    @CustomerAddress2 ,
    @CustomerMiddleName ,
    @GlobalOptOut ,
    @LeaseTerm ,
    @ExtendedWarrantyFlag ,
    @Salesman_3_Number ,
    @Salesman_3_Name ,
    @Salesman_4_Number ,
    @Salesman_4_Name ,
    @Salesman_5_Number ,
    @Salesman_5_Name ,
    @Salesman_6_Number ,
    @Salesman_6_Name ,
    @APRRate2 ,
    @APRRate3 ,
    @APRRate4 ,
    @Term2 ,
    @SecurityDeposit2 ,
    @DownPayment2 ,
    @TotalOfPayments2 ,
    @BasePayment ,
    @JournalSaleAmount ,
    @IndividualBusinessFlag ,
    @InventoryDate ,
    @StatusDate ,
    @ListPrice ,
    @NetTradeAmount ,
    @TrimLevel ,
    @SubTrimLevel ,
    @BodyDescription ,
    @BodyDoorCount ,
    @TransmissionDesc ,
    @EngineDesc ,
    @TypeCode ,
    @SLCT2 ,
    @DealDateOffset ,
    @AccountingDate ,
    @CoBuyerCustNum ,
    @CoBuyerCell ,
    @CoBuyerEmail ,
    @CoBuyerSalutation ,
    @CoBuyerPhoneBlock ,
    @CoBuyerMailBlock ,
    @CoBuyerEmailBlock ,
    @RealBookDate ,
    @CoBuyerMiddleName ,
    @CoBuyerCountry ,
    @CoBuyerAddress2 ,
    @CoBuyerOptOut ,
    @CoBuyerOccupation ,
    @CoBuyerEmployer ,
    @Country ,
    @Occupation ,
    @Employer ,
    @Salesman2Commission ,
    @BankAddress ,
    @BankCity ,
    @BankState ,
    @BankZip ,
    @LeaseEstimatedMiles ,
    @AFTReserve ,
    @CreditLifePrem ,
    @CreditLifeRes ,
    @AHRes ,
    @Language ,
    @BuyRate ,
    @DMVAmount ,
    @Weight ,
    @StateDMVTotFee ,
    @ROSNumber ,
    @Incentives ,
    @CASS_STD_LINE1 ,
    @CASS_STD_LINE2 ,
    @CASS_STD_CITY ,
    @CASS_STD_STATE ,
    @CASS_STD_ZIP ,
    @CASS_STD_ZIP4 ,
    @CASS_STD_DPBC ,
    @CASS_STD_CHKDGT ,
    @CASS_STD_CART ,
    @CASS_STD_LOT ,
    @CASS_STD_LOTORD ,
    @CASS_STD_URB ,
    @CASS_STD_FIPS ,
    @CASS_STD_EWS ,
    @CASS_STD_LACS ,
    @CASS_STD_ZIPMOV ,
    @CASS_STD_Z4LOM ,
    @CASS_STD_NDIAPT ,
    @CASS_STD_NDIRR ,
    @CASS_STD_LACSRT ,
    @CASS_STD_ERROR_CD ,
    @NCOA_AC_ID ,
    @NCOA_COA_ADDSRC ,
    @NCOA_COA_MATCH ,
    @NCOA_COA_MOVTYP ,
    @NCOA_COA_DATE ,
    @NCOA_COA_DELCD ,
    @NCOA_COA_RTYPE ,
    @NCOA_COA_RTNCD ,
    @NCOA_COA_LINE1 ,
    @NCOA_COA_LINE2 ,
    @NCOA_COA_CITY ,
    @NCOA_COA_STATE ,
    @NCOA_COA_ZIP ,
    @NCOA_COA_ZIP4 ,
    @NCOA_COA_DPBC ,
    @NCOA_COA_CHKDGT ,
    @NCOA_COA_CART ,
    @NCOA_COA_LOT ,
    @NCOA_COA_LOTORD ,
    @NCOA_COA_URB ,
    @NCOA_COA_Z4LOM ,
    @NCOA_COA_ACTION ,
    @NCOA_COA_QNAME ,
    @NCOA_DPV_AA ,
    @NCOA_DPV_A1 ,
    @NCOA_DPV_BB ,
    @NCOA_DPV_CC ,
    @NCOA_DPV_M1 ,
    @NCOA_DPV_M3 ,
    @NCOA_DPV_N1 ,
    @NCOA_DPV_P1 ,
    @NCOA_DPV_P3 ,
    @NCOA_DPV_RR ,
    @NCOA_DPV_R1 ,
    @NCOA_DPV_STATUS ,
    @NCOA_DPV_F1 ,
    @NCOA_DPV_G1 ,
    @NCOA_DPV_U1 ;
    WHILE @@FETCH_STATUS = 0
    BEGIN
    PRINT @VehicleVIN ;
    --===============================================================================
    -- ****************** insert into Sales Table ***********
    INSERT INTO Sales
    IconicDealerID,
    DealNumber,
    CustomerNumber,
    DMSType,
    ContractDate
    VALUES (@ClientDealerID,@DealNumber,@CustomerNumber,@DMSType,@ContractDate);
    set @SalesID = scope_identity();
    PRINT @SalesID;
    --================================================================================
    --Insert into SALES_TRADEIN Table
    INSERT INTO SALES_TRADEIN
    SalesID,
    TradeIn_VIN,
    TradeIn_Make,
    TradeIn_Model,
    TradeIn_ExteriorColor,
    TradeIn_Year,
    TradeIn_Mileage,
    TradeIn_Gross,
    TradeIn_Payoff,
    TradeIn_ACV,
    TradeIn_InteriorColor
    VALUES (
    @SalesID,
    case when @TradeIn_1_VIN null then @TradeIn_1_VIN else @TradeIn_2_VIN end,
    case when @TradeIn_1_Make is null then @TradeIn_1_Make else @TradeIn_2_Make end,
    case when @TradeIn_1_Model is null then @TradeIn_1_Model else @TradeIn_2_Model end,
    case when @TradeIn_1_ExteriorColor is null then @TradeIn_1_ExteriorColor else @TradeIn_2_ExteriorColor end,
    case when @TradeIn_1_Year is null then @TradeIn_1_Year else @TradeIn_2_Year end,
    case when @TradeIn_1_Mileage is null then @TradeIn_1_Mileage else @TradeIn_2_Mileage end,
    case when @TradeIn_1_Gross is null then @TradeIn_1_Gross else @TradeIn_2_Gross end,
    case when @TradeIn_1_Payoff is not null then @TradeIn_1_Payoff else @TradeIn_2_Payoff end,
    case when @TradeIn_1_ACV is null then @TradeIn_1_ACV else @TradeIn_2_ACV end,
    case when @TradeIn_1_InteriorColor is null then @TradeIn_1_InteriorColor else @TradeIn_1_InteriorColor end
    --===============================================================================
    --Insert into SALES_VEHICLE Table
    INSERT INTO SALES_VEHICLE
    SalesID ,
    VehicleYear ,
    VehicleMake ,
    VehicleModel ,
    VehicleStockNumber ,
    VehicleVIN ,
    VehicleExteriorColor ,
    VehicleInteriorColor ,
    VehicleMileage ,
    VehicleType ,
    InServiceDate ,
    LeaseAnnualMiles ,
    ExtendedWarrantyName ,
    ExtendedWarrantyTerm ,
    ExtendedWarrantyLimitMiles ,
    LicensePlateNumber ,
    ModelDescriptionOfCarSold ,
    VehicleClassification ,
    ModelNumberOfCarSold ,
    ExtendedWarrantyFlag ,
    TrimLevel ,
    SubTrimLevel ,
    BodyDescription ,
    BodyDoorCount ,
    TransmissionDesc ,
    EngineDesc ,
    TypeCode ,
    Weight ,
    LeaseEstimatedMiles
    VALUES (
    @SalesID,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleStockNumber,@VehicleVIN,
    @VehicleExteriorColor,@VehicleInteriorColor,@VehicleMileage,@VehicleType,
    @InServiceDate,@LeaseAnnualMiles,@ExtendedWarrantyName,@ExtendedWarrantyTerm,
    @ExtendedWarrantyLimitMiles,@LicensePlateNumber,@ModelDescriptionOfCarSold,
    @VehicleClassification,@ModelNumberOfCarSold,@ExtendedWarrantyFlag,
    @TrimLevel,@SubTrimLevel,@BodyDescription,@BodyDoorCount,
    @TransmissionDesc,@EngineDesc,@TypeCode,@Weight,@LeaseEstimatedMiles
    --======================================================================================
    --Insert into SALES_FEE Table
    INSERT INTO SALES_FEE
    SalesID ,
    Fee_Name ,
    Fee_Fee ,
    Fee_Commission
    VALUES (
    @SalesID,
    case
    when @Fee_1_Name is not null then @Fee_1_Name
    when @Fee_2_Name is not null then @Fee_2_Name
    when @Fee_3_Name is not null then @Fee_3_Name
    when @Fee_4_Name is not null then @Fee_4_Name
    when @Fee_5_Name is not null then @Fee_5_Name
    when @Fee_6_Name is not null then @Fee_6_Name
    when @Fee_7_Name is not null then @Fee_7_Name
    when @Fee_8_Name is not null then @Fee_8_Name
    when @Fee_9_Name is not null then @Fee_9_Name
    else @Fee_10_Name end,
    case
    when @Fee_1_Fee is not null then @Fee_1_Fee
    when @Fee_2_Fee is not null then @Fee_2_Fee
    when @Fee_3_Fee is not null then @Fee_3_Fee
    when @Fee_4_Fee is not null then @Fee_4_Fee
    when @Fee_5_Fee is not null then @Fee_5_Fee
    when @Fee_6_Fee is not null then @Fee_6_Fee
    when @Fee_7_Fee is not null then @Fee_7_Fee
    when @Fee_8_Fee is not null then @Fee_8_Fee
    when @Fee_9_Fee is not null then @Fee_9_Fee
    else @Fee_10_Fee end,
    case
    when @Fee_1_Commission is not null then @Fee_1_Commission
    when @Fee_2_Commission is not null then @Fee_2_Commission
    when @Fee_3_Commission is not null then @Fee_3_Commission
    when @Fee_4_Commission is not null then @Fee_4_Commission
    when @Fee_5_Commission is not null then @Fee_5_Commission
    when @Fee_6_Commission is not null then @Fee_6_Commission
    when @Fee_7_Commission is not null then @Fee_7_Commission
    when @Fee_8_Commission is not null then @Fee_8_Commission
    when @Fee_9_Commission is not null then @Fee_9_Commission
    else @Fee_10_Commission end
    --======================================================================================
    --Insert into SALES_HR Table
    INSERT INTO SALES_HR
    SalesID ,
    Salesman_Number ,
    Salesman_Name ,
    ClosingManagerName ,
    ClosingManagerNumber ,
    F_AND_I_ManagerNumber ,
    F_AND_I_ManagerName ,
    SalesManagerNumber ,
    SalesManagerName
    VALUES (
    @SalesID ,
    case
    when @Salesman_1_Number is not null then @Salesman_1_Number
    when @Salesman_2_Number is not null then @Salesman_2_Number
    when @Salesman_3_Number is not null then @Salesman_3_Number
    when @Salesman_4_Number is not null then @Salesman_4_Number
    when @Salesman_5_Number is not null then @Salesman_5_Number
    else @Salesman_6_Number end,
    case
    when @Salesman_1_Name is not null then @Salesman_1_Name
    when @Salesman_2_Name is not null then @Salesman_2_Name
    when @Salesman_3_Name is not null then @Salesman_3_Name
    when @Salesman_4_Name is not null then @Salesman_4_Name
    when @Salesman_5_Name is not null then @Salesman_5_Name
    else @Salesman_6_Name end,
    @ClosingManagerName ,
    @ClosingManagerNumber ,
    @F_AND_I_ManagerNumber ,
    @F_AND_I_ManagerName ,
    @SalesManagerNumber ,
    @SalesManagerName
    --======================================================================================
    --Insert into SALES_COBUYER Table
    INSERT INTO SALES_COBUYER
    SalesID ,
    CoBuyerName ,
    CoBuyerFirstName ,
    CoBuyerLastName ,
    CoBuyerAddress ,
    CoBuyerCity ,
    CoBuyerState ,
    CoBuyerZip ,
    CoBuyerCounty ,
    CoBuyerHomePhone ,
    CoBuyerWorkPhone ,
    CoBuyerBirthDate ,
    CoBuyerCustNum ,
    CoBuyerCell ,
    CoBuyerEmail ,
    CoBuyerSalutation ,
    CoBuyerMiddleName ,
    CoBuyerCountry ,
    CoBuyerAddress2 ,
    CoBuyerOptOut ,
    CoBuyerOccupation ,
    CoBuyerEmployer ,
    CoBuyerPhoneBlock ,
    CoBuyerMailBlock ,
    CoBuyerEmailBlock
    VALUES (
    @SalesID,@CoBuyerName,@CoBuyerFirstName,@CoBuyerLastName,@CoBuyerAddress,
    @CoBuyerCity,@CoBuyerState,@CoBuyerZip,@CoBuyerCounty,@CoBuyerHomePhone,
    @CoBuyerWorkPhone,@CoBuyerBirthDate,@CoBuyerCustNum,@CoBuyerCell,
    @CoBuyerEmail,@CoBuyerSalutation,@CoBuyerMiddleName,@CoBuyerCountry,
    @CoBuyerAddress2,@CoBuyerOptOut,@CoBuyerOccupation,@CoBuyerEmployer,
    @CoBuyerPhoneBlock,@CoBuyerMailBlock,@CoBuyerEmailBlock
    --======================================================================================
    --Insert into SALES_CUSTOMER Table
    INSERT INTO SALES_CUSTOMER
    SalesID ,
    IndividualBusinessFlag ,
    PhoneBlock ,
    EmailBlock ,
    CustomerName ,
    CustomerFirstName ,
    CustomerLastName ,
    CustomerAddress ,
    CustomerCity ,
    CustomerState ,
    CustomerZip ,
    CustomerCounty ,
    CustomerHomePhone ,
    CustomerWorkPhone ,
    CustomerCellPhone ,
    CustomerPagerPhone ,
    CustomerEmail ,
    CustomerBirthDate ,
    MailBlock ,
    CustomerSuffix ,
    CustomerSalutation ,
    CustomerAddress2 ,
    CustomerMiddleName ,
    GlobalOptOut ,
    InsuranceName ,
    InsuranceAgentName ,
    InsuranceAddress ,
    InsuranceCity ,
    InsuranceState ,
    InsuranceZip ,
    InsurancePhone ,
    InsurancePolicyNumber ,
    InsuranceEffectiveDate ,
    InsuranceExpirationDate ,
    InsuranceCompensationDeduction ,
    Country ,
    Occupation ,
    Employer ,
    CASS_STD_LINE1 ,
    CASS_STD_LINE2 ,
    CASS_STD_CITY ,
    CASS_STD_STATE ,
    CASS_STD_ZIP ,
    CASS_STD_ZIP4 ,
    CASS_STD_DPBC ,
    CASS_STD_CHKDGT ,
    CASS_STD_CART ,
    CASS_STD_LOT ,
    CASS_STD_LOTORD ,
    CASS_STD_URB ,
    CASS_STD_FIPS ,
    CASS_STD_EWS ,
    CASS_STD_LACS ,
    CASS_STD_ZIPMOV ,
    CASS_STD_Z4LOM ,
    CASS_STD_NDIAPT ,
    CASS_STD_NDIRR ,
    CASS_STD_LACSRT ,
    CASS_STD_ERROR_CD ,
    NCOA_AC_ID ,
    NCOA_COA_ADDSRC ,
    NCOA_COA_MATCH ,
    NCOA_COA_MOVTYP ,
    NCOA_COA_DATE ,
    NCOA_COA_DELCD ,
    NCOA_COA_RTYPE ,
    NCOA_COA_RTNCD ,
    NCOA_COA_LINE1 ,
    NCOA_COA_LINE2 ,
    NCOA_COA_CITY ,
    NCOA_COA_STATE ,
    NCOA_COA_ZIP ,
    NCOA_COA_ZIP4 ,
    NCOA_COA_DPBC ,
    NCOA_COA_CHKDGT ,
    NCOA_COA_CART ,
    NCOA_COA_LOT ,
    NCOA_COA_LOTORD ,
    NCOA_COA_URB ,
    NCOA_COA_Z4LOM ,
    NCOA_COA_ACTION ,
    NCOA_COA_QNAME ,
    NCOA_DPV_AA ,
    NCOA_DPV_A1 ,
    NCOA_DPV_BB ,
    NCOA_DPV_CC ,
    NCOA_DPV_M1 ,
    NCOA_DPV_M3 ,
    NCOA_DPV_N1 ,
    NCOA_DPV_P1 ,
    NCOA_DPV_P3 ,
    NCOA_DPV_RR ,
    NCOA_DPV_R1 ,
    NCOA_DPV_STATUS ,
    NCOA_DPV_F1 ,
    NCOA_DPV_G1 ,
    NCOA_DPV_U1
    VALUES (
    @SalesID ,
    @IndividualBusinessFlag ,
    @PhoneBlock ,
    @EmailBlock ,
    @CustomerName ,
    @CustomerFirstName ,
    @CustomerLastName ,
    @CustomerAddress ,
    @CustomerCity ,
    @CustomerState ,
    @CustomerZip ,
    @CustomerCounty ,
    @CustomerHomePhone ,
    @CustomerWorkPhone ,
    @CustomerCellPhone ,
    @CustomerPagerPhone ,
    @CustomerEmail ,
    @CustomerBirthDate ,
    @MailBlock ,
    @CustomerSuffix ,
    @CustomerSalutation ,
    @CustomerAddress2 ,
    @CustomerMiddleName ,
    @GlobalOptOut ,
    @InsuranceName ,
    @InsuranceAgentName ,
    @InsuranceAddress ,
    @InsuranceCity ,
    @InsuranceState ,
    @InsuranceZip ,
    @InsurancePhone ,
    @InsurancePolicyNumber ,
    @InsuranceEffectiveDate ,
    @InsuranceExpirationDate ,
    @InsuranceCompensationDeduction ,
    @Country ,
    @Occupation ,
    @Employer ,
    @CASS_STD_LINE1 ,
    @CASS_STD_LINE2 ,
    @CASS_STD_CITY ,
    @CASS_STD_STATE ,
    @CASS_STD_ZIP ,
    @CASS_STD_ZIP4 ,
    @CASS_STD_DPBC ,
    @CASS_STD_CHKDGT ,
    @CASS_STD_CART ,
    @CASS_STD_LOT ,
    @CASS_STD_LOTORD ,
    @CASS_STD_URB ,
    @CASS_STD_FIPS ,
    @CASS_STD_EWS ,
    @CASS_STD_LACS ,
    @CASS_STD_ZIPMOV ,
    @CASS_STD_Z4LOM ,
    @CASS_STD_NDIAPT ,
    @CASS_STD_NDIRR ,
    @CASS_STD_LACSRT ,
    @CASS_STD_ERROR_CD ,
    @NCOA_AC_ID ,
    @NCOA_COA_ADDSRC ,
    @NCOA_COA_MATCH ,
    @NCOA_COA_MOVTYP ,
    @NCOA_COA_DATE ,
    @NCOA_COA_DELCD ,
    @NCOA_COA_RTYPE ,
    @NCOA_COA_RTNCD ,
    @NCOA_COA_LINE1 ,
    @NCOA_COA_LINE2 ,
    @NCOA_COA_CITY ,
    @NCOA_COA_STATE ,
    @NCOA_COA_ZIP ,
    @NCOA_COA_ZIP4 ,
    @NCOA_COA_DPBC ,
    @NCOA_COA_CHKDGT ,
    @NCOA_COA_CART ,
    @NCOA_COA_LOT ,
    @NCOA_COA_LOTORD ,
    @NCOA_COA_URB ,
    @NCOA_COA_Z4LOM ,
    @NCOA_COA_ACTION ,
    @NCOA_COA_QNAME ,
    @NCOA_DPV_AA ,
    @NCOA_DPV_A1 ,
    @NCOA_DPV_BB ,
    @NCOA_DPV_CC ,
    @NCOA_DPV_M1 ,
    @NCOA_DPV_M3 ,
    @NCOA_DPV_N1 ,
    @NCOA_DPV_P1 ,
    @NCOA_DPV_P3 ,
    @NCOA_DPV_RR ,
    @NCOA_DPV_R1 ,
    @NCOA_DPV_STATUS ,
    @NCOA_DPV_F1 ,
    @NCOA_DPV_G1 ,
    @NCOA_DPV_U1
    --======================================================================================
    --Insert into SALES_AMOUNT Table
    INSERT INTO SALES_AMOUNT
    SalesID ,
    HoldBackAmount ,
    ExtendedWarrantyDollar ,
    ExtendedWarrantyProfit ,
    FrontGross ,
    BackGross ,
    MileageRate ,
    APRRate ,
    ResidualAmount ,
    LicenseFee ,
    RegistrationFee ,
    TotalTax ,
    Cost ,
    InvoiceAmount ,
    FinanceCharge ,
    TotalPickupPayment ,
    TotalAccessories ,
    TotalDriveOffAmount ,
    SalesmanCommission ,
    GrossProfitSale ,
    FinanceReserve ,
    CreditLifePremium ,
    CreditLifeCommision ,
    TotalInsuranceReserve ,
    BalloonAmount ,
    CashPrice ,
    AmountFinanced ,
    TotalOfPayments ,
    MSRP ,
    DownPayment ,
    SecurityDesposit ,
    Rebate ,
    Term ,
    RetailPayment ,
    LeasePayment ,
    LeaseNetCapCost ,
    LeaseTotalCapReduction ,
    APRRate2 ,
    APRRate3 ,
    GAPPremium ,
    LeaseTerm ,
    CashDeposit ,
    AHPremium ,
    LeaseRate ,
    Incentives ,
    StateDMVTotFee ,
    BuyRate ,
    DMVAmount ,
    CreditLifePrem ,
    CreditLifeRes ,
    AHRes ,
    Salesman2Commission ,
    ListPrice ,
    NetTradeAmount ,
    APRRate4 ,
    Term2 ,
    SecurityDeposit2 ,
    DownPayment2 ,
    TotalOfPayments2 ,
    BasePayment ,
    JournalSaleAmount
    VALUES (
    @SalesID,@HoldBackAmount,@ExtendedWarrantyDollar,@ExtendedWarrantyProfit,
    @FrontGross,@BackGross,@MileageRate,@APRRate,@ResidualAmount,@LicenseFee,
    @RegistrationFee,@TotalTax,@Cost,@InvoiceAmount,@FinanceCharge,
    @TotalPickupPayment,@TotalAccessories,@TotalDriveOffAmount,@SalesmanCommission,
    @GrossProfitSale,@FinanceReserve,@CreditLifePremium,@CreditLifeCommision,
    @TotalInsuranceReserve,@BalloonAmount,@CashPrice,@AmountFinanced,@TotalOfPayments,
    @MSRP,@DownPayment,@SecurityDesposit,@Rebate,@Term,@RetailPayment,@LeasePayment,
    @LeaseNetCapCost,@LeaseTotalCapReduction,@APRRate2,@APRRate3,@GAPPremium,
    @LeaseTerm,@CashDeposit,@AHPremium,@LeaseRate,@Incentives,@StateDMVTotFee,
    @BuyRate,@DMVAmount,@CreditLifePrem,@CreditLifeRes,@AHRes,@Salesman2Commission,
    @ListPrice,@NetTradeAmount,@APRRate4,@Term2,@SecurityDeposit2,
    @DownPayment2,@TotalOfPayments2,@BasePayment,@JournalSaleAmount
    --===========================================================================
    --Insert into SALES_BANKINFO Table
    INSERT INTO SALES_BANKINFO
    SalesID ,
    SLCT2 ,
    DealDateOffset ,
    DealerSelect ,
    DealStatus ,
    DealType ,
    SaleType ,
    BankCode ,
    BankName ,
    PaymentType ,
    BankAddress ,
    BankCity ,
    BankState ,
    BankZip ,
    AFTReserve ,
    Language ,
    ROSNumber
    VALUES (
    @SalesID,@SLCT2,@DealDateOffset,@DealerSelect,@DealStatus,@DealType,
    @SaleType,@BankCode,@BankName,@PaymentType,@BankAddress,@BankCity,
    @BankState,@BankZip,@AFTReserve,@Language,@ROSNumber
    ---=======================================================
    INSERT INTO SALES_DATE
    SalesID ,
    AccountingDate ,
    InventoryDate ,
    StatusDate ,
    LastInstallmentDate ,
    RetailFirstPayDate ,
    LeaseFirstPayDate ,
    DayToFirstPayment ,
    EntryDate ,
    DealBookDate ,
    RealBookDate
    VALUES (
    @SalesID ,
    convert (datetime,@AccountingDate) ,
    -- CAST (@AccountingDate AS datetime),
    convert (datetime,@InventoryDate) ,
    -- CAST (@InventoryDate AS datetime),
    convert (datetime,@StatusDate) ,
    -- CAST (@StatusDate AS datetime),
    convert (datetime,@LastInstallmentDate),
    -- CAST (@LastInstallmentDate AS datetime),
    convert (datetime,@RetailFirstPayDate) ,
    -- CAST (@RetailFirstPayDate AS datetime),
    @LeaseFirstPayDate ,
    convert (datetime,@DayToFirstPayment),
    -- CAST (@DayToFirstPayment AS datetime),
    convert (datetime,@EntryDate),
    -- CAST (@EntryDate AS datetime),
    convert (datetime,@DealBookDate),
    -- CAST (@DealBookDate AS datetime),
    convert (datetime,@RealBookDate)
    -- CAST (@RealBookDate AS datetime)
    */---=======================================================
    --======================================================================================
    -- Move cursor to Next record
    FETCH NEXT FROM Sales_Cursor
    INTO @FileType ,
    @ACDealerID ,
    @ClientDealerID ,
    @DMSType ,
    @DealNumber ,
    @CustomerNumber ,
    @CustomerName ,
    @CustomerFirstName ,
    @CustomerLastName ,
    @CustomerAddress ,
    @CustomerCity ,
    @CustomerState ,
    @CustomerZip ,
    @CustomerCounty ,
    @CustomerHomePhone ,
    @CustomerWorkPhone ,
    @CustomerCellPhone ,
    @CustomerPagerPhone ,
    @CustomerEmail ,
    @CustomerBirthDate ,
    @MailBlock ,
    @CoBuyerName ,
    @CoBuyerFirstName ,
    @CoBuyerLastName ,
    @CoBuyerAddress ,
    @CoBuyerCity ,
    @CoBuyerState ,
    @CoBuyerZip ,
    @CoBuyerCounty ,
    @CoBuyerHomePhone ,
    @CoBuyerWorkPhone ,
    @CoBuyerBirthDate ,
    @Salesman_1_Number ,
    @Salesman_1_Name ,
    @Salesman_2_Number ,
    @Salesman_2_Name ,
    @ClosingManagerName ,
    @ClosingManagerNumber ,
    @F_AND_I_ManagerNumber ,
    @F_AND_I_ManagerName ,
    @SalesManagerNumber ,
    @SalesManagerName ,
    @EntryDate ,
    @DealBookDate ,
    @VehicleYear ,
    @VehicleMake ,
    @VehicleModel ,
    @VehicleStockNumber ,
    @VehicleVIN ,
    @VehicleExteriorColor ,
    @VehicleInteriorColor ,
    @VehicleMileage ,
    @VehicleType ,
    @InServiceDate ,
    @HoldBackAmount ,
    @DealType ,
    @SaleType ,
    @BankCode ,
    @BankName ,
    @SalesmanCommission ,
    @GrossProfitSale ,
    @FinanceReserve ,
    @CreditLifePremium ,
    @CreditLifeCommision ,
    @TotalInsuranceReserve ,
    @BalloonAmount ,
    @CashPrice ,
    @AmountFinanced ,
    @TotalOfPayments ,
    @MSRP ,
    @DownPayment ,
    @SecurityDesposit ,
    @Rebate ,
    @Term ,
    @RetailPayment ,
    @PaymentType ,
    @RetailFirstPayDate ,
    @LeaseFirstPayDate ,
    @DayToFirstPayment ,
    @LeaseAnnualMiles ,
    @MileageRate ,
    @APRRate ,
    @ResidualAmount ,
    @LicenseFee ,
    @RegistrationFee ,
    @TotalTax ,
    @ExtendedWarrantyName ,
    @ExtendedWarrantyTerm ,
    @ExtendedWarrantyLimitMiles ,
    @ExtendedWarrantyDollar ,
    @ExtendedWarrantyProfit ,
    @FrontGross ,
    @BackGross ,
    @TradeIn_1_VIN ,
    @TradeIn_2_VIN ,
    @TradeIn_1_Make ,
    @TradeIn_2_Make ,
    @TradeIn_1_Model ,
    @TradeIn_2_Model ,
    @TradeIn_1_ExteriorColor ,
    @TradeIn_2_ExteriorColor ,
    @TradeIn_1_Year ,
    @TradeIn_2_Year ,
    @TradeIn_1_Mileage ,
    @TradeIn_2_Mileage ,
    @TradeIn_1_Gross ,
    @TradeIn_2_Gross ,
    @TradeIn_1_Payoff ,
    @TradeIn_2_Payoff ,
    @TradeIn_1_ACV ,
    @TradeIn_2_ACV ,
    @Fee_1_Name ,
    @Fee_1_Fee ,
    @Fee_1_Commission ,
    @Fee_2_Name ,
    @Fee_2_Fee ,
    @Fee_2_Commission ,
    @Fee_3_Name ,
    @Fee_3_Fee ,
    @Fee_3_Commission ,
    @Fee_4_Name ,
    @Fee_4_Fee ,
    @Fee_4_Commission ,
    @Fee_5_Name ,
    @Fee_5_Fee ,
    @Fee_5_Commission ,
    @Fee_6_Name ,
    @Fee_6_Fee ,
    @Fee_6_Commission ,
    @Fee_7_Name ,
    @Fee_7_Fee ,
    @Fee_7_Commission ,
    @Fee_8_Name ,
    @Fee_8_Fee ,
    @Fee_8_Commission ,
    @Fee_9_Name ,
    @Fee_9_Fee ,
    @Fee_9_Commission ,
    @Fee_10_Name ,
    @Fee_10_Fee ,
    @Fee_10_Commission ,
    @ContractDate ,
    @InsuranceName ,
    @InsuranceAgentName ,
    @InsuranceAddress ,
    @InsuranceCity ,
    @InsuranceState ,
    @InsuranceZip ,
    @InsurancePhone ,
    @InsurancePolicyNumber ,
    @InsuranceEffectiveDate ,
    @InsuranceExpirationDate ,
    @InsuranceCompensationDeduction ,
    @TradeIn_1_InteriorColor ,
    @TradeIn_2_InteriorColor ,
    @PhoneBlock ,
    @LicensePlateNumber ,
    @Cost ,
    @InvoiceAmount ,
    @FinanceCharge ,
    @TotalPickupPayment ,
    @TotalAccessories ,
    @TotalDriveOffAmount ,
    @EmailBlock ,
    @ModelDescriptionOfCarSold ,
    @VehicleClassification ,
    @ModelNumberOfCarSold ,
    @GAPPremium ,
    @LastInstallmentDate ,
    @CashDeposit ,
    @AHPremium ,
    @LeaseRate ,
    @DealerSelect ,
    @LeasePayment ,
    @LeaseNetCapCost ,
    @LeaseTotalCapReduction ,
    @DealStatus ,
    @CustomerSuffix ,
    @CustomerSalutation ,
    @CustomerAddress2 ,
    @CustomerMiddleName ,
    @GlobalOptOut ,
    @LeaseTerm ,
    @ExtendedWarrantyFlag ,
    @Salesman_3_Number ,
    @Salesman_3_Name ,
    @Salesman_4_Number ,
    @Salesman_4_Name ,
    @Salesman_5_Number ,
    @Salesman_5_Name ,
    @Salesman_6_Number ,
    @Salesman_6_Name ,
    @APRRate2 ,
    @APRRate3 ,
    @APRRate4 ,
    @Term2 ,
    @SecurityDeposit2 ,
    @DownPayment2 ,
    @TotalOfPayments2 ,
    @BasePayment ,
    @JournalSaleAmount ,
    @IndividualBusinessFlag ,
    @InventoryDate ,
    @StatusDate ,
    @ListPrice ,
    @NetTradeAmount ,
    @TrimLevel ,
    @SubTrimLevel ,
    @BodyDescription ,
    @BodyDoorCount ,
    @TransmissionDesc ,
    @EngineDesc ,
    @TypeCode ,
    @SLCT2 ,
    @DealDateOffset ,
    @AccountingDate ,
    @CoBuyerCustNum ,
    @CoBuyerCell ,
    @CoBuyerEmail ,
    @CoBuyerSalutation ,
    @CoBuyerPhoneBlock ,
    @CoBuyerMailBlock ,
    @CoBuyerEmailBlock ,
    @RealBookDate ,
    @CoBuyerMiddleName ,
    @CoBuyerCountry ,
    @CoBuyerAddress2 ,
    @CoBuyerOptOut ,
    @CoBuyerOccupation ,
    @CoBuyerEmployer ,
    @Country ,
    @Occupation ,
    @Employer ,
    @Salesman2Commission ,
    @BankAddress ,
    @BankCity ,
    @BankState ,
    @BankZip ,
    @LeaseEstimatedMiles ,
    @AFTReserve ,
    @CreditLifePrem ,
    @CreditLifeRes ,
    @AHRes ,
    @Language ,
    @BuyRate ,
    @DMVAmount ,
    @Weight ,
    @StateDMVTotFee ,
    @ROSNumber ,
    @Incentives ,
    @CASS_STD_LINE1 ,
    @CASS_STD_LINE2 ,
    @CASS_STD_CITY ,
    @CASS_STD_STATE ,
    @CASS_STD_ZIP ,
    @CASS_STD_ZIP4 ,
    @CASS_STD_DPBC ,
    @CASS_STD_CHKDGT ,
    @CASS_STD_CART ,
    @CASS_STD_LOT ,
    @CASS_STD_LOTORD ,
    @CASS_STD_URB ,
    @CASS_STD_FIPS ,
    @CASS_STD_EWS ,
    @CASS_STD_LACS ,
    @CASS_STD_ZIPMOV ,
    @CASS_STD_Z4LOM ,
    @CASS_STD_NDIAPT ,
    @CASS_STD_NDIRR ,
    @CASS_STD_LACSRT ,
    @CASS_STD_ERROR_CD ,
    @NCOA_AC_ID ,
    @NCOA_COA_ADDSRC ,
    @NCOA_COA_MATCH ,
    @NCOA_COA_MOVTYP ,
    @NCOA_COA_DATE ,
    @NCOA_COA_DELCD ,
    @NCOA_COA_RTYPE ,
    @NCOA_COA_RTNCD ,
    @NCOA_COA_LINE1 ,
    @NCOA_COA_LINE2 ,
    @NCOA_COA_CITY ,
    @NCOA_COA_STATE ,
    @NCOA_COA_ZIP ,
    @NCOA_COA_ZIP4 ,
    @NCOA_COA_DPBC ,
    @NCOA_COA_CHKDGT ,
    @NCOA_COA_CART ,
    @NCOA_COA_LOT ,
    @NCOA_COA_LOTORD ,
    @NCOA_COA_URB ,
    @NCOA_COA_Z4LOM ,
    @NCOA_COA_ACTION ,
    @NCOA_COA_QNAME ,
    @NCOA_DPV_AA ,
    @NCOA_DPV_A1 ,
    @NCOA_DPV_BB ,
    @NCOA_DPV_CC ,
    @NCOA_DPV_M1 ,
    @NCOA_DPV_M3 ,
    @NCOA_DPV_N1 ,
    @NCOA_DPV_P1 ,
    @NCOA_DPV_P3 ,
    @NCOA_DPV_RR ,
    @NCOA_DPV_R1 ,
    @NCOA_DPV_STATUS ,
    @NCOA_DPV_F1 ,
    @NCOA_DPV_G1 ,
    @NCOA_DPV_U1;
    END
    CLOSE Sales_Cursor;
    DEALLOCATE Sales_Cursor;
    GO
    SET ANSI_PADDING OFF
    GO

    Duplicate thread:
    problem - original

  • Call a function inside a package from a stored procedure

    Hello:
    I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
    I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
    can I do the following in proc_c:
    my_cursor1 SYS_REFCURSOR;
    begin
    my_cursor1 := exec pack_a.func_b
    end
    It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.

    guys:
    Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
    I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
    DECLARE TEMP VARCHAR2(100);
    BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
    I tried to use 'set serveroutput on' and got the following error:
    ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1
    I am kind of confused now. thank you for your help.
    Jack
    Here is my procedure:
    create or replace
    PROCEDURE PROC_SEARCH
    ( AGENCY_ID IN VARCHAR2,
    DEVICE_ID IN VARCHAR2,
    L_NAME IN VARCHAR2,
    F_NAME IN VARCHAR2,
    SEX IN VARCHAR2,
    DOB IN VARCHAR2,
    CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
    AS
    v_agy_id varchar2(10);
    v_device_id varchar2(20);
    v_l_name varchar2(25);
    v_f_name varchar2(15);
    v_sex varchar2(1);
    v_dob date;
    -- this cursor is going to be used to store a list of warrant matching
    -- name search criteria
    cad_srch_cursor sys_refcursor;
    objSrch SEARCH_RESULT_TEMP%ROWTYPE;
    BEGIN
    cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
    LOOP
    FETCH cad_srch_cursor INTO objSrch;
    EXIT WHEN cad_srch_cursor%NOTFOUND;
    --insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
    CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
    dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
    end LOOP;
    END PROC_LAWS_SEARCH;
    -----------------------------------------

  • Create a new table from another table that exists ussing a stored procedure

    Hi,
    I want to know if is posibble to create a new table from another table that exists ussing a stored procedure. This new table is created from other table that exists in the DB.
    (in the next code the table tbl1 exist into the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)
    create or replace procedute temp is
    temp_tbl1 tbl1%TYPE; //the temp_tbl1 will have the same type of tbl1
    begin
    create table temp_tbl1 as (select * from tbl1);
    end temp;
    thanks very much

    cat wrote:
    Hello,
    I think my problem is not about this grant, because if I execute this as an "anonymous procedure":
    DECLARE
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
    END;
    It runs ok
    But if I do:
    CREATE OR REPLACE procedure temp as
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
    END;
    I have the error
    ORA-01031: Insufficient privileges
    ORA-06512: at "temp", line 3Anonymous blocks are treated as "Invoker's Rights" from a privilege perspective whereas stored programs by default are treated as "Definer's Rights". Therefore using anonymous blocks is not a valid test to check this.
    The simplest form of checking this issue is by executing
    SET ROLE NONE;and then to run your statement/code block in question interactively. Using this approach you get in your session the effective rights of a "Definer's Rights" stored program, i.e. only privileges that you got granted directly to your user.
    You can revert to the default setting by issuing
    SET ROLE ALL;For more information regarding this topic, read e.g. the documentation:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#LNPLS00809
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Call a UNIX shell script from an oracle stored procedure

    We need to call a UNIX shell script from an oracle stored procedure
    i.e. the control should come back to the procedure once the script completes. Can any body help to achieve this ?

    There are various ways in achieving this.
    For Example, you can call a PRO*C-Library residing on the database server.
    This requires a PL/SQL library to be generated and some changes to the Listener configuration.
    It is also possible to implement a java procedure on the database being invoked by a PL/SQL wrapper class.
    In this way (and if used right) there is also granularity regarding the filestructure permissions given and it may be called during a Forms or other PL/SQL session.
    The article below explains a more generic approach how to invoke shell commands from within an Oracle Instance.
    Be careful with this, because it really works ;)
    Refer to :
    http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
    Message was edited by:
    user434854

  • Problem in using ref cursor

    I have a procedure which is using one ref cursor as OUT paramater. Now when I call this procedure, it gives me the following error:
    ORA-00932: inconsistent datatypes: expected CURSER got NUMBER
    ORA-06512: at "APPS.ORDER_RETURN1", line 8
    ORA-06512: at "APPS.ORDER_RETURN2", line 4
    ORA-06512: at line 1
    Below is my code
    PROCEDURE ORDER_RETURN1(p_order OUT sys_refcursor) IS
    TYPE OE_ORDER_rcur IS REF CURSOR;
    rcur OE_ORDER_rcur;
    BEGIN
    OPEN rcur FOR
    SELECT ORDER_NUMBER FROM OE_ORDER_HEADERS_ALL WHERE ROWNUM < 4;
    FETCH rcur INTO p_order;
    CLOSE rcur;
    END ORDER_RETURN1;
    PROCEDURE ORDER_RETURN2 IS
    OE_ORDER_rcur11 sys_refcursor;
    BEGIN
    ORDER_RETURN1(OE_ORDER_rcur11);
    end;
    I tried to call proc ORDER_RETURN1 with the help of proc ORDER_RETURN2, but no change, it gives me same error if i call the first proc ORDER_RETURN1 or i call ORDER_RETURN2.
    I am stuck with this problem, I had used ref cursor in procedure but not able to call the procedure which uses ref cursor as OUT parameter.
    Please help me to resolve this.
    Thanks
    Nidhi..

    Check out this
    SQL>VARIABLE X REFCURSOR
    SQL>CREATE OR REPLACE PROCEDURE ORDER_RETURN1(p_order OUT sys_refcursor) IS
      2  BEGIN
      3  OPEN p_order FOR
      4  SELECT OBJECT_ID FROM ALL_OBJECTS WHERE ROWNUM < 4;
      5  END ORDER_RETURN1;
      6  /
    Procedure created.
    SQL>EXEC ORDER_RETURN1(:X)
    PL/SQL procedure successfully completed.
    SQL>PRINT X
    OBJECT_ID
             4
            39
            30
    SQL>Regards
    Arun

  • Problem in passing ref cursor values as parameter in where clau.Most Urgent

    Problem:
    1) I have used normal cursor (C_hubmsgid_set) with some select statement such as grouping and all.
    After executing the query it will return some resultset to the specified cursor.
    2) I am trying to use another cursor which is ref cursor but the problem is
    I want to give all the resultset based on all the conditions to the ref cursor.
    But the cursor will get only the last record due to overwriting .how to get all
    the result set in a ref cursor like
    cursor c1 is select .....
    loop
    open refcursor for
    Select * from ....where condition
    end loop
    After this the refcursor( p_sysaudithistory_cur) which should have all the resultset matched by the where condition.
    3. It should be java compatible one.
    4. I am not able to match cursor row = IN Pameter value
    Below is the query:
    CREATE OR REPLACE PROCEDURE SP_TEST_audit_history2 (
    p_start IN date,
    p_end IN date,
    p_msgcode IN varchar2,
    p_partnername IN varchar2,
    p_status IN varchar2,
    p_locationname IN varchar2,
    p_custbusunit IN varchar2,
    p_sysaudithistory_cur OUT plutotypes.ref_cursor,
    p_status1 OUT NUMBER) AS
    l_status NUMBER := 0;
    CURSOR C_hubmsgid_set IS
    SELECT DISTINCT MAX(tfm.datetime) datetime, tfm.hubmsgid
    FROM tfm_status tfm, vw_msgcode_part_locn vw
    WHERE
    tfm.datetime >= NVL(p_start, TO_DATE('01/01/1981','DD/MM/YYYY')) AND
    tfm.datetime <= NVL(p_end, TO_DATE('31/12/9999','DD/MM/YYYY')) AND
    tfm.msgcode LIKE NVL(p_msgcode,'%') AND
    vw.msgcode = tfm.msgcode
    AND vw.partnername LIKE NVL(p_partnername,'%')
    AND tfm.status LIKE NVL(p_status,'%')
    AND vw.locationname LIKE NVL(p_locationname,'%')
    AND vw.custbusunit LIKE NVL(p_custbusunit,'%')
    AND rownum < 250
    GROUP BY tfm.hubmsgid
    ORDER BY datetime DESC;
    /* Loop through the Cursor */
    BEGIN
    BEGIN
    OPEN p_sysaudithistory_cur
    FOR
    SELECT
    tfm.hubmsgid ,
    tfm.status || '-'|| nvl2(tfm.exception_id,'FAILED','OK') ,
    tfm.datetime,
    tfm.exception_id
    FROM tfm_status tfm
    WHERE tfm.hubmsgid = c_hubmsgids.hubmsgid /* here only i am getting error*/
    AND tfm.datetime = c_hubmsgids.datetime
    AND tfm.status like NVL(p_status,'%')
    and rownum =1;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    l_status := 1;
    END;
    p_status1 := l_status;
    END;
    Thanks in advance
    prasanth a.s.

    Please don't post duplicate questions. All it does is clutter the forums and result in fragmented threads and duplicate responses. Please see my response in the original thread at the link below.
    Please solve this Refcursor issue PLEASE

  • Stored procedure call with REF CURSOR from JDBC

    How can I call a SP with a REF CURSOR OUT parameter from JDBC?

    This is a breeze.
    CallableStatement oraCall = oraConn.prepareCall("BEGIN PKG_SOMETHING.RETURNS_A_SP(?);END;");
    oraCall.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR);
    oraCall.execute();
    ResultSet rsServList = (ResultSet) oraCall.getObject(1);
    ... use ResultSet ...
    rsServList.close();
    oraCall.close();
    slag

  • Ref cursors don't work in declared procedures?

    It appears that ref cursors in declared procedures don't work.
    For example, the following code runs with no errors, but returns nothing from the ref cursor -
    s = s & "DECLARE" & vbLf
    s = s & " TYPE OutCurType IS REF CURSOR;" & vbLf
    s = s & "PROCEDURE xxxProc(p5 in out OutCurType )" & vbLf
    s = s & " AS" & vbLf
    s = s & "BEGIN" & vbLf
    s = s & " OPEN p5 FOR SELECT * FROM table;" & vbLf
    s = s & "END xxxProc;" & vbLf
    s = s & "BEGIN" & vbLf
    s = s & " xxxProc( :p5 );" & vbLf
    s = s & "END;" & vbLf
    oCmd.CommandText = s
    oCmd.CommandType = CommandType.Text
    oParam6.ParameterName = "p5"
    oParam6.OracleDbType = Oracle.DataAccess.Client.OracleDbType.RefCursor
    oParam6.Direction = ParameterDirection.Output
    oParam6.Value = DBNull.Value
    oCmd.Parameters.Add(oParam6)
    oCmd.ExecuteNonQuery()
    oDR = CType(oCmd.Parameters("p5").Value, Oracle.DataAccess.Types.OracleRefCursor).GetDataReader
    While oDR.Read
    Stop
    End While
    However, a previously created procedure executes fine, in the above code -
    s = "BEGIN" & vbLf
    s = s & " xxxPkg.xxxProc( :p5 );" & vbLf
    s = s & "END;" & vbLf
    Is there a way to get ref cursors to work in declared procedures? Thanks...

    Fixed the grid cell display and popup editor for Ref Cursors.
    -Raghu

  • Cursor with nested query in stored procedure problem

    Hello
    I'm trying to declare the folowing (example) cursor in a stored procedure in Oracle 8i:
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    The nested part "(SELECT d.DUMMY FROM dual)" is not alowed, while the same query runs outside the stored procedure. Can someone explain why this is not alowed and how to solve the problem whitout rewriting the query?
    Tom

    When i run the same code in SQL plus:
    SQL> declare
    2 CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    3 begin
    4 null;
    5 end;
    6 /
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    FOUT in regel 2:
    .ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + mod not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string>
    ORA-06550: line 2, column 66:
    PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
    ; return returning and or
    Different versions of Oracle?

  • Problem with a resultset before a delete in a stored procedure

    We have been using the Microsoft provider in the past. However, we now need to use CLOBs, so we would like to move to the Oracle provider. However, we have several stored procedures that select some data out of a table, compile a result set, and then delete those records. This is all done as one transaction.
    So, for instance:
    CREATE OR REPLACE PACKAGE TESTPKG IS
    TYPE t_userid IS TABLE OF INT INDEX BY BINARY_INTEGER;
    END;
    CREATE OR REPLACE PROCEDURE SP_TESTPROC(o_userid OUT EZTESTPKG.t_userid) IS
    counter NUMBER DEFAULT 1;
    CURSOR v_cursor IS
    SELECT userid
    FROM MyTempUsers;
    BEGIN
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
    FOR i IN v_cursor LOOP
    o_userid(counter):=i.userid;
    counter:=counter+1;
    END LOOP;
    DELETE FROM MyTempUsers;
    COMMIT;
    END;
    this is called with and ADO CommandText of:
    {call SP_TESTPROC({resultset 200, o_userid})}
    Now, I simplified my example, but a reference cursor will not work because of the delete that would happen after the select. And I know that "resultset" is specific to the Microsoft provider.
    Is there anyway to get these output parameters back to my ADO application in a manner similar to the Microsoft provider? Or in any method? Cursors are great, but in this case, all I would get would be an empty resultset, because of the Delete. Correct?

    1. The reason as you said is the ISOLATION level(Serializable). This creates an exclusive lock on the data that has been selected from the table into the cursor(which is created in memory) and thus you cannot update or delete any of the selected.
    2. You could still use a reference cursor because it resides in memory and does not reperesent any changes made to the table on disk provided that there are no locks in palce(this is true in your case).

  • Cursors in Oracle 10g XE stored procedures

    I want to use a cursor in a stored procedure. I saw many examples on the net but none of them seem to work in Oracle 10g Express Edition.
    I am new to Oracle and any solution relevant to Oracle 10g XE is highly appreciated.
    Yosief Kesete

    Dear user!
    Simple error. Try that:
    CREATE OR REPLACE PROCEDURE "employeesgetlist
      p_FIRST_NAME IN VARCHAR2,
      returnValue OUT SYS_REFCURSOR
    IS
      p_EMPLOYEE_ID NUMBER;
      CURSOR C1 IS
      SELECT employee_id
      FROM employees
      WHERE first_name = p_FIRST_NAME;
    BEGIN
      BEGIN
        -- OPEN A PREVIOUSLY DECLARED CURSOR
        OPEN C1;
        LOOP
          FETCH C1 INTO p_EMPLOYEE_ID;
          EXIT WHEN C1%NOTFOUND;
        END LOOP;
         -- CLOSE THE CURSOR
        CLOSE C1;
      END;
      OPEN returnValue FOR
      SELECT * FROM employees
      WHERE employee_id = p_EMPLOYEE_ID;
    END;
    {code}
    Yours sincerely
    Florian W.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Calling the Java Method in PL/SQL Java Stored procedure errors out

    Hi,
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........
    I have written a java class by name XYZ which has a method ABC for which there are 9 arguements being passed and its a VOID method.
    This java class has been loaded into ORACLE using DBMS_JAVA.LOADJAVA pkg, Now this class is being called in the oracle as a JAVA Stored procedure...... When ever im trying to call the procedure it throws the following error
    ORA-29531: no method
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    The code snippet as follows
    JAVA CODE:
    Class xyz
    public static void Abc (String hostName,
    int port,
    String serviceURL,
    String soapAction,
    int timeOut,
    String wsUser,
    String wsPasWd,
    String keyStore,
    String keyStorePasWd)
    //method implementation
    JAVA STORED PROCEDURE:
    create OR REPLACE procedure ABC_JAVA_SP_CALL
    (p_hostname in varchar2, p_port in number, p_serviceurl in varchar2, p_soapaction in varchar2, p_timeout in number, p_wsuser in varchar2, p_wspasswd in varchar2, p_ks_path in varchar2, p_ks_passwd in varchar2)
    as
    language java
    name 'xyz.Abc(java.lang.String, int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)';
    When i try to call
    declare
    p_hostname varchar2(100);
    p_port number;
    p_serviceurl varchar2(100);
    p_soapaction varchar2(100);
    p_timeout number;
    p_wsuser varchar2(100);
    p_wspasswd varchar2(100);
    p_ks_path varchar2(100);
    p_ks_passwd varchar2(100);
    begin
    //SP which returns the values for the required parameters.
    comppkg.getvcsinfo(
    p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd
    Layer7_icengc_ws_tes(p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd);
    end;
    This thing ends up with
    29531. 00000 - "no method %s in class %s"
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    Im not understanding what wrong am i doing
    pls help
    Edited by: madhusudan on Feb 12, 2013 8:07 PM

    Hello,
    there is the forum {forum:id=65} for questions about using Java within Oracle.
    Regards
    Marcus
    Edited by: Marwim on 13.02.2013 07:56
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........You got the hint to the correct forum alread in another thread {message:id=10837976}
    And if you think this is not related to Java but PL/SQL, then you should ask in {forum:id=75}

  • Calling a function in remote database inside a stored procedure

    There are 2 Oracle databases with pseudo names Remote and Local. I have a function in Remote called FUS.F_Return_10 which simply returns 10 for testing purposes, where FUS is a schema name. In Local I want to create a procedure that will call the above function. Here's the PL/SQL:
    CREATE OR REPLACE PROCEDURE TEST
    V_COUNT OUT NUMBER
    AS
    V_FOO NUMBER(2,0);
    BEGIN
    V_FOO:= FUS.F_Return_10@PER_ACC;
    SELECT COUNT(*) INTO v_count FROM persons WHERE DEPID=V_FOO;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    v_count :=0;
    END;
    There's a Public Database Link called PER_ACC in Local. When I try to create this procedure I get: Encountered symbol "@" when expecting one of the following: .(*%&................
    Can you tell me where my mistake is?

    Always verify your link works first by issuing:
    select * from dual@dblinkname
    Also do you have a private database link with the same name in the schema you are using, because the database will use this link before it uses the public link.
    Also make sure the Package you are calling has execute privileges granted directly , not through a role. If your uses does not exist on the other database, you will most likely need to grant execute privilege to public.
    Finally, if its not in the same schema name then you need to prefix your call with the schema name or create a public synonym for the package.

Maybe you are looking for

  • How to perform a reverse "Flowed" positioning subform

    Hello Gurus I need to create an Adobe form with a footer that will be reproduced on each pages. The size of the footer will be determine by the text that will be put in from a parameter passed to the adobe form. So, the footer needs to be at the bott

  • Some album art not displaying in

    I have the latest firmware release (.60.0). After either syncing via an app or simply dragging and dropping via Media Explorer, some album art does not display properly in my ZVM in the Album art view nor when the song is played. The method I used is

  • Odd file access issues OES 11 SP1

    Hello, We're running a VMWare ESXi 5.1 cluster. On that we have an OES 11 cluster managing groupwise/iprint/nss/dhcp/dns services. Over the summer we updated to SP1 on the OES side. This school year we have seen some odd issues, particularly with our

  • Query to get the customer's ship_to  Phone# and Fax#

    Gurus - Can anyone of you please help me in getting a query to shows the phoen and fax# of the Customer's ship_to Phone# and fax# customers--> on Address tab ( click open) On next screen click on contacts tabe for SHIP_TO row , there under the commun

  • Deletion of Vendor

    Hi Friends, I have deleted few vendors by using T-code XK06. Can anybody tell me after how many days it will be completely deleted from database????Because I can remove the flag for deletion in T-code XK06 also. In that case what is the difference be