Returing clause with select and insert

Hi,
I am trying to use the following query but its not working.I want to know whether this syntax is valid.
Insert into t_name( , , ,)
Select , , , from t_name2
Returing into , , , .
There is only one row I am dealing with.
Thanks a Lot !!!
Edited by: user10619253 on Jan 16, 2009 12:52 AM

Hi user michaels2,
Whwn I am trying with the above example its working but for more then 1 column its not working
SQL> declare
2 x int;
3 begin
4 insert into emp (empno,ENAME)
5 values ( ( select 100,'ABC' from dual ) )
6 returning empno into x;
7 dbms_output.put_line ('Last Value Inserted: '||to_char (x));
8 end;
9 /
values ( ( select 100,'ABC' from dual ) )
ERROR at line 5:
ORA-06550: line 5, column 8:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 4, column 4:
PL/SQL: SQL Statement ignored
SQL>
Thanks !!!

Similar Messages

  • How to use direct select and insert or load to speedup the process instead of cursur

    Hi friends,
    I have stored procedure .In SP i am using cursur to load data from Parent to several child table.
    I have attached the script with this message.
    And my problem is how to use direct select and insert or load to speedup the process instead of cursur.
    Can any one please suggest me how to change this scripts pls.
    USE [IconicMarketing]
    GO
    /****** Object: StoredProcedure [dbo].[SP_DMS_INVENTORY] Script Date: 3/6/2015 3:34:03 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <ARUN,NAGARAJ>
    -- Create date: <11/21/2014>
    -- Description: <STORED PROCEDURE FOR DMS_INVENTORY>
    -- =============================================
    ALTER PROCEDURE [dbo].[SP_DMS_INVENTORY]
    @Specific_Date varchar(20) ,
    @DealerNum Varchar(6),
    @Date_Daily varchar(50)
    AS
    BEGIN
    SET NOCOUNT ON;
    --==========================================================================
    -- INVENTORY_CURSUR
    --==========================================================================
    DECLARE
    @FileType varchar(50),
    @ACDealerID varchar(50),
    @ClientDealerID varchar(50),
    @DMSType varchar(50),
    @StockNumber varchar(50),
    @InventoryDate datetime ,
    @StockType varchar(100),
    @DMSStatus varchar(50),
    @InvoicePrice numeric(18, 2),
    @CostPack varchar(50),
    @SalesCost numeric(18, 2),
    @HoldbackAmount numeric(18, 2),
    @ListPrice numeric(18, 2),
    @MSRP varchar(max),
    @LotLocation varchar(50),
    @TagLine varchar(max),
    @Certification varchar(max),
    @CertificationNumber varchar(max),
    @VehicleVIN varchar(50),
    @VehicleYear bigint ,
    @VehicleMake varchar(50),
    @VehicleModel varchar(50),
    @VehicleModelCode varchar(50),
    @VehicleTrim varchar(50),
    @VehicleSubTrimLevel varchar(max),
    @Classification varchar(max),
    @TypeCode varchar(100),
    @VehicleMileage bigint ,
    @EngineCylinderCount varchar(10) ,
    @TransmissionType varchar(50),
    @VehicleExteriorColor varchar(50),
    @VehicleInteriorColor varchar(50),
    @CreatedDate datetime ,
    @LastModifiedDate datetime ,
    @ModifiedFlag varchar(max),
    @InteriorColorCode varchar(50),
    @ExteriorColorCode varchar(50),
    @PackageCode varchar(50),
    @CodedCost varchar(50),
    @Air varchar(100),
    @OrderType varchar(max),
    @AgeDays bigint ,
    @OutstandingRO varchar(50),
    @DlrAccessoryRetail varchar(50),
    @DlrAccessoryCost varchar(max),
    @DlrAccessoryDesc varchar(max),
    @ModelDesc varchar(50),
    @Memo1 varchar(1000),
    @Memo2 varchar(max),
    @Weight varchar(max),
    @FloorPlan numeric(18, 2),
    @Purchaser varchar(max),
    @PurchasedFrom varchar(max),
    @InternetPrice varchar(50),
    @InventoryAcctDollar numeric(18, 2),
    @VehicleType varchar(50),
    @DealerAccessoryCode varchar(50),
    @AllInventoryAcctDollar numeric(18, 2),
    @BestPrice varchar(50),
    @InStock bigint ,
    @AccountingMake varchar(50),
    @GasDiesel varchar(max),
    @BookValue varchar(10),
    @FactoryAccessoryDescription varchar(max),
    @TotalReturn varchar(10),
    @TotalCost varchar(10),
    @SS varchar(max),
    @VehicleBody varchar(max),
    @StandardEquipment varchar(max),
    @Account varchar(max),
    @CalculatedPrice varchar(10),
    @OriginalCost varchar(10),
    @AccessoryCore varchar(10),
    @OtherDollar varchar(10),
    @PrimaryBookValue varchar(10),
    @AmountDue varchar(10),
    @LicenseFee varchar(10),
    @ICompany varchar(max),
    @InvenAcct varchar(max),
    @Field23 varchar(max),
    @Field24 varchar(max),
    @SalesCode bigint,
    @BaseRetail varchar(10),
    @BaseInvAmt varchar(10),
    @CommPrice varchar(10),
    @Price1 varchar(10),
    @Price2 varchar(10),
    @StickerPrice varchar(10),
    @TotInvAmt varchar(10),
    @OptRetail varchar(max),
    @OptInvAmt varchar(10),
    @OptCost varchar(10),
    @Options1 varchar(max),
    @Category varchar(max),
    @Description varchar(max),
    @Engine varchar(max),
    @ModelType varchar(max),
    @FTCode varchar(max),
    @Wholesale varchar(max),
    @Retail varchar(max),
    @Draft varchar(max),
    @myerror varchar(500),
    @Inventoryid int,
    @errornumber int,
    @errorseverity varchar(500),
    @errortable varchar(50),
    @errorstate int,
    @errorprocedure varchar(500),
    @errorline varchar(50),
    @errormessage varchar(1000),
    @Invt_Id int,
    @flatfile_createddate datetime,
    @FtpDate date,
    @Inv_cur varchar(1000),
    @S_Year varchar(4),
    @S_Month varchar(2),
    @S_Date varchar(2),
    @Date_Specfic varchar(50),
    @Param_list nvarchar(max),
    @Daily_Date Varchar(50);
    --====================================================================================
    --DECLARE CURSUR FOR SPECIFIC DATE (OR) DEALER-ID WITH SPECIFIC DATE (OR) CURRENT DATE
    --====================================================================================
    set @Date_Specfic = Substring(@Specific_Date,1,4) +'-'+Substring(@Specific_Date,5,2)+'-'+Substring(@Specific_Date,7,2);
    set @Daily_Date = SUBSTRING(@Date_Daily,14,4) + '-' + SUBSTRING(@Date_Daily,18,2)+ '-' + SUBSTRING(@date_Daily,20,2)
    IF @Daily_Date IS NOT NULL
    BEGIN
    Delete From [dbo].[DMS_INVENTORY_DETAILS]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    Delete From [dbo].[DMS_INVENTORY_AMOUNT]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
    Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    Delete From [dbo].[DMS_INVENTORY_VEHICLE]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
    Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    Delete From [dbo].[DMS_INVENTORY]
    Where ID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
    DECLARE Inventory_Cursor CURSOR FOR
    SELECT * from [dbo].[FLATFILE_INVENTORY] where
    CONVERT (date,flatfile_createddate) = CONVERT (date,GETDATE()) order by flatfile_createddate;
    END
    Else
    BEGIN
    if (@Date_Specfic IS NOT NULL AND @DealerNum != '?????')
    BEGIN
    Delete From [dbo].[DMS_INVENTORY_DETAILS]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    Delete From [dbo].[DMS_INVENTORY_AMOUNT]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
    Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    Delete From [dbo].[DMS_INVENTORY_VEHICLE]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
    Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    Delete From [dbo].[DMS_INVENTORY]
    Where ID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
    DECLARE Inventory_Cursor CURSOR FOR
    SELECT * from [dbo].[FLATFILE_INVENTORY] where FtpDate=@Date_Specfic AND ACDealerID='ACTEST' + @DealerNum;
    END
    ELSE
    BEGIN
    Delete From [dbo].[DMS_INVENTORY_DETAILS]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    Delete From [dbo].[DMS_INVENTORY_AMOUNT]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
    Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    Delete From [dbo].[DMS_INVENTORY_VEHICLE]
    Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
    Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    Delete From [dbo].[DMS_INVENTORY]
    Where ID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
    DECLARE Inventory_Cursor CURSOR FOR
    SELECT * from [dbo].[FLATFILE_INVENTORY] where FtpDate=@Date_Specfic;
    END
    END
    OPEN Inventory_Cursor
    FETCH NEXT FROM Inventory_Cursor
    INTO
    @FileType ,
    @ACDealerID ,
    @ClientDealerID ,
    @DMSType ,
    @StockNumber ,
    @InventoryDate ,
    @StockType ,
    @DMSStatus ,
    @InvoicePrice ,
    @CostPack ,
    @SalesCost ,
    @HoldbackAmount ,
    @ListPrice ,
    @MSRP ,
    @LotLocation ,
    @TagLine ,
    @Certification ,
    @CertificationNumber ,
    @VehicleVIN ,
    @VehicleYear ,
    @VehicleMake ,
    @VehicleModel ,
    @VehicleModelCode ,
    @VehicleTrim ,
    @VehicleSubTrimLevel ,
    @Classification ,
    @TypeCode ,
    @VehicleMileage ,
    @EngineCylinderCount ,
    @TransmissionType ,
    @VehicleExteriorColor ,
    @VehicleInteriorColor ,
    @CreatedDate ,
    @LastModifiedDate ,
    @ModifiedFlag ,
    @InteriorColorCode ,
    @ExteriorColorCode ,
    @PackageCode ,
    @CodedCost ,
    @Air ,
    @OrderType ,
    @AgeDays ,
    @OutstandingRO ,
    @DlrAccessoryRetail ,
    @DlrAccessoryCost ,
    @DlrAccessoryDesc ,
    @ModelDesc ,
    @Memo1 ,
    @Memo2 ,
    @Weight ,
    @FloorPlan ,
    @Purchaser ,
    @PurchasedFrom ,
    @InternetPrice ,
    @InventoryAcctDollar ,
    @VehicleType ,
    @DealerAccessoryCode ,
    @AllInventoryAcctDollar ,
    @BestPrice ,
    @InStock ,
    @AccountingMake ,
    @GasDiesel ,
    @BookValue ,
    @FactoryAccessoryDescription ,
    @TotalReturn ,
    @TotalCost ,
    @SS ,
    @VehicleBody ,
    @StandardEquipment ,
    @Account ,
    @CalculatedPrice ,
    @OriginalCost ,
    @AccessoryCore ,
    @OtherDollar ,
    @PrimaryBookValue ,
    @AmountDue ,
    @LicenseFee ,
    @ICompany ,
    @InvenAcct ,
    @Field23 ,
    @Field24 ,
    @SalesCode ,
    @BaseRetail ,
    @BaseInvAmt ,
    @CommPrice ,
    @Price1 ,
    @Price2 ,
    @StickerPrice ,
    @TotInvAmt ,
    @OptRetail ,
    @OptInvAmt ,
    @OptCost ,
    @Options1 ,
    @Category ,
    @Description ,
    @Engine ,
    @ModelType ,
    @FTCode ,
    @Wholesale ,
    @Retail ,
    @Draft ,
    @flatfile_createddate,
    @FtpDate;
    WHILE @@FETCH_STATUS = 0
    BEGIN
    --==========================================================================
    -- INSERT INTO INVENTORY (PARENT TABLE)
    --==========================================================================
    BEGIN TRY
    INSERT INTO [dbo].[DMS_INVENTORY]
    DMSDealerID,
    StockNumber,
    DMSType,
    InventoryDate,
    FtpDate
    VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate,@FtpDate);
    END TRY
    BEGIN CATCH
    SELECT
    @errornumber = ERROR_NUMBER(),
    @errorseverity = ERROR_SEVERITY(),
    @errortable = 'DMS_INVENTORY',
    @errorstate = ERROR_STATE(),
    @errorprocedure = ERROR_PROCEDURE(),
    @errorline = ERROR_LINE(),
    @errormessage = ERROR_MESSAGE();
    --==========================================================================
    -- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
    --==========================================================================
    EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
    @SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
    @VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
    @CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
    @DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
    @InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
    @FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
    @OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
    @Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
    @ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
    END CATCH
    -- PRINT @errornumber;
    -- PRINT @errorseverity;
    -- PRINT @errortable;
    -- PRINT @errorprocedure;
    -- PRINT @errorline;
    -- PRINT @errormessage;
    -- PRINT @errorstate;
    set @myerror = @@ERROR;
    -- This -- PRINT statement -- PRINTs 'Error = 0' because
    -- @@ERROR is reset in the IF statement above.
    -- PRINT N'Error = ' + @myerror;
    set @Inventoryid = scope_identity();
    -- PRINT @Inventoryid;
    --==========================================================================
    -- INSERT INTO DMS_INVENTORY_DETAILS (CHILD TABLE)
    --==========================================================================
    BEGIN TRY
    INSERT INTO [dbo].[DMS_INVENTORY_DETAILS]
    DMSInventoryID,
    StockType,
    DMSStatus,
    LotLocation,
    TagLine,
    Certification,
    CertificationNumber,
    CreatedDate,
    LastModifiedDate,
    ModifiedFlag,
    PackageCode,
    OrderType,
    AgeDays,
    OutstandingRO,
    Memo1,
    Memo2,
    Purchaser,
    PurchasedFrom,
    DealerAccessoryCode,
    InStock,
    AccountingMake,
    SS,
    Account,
    AccessoryCore,
    ICompany,
    InvenAcct,
    Field23,
    Field24,
    SalesCode,
    Draft,
    FTCode,
    FtpDate
    VALUES (
    @InventoryID,
    @StockType,
    @DMSStatus,
    @LotLocation,
    @TagLine,
    @Certification,
    @CertificationNumber,
    @CreatedDate,
    @LastModifiedDate,
    @ModifiedFlag,
    @PackageCode,
    @OrderType,
    @AgeDays,
    @OutstandingRO,
    @Memo1,
    @Memo2,
    @Purchaser,
    @PurchasedFrom,
    @DealerAccessoryCode,
    @InStock,
    @AccountingMake,
    @SS,
    @Account,
    @AccessoryCore,
    @ICompany,
    @InvenAcct,
    @Field23,
    @Field24,
    @SalesCode,
    @Draft,
    @FTCode,
    @FtpDate
    END TRY
    BEGIN CATCH
    SELECT
    @errornumber = ERROR_NUMBER(),
    @errorseverity = ERROR_SEVERITY(),
    @errorstate = ERROR_STATE(),
    @errortable = 'DMS_INVENTORY_DETAILS',
    @errorprocedure = ERROR_PROCEDURE(),
    @errorline = ERROR_LINE(),
    @errormessage = ERROR_MESSAGE();
    --==========================================================================
    -- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
    --==========================================================================
    EXECUTE [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
    @SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
    @VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
    @CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
    @DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
    @InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
    @FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
    @OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
    @Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
    @ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
    END CATCH
    --==========================================================================
    -- INSERT INTO DMS_INVENTORY_AMOUNT (CHILD TABLE)
    --==========================================================================
    BEGIN TRY
    INSERT INTO [dbo].[DMS_INVENTORY_AMOUNT]
    DMSInventoryID,
    AllInventoryAcctDollar,
    OtherDollar,
    PrimaryBookValue,
    AmountDue,
    LicenseFee,
    CalculatedPrice,
    OriginalCost,
    BookValue,
    TotalReturn,
    TotalCost,
    DlrAccessoryRetail,
    DlrAccessoryCost,
    DlrAccessoryDesc,
    InternetPrice,
    InventoryAcctDollar,
    BestPrice,
    Weight,
    FloorPlan,
    CodedCost,
    InvoicePrice,
    CostPack,
    SalesCost,
    HoldbackAmount,
    ListPrice,
    MSRP,
    BaseRetail,
    BaseInvAmt,
    CommPrice,
    Price1,
    Price2,
    StickerPrice,
    TotInvAmt,
    OptRetail,
    OptInvAmt,
    OptCost,
    Wholesale,
    Retail,
    FtpDate
    VALUES (
    @InventoryID,
    @AllInventoryAcctDollar,
    @OtherDollar,
    @PrimaryBookValue,
    @AmountDue,
    @LicenseFee,
    @CalculatedPrice,
    @OriginalCost,
    @BookValue,
    @TotalReturn,
    @TotalCost,
    @DlrAccessoryRetail,
    @DlrAccessoryCost,
    @DlrAccessoryDesc,
    @InternetPrice,
    @InventoryAcctDollar,
    @BestPrice,
    @Weight,
    @FloorPlan,
    @CodedCost,
    @InvoicePrice,
    @CostPack,
    @SalesCost,
    @HoldbackAmount,
    @ListPrice,
    @MSRP,
    @BaseRetail,
    @BaseInvAmt,
    @CommPrice,
    @Price1,
    @Price2,
    @StickerPrice,
    @TotInvAmt,
    @OptRetail,
    @OptInvAmt,
    @OptCost,
    @Wholesale,
    @Retail,
    @FtpDate
    END TRY
    BEGIN CATCH
    SELECT
    @errornumber = ERROR_NUMBER(),
    @errorseverity = ERROR_SEVERITY(),
    @errortable = 'DMS_INVENTORY_AMOUNT',
    @errorstate = ERROR_STATE(),
    @errorprocedure = ERROR_PROCEDURE(),
    @errorline = ERROR_LINE(),
    @errormessage = ERROR_MESSAGE();
    --==========================================================================
    -- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
    --==========================================================================
    EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
    @SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
    @VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
    @CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
    @DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
    @InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
    @FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
    @OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
    @Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
    @ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
    END CATCH
    --==========================================================================
    -- INSERT INTO DMS_INVENTORY_VEHICLE (CHILD TABLE)
    --==========================================================================
    BEGIN TRY
    INSERT INTO [dbo].[DMS_INVENTORY_VEHICLE]
    DMSInventoryID,
    InteriorColorCode,
    ExteriorColorCode,
    Air,
    ModelDesc,
    VehicleType,
    VehicleVIN,
    VehicleYear,
    VehicleMake,
    VehicleModel,
    VehicleModelCode,
    VehicleTrim,
    VehicleSubTrimLevel,
    Classification,
    TypeCode,
    VehicleMileage,
    FtpDate,
    EngineCylinderCount
    VALUES (
    @InventoryID,
    @InteriorColorCode,
    @ExteriorColorCode,
    @Air,
    @ModelDesc,
    @VehicleType,
    @VehicleVIN,
    @VehicleYear,
    @VehicleMake,
    @VehicleModel,
    @VehicleModelCode,
    @VehicleTrim,
    @VehicleSubTrimLevel,
    @Classification,
    @TypeCode,
    @VehicleMileage,
    @FtpDate,
    @EngineCylinderCount
    END TRY
    BEGIN CATCH
    SELECT
    @errornumber = ERROR_NUMBER(),
    @errorseverity = ERROR_SEVERITY(),
    @errortable = 'DMS_INVENTORY_VEHICLE',
    @errorstate = ERROR_STATE(),
    @errorprocedure = ERROR_PROCEDURE(),
    @errorline = ERROR_LINE(),
    @errormessage = ERROR_MESSAGE();
    --==========================================================================
    -- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
    --==========================================================================
    EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
    @SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
    @VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
    @CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
    @DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
    @InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
    @FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
    @OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
    @Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
    @ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
    END CATCH
    --==========================================================================
    -- MOVE CURSUR TO NEXT RECORD
    --==========================================================================
    FETCH NEXT FROM Inventory_Cursor
    INTO @FileType ,
    @ACDealerID ,
    @ClientDealerID ,
    @DMSType ,
    @StockNumber ,
    @InventoryDate ,
    @StockType ,
    @DMSStatus ,
    @InvoicePrice ,
    @CostPack ,
    @SalesCost ,
    @HoldbackAmount ,
    @ListPrice ,
    @MSRP ,
    @LotLocation ,
    @TagLine ,
    @Certification ,
    @CertificationNumber ,
    @VehicleVIN ,
    @VehicleYear ,
    @VehicleMake ,
    @VehicleModel ,
    @VehicleModelCode ,
    @VehicleTrim ,
    @VehicleSubTrimLevel ,
    @Classification ,
    @TypeCode ,
    @VehicleMileage ,
    @EngineCylinderCount ,
    @TransmissionType ,
    @VehicleExteriorColor ,
    @VehicleInteriorColor ,
    @CreatedDate ,
    @LastModifiedDate ,
    @ModifiedFlag ,
    @InteriorColorCode ,
    @ExteriorColorCode ,
    @PackageCode ,
    @CodedCost ,
    @Air ,
    @OrderType ,
    @AgeDays ,
    @OutstandingRO ,
    @DlrAccessoryRetail ,
    @DlrAccessoryCost ,
    @DlrAccessoryDesc ,
    @ModelDesc ,
    @Memo1 ,
    @Memo2 ,
    @Weight ,
    @FloorPlan ,
    @Purchaser ,
    @PurchasedFrom ,
    @InternetPrice ,
    @InventoryAcctDollar ,
    @VehicleType ,
    @DealerAccessoryCode ,
    @AllInventoryAcctDollar ,
    @BestPrice ,
    @InStock ,
    @AccountingMake ,
    @GasDiesel ,
    @BookValue ,
    @FactoryAccessoryDescription ,
    @TotalReturn ,
    @TotalCost ,
    @SS ,
    @VehicleBody ,
    @StandardEquipment ,
    @Account ,
    @CalculatedPrice ,
    @OriginalCost ,
    @AccessoryCore ,
    @OtherDollar ,
    @PrimaryBookValue ,
    @AmountDue ,
    @LicenseFee ,
    @ICompany ,
    @InvenAcct ,
    @Field23 ,
    @Field24 ,
    @SalesCode ,
    @BaseRetail ,
    @BaseInvAmt ,
    @CommPrice ,
    @Price1 ,
    @Price2 ,
    @StickerPrice ,
    @TotInvAmt ,
    @OptRetail ,
    @OptInvAmt ,
    @OptCost ,
    @Options1 ,
    @Category ,
    @Description ,
    @Engine ,
    @ModelType ,
    @FTCode ,
    @Wholesale ,
    @Retail ,
    @Draft ,
    @flatfile_createddate,
    @FtpDate;
    END
    CLOSE Inventory_Cursor;
    DEALLOCATE Inventory_Cursor;
    SET ANSI_PADDING OFF
    END
    Arunraj Kumar

    Thank you.
    And another question if the data is already there in the child table if i try to load alone it must delete the old data in the child tablee and need to get load the new data and 
    How to do this ?
    Arunraj Kumar
    You can do that with an IF EXISTS condition
    IF EXISTS (SELECT 1
    FROM YourChildTable c
    INNER JOIn @temptable t
    ON c.Bkey1 = t.Bkey1
    AND c.Bkey2 = t.Bkey2
    DELETE t
    FROM YourChildTable c
    INNER JOIn @temptable t
    ON c.Bkey1 = t.Bkey1
    AND c.Bkey2 = t.Bkey2
    INSERT INTO YourChildTable
    where Bkey1,Bkey2 etc forms the business key of the table
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • My hard drive died last week, and I needed to install a new one.  Previously, I was able to save a .doc with text and inserted photo to .pdf and then to .jpg.  Now I can get the .pdf but can't determine what to do to convert to .jpg.  Does anyone know ?

    My hard drive died last week, and I needed to install a new one.  Previously, I was able to save a .doc with text and inserted photo to .pdf and then to .jpg.  Now I can get the .pdf but can't determine what to do to convert to .jpg.  Does anyone know ?

    Rather than do that, which means starting over from scratch, losing all your edits, organisation and so on, why not simply use iPhoto Library Manager to revert the Library to the older version? Easier, less destructive.
    The instructions on that are here
    If you really want to start over: you can access the Originals folder simply by going to your Pictures Folder and finding the iPhoto Library there. Right (or Control-) Click on the icon and select 'Show Package Contents'. A finder window will open with the Library exposed.

  • ESB performance issue: takes too long to select and insert records in DBs

    Hi,
    I have an ESB service which has to select data from seven different tables(using join operations) of one database and insert it into a single table of another database.
    It takes unduly long time to do this operation.
    For ex: it takes over 2 hours to select and insert 3000 records.
    When ran the same query to select the records from the tables using SQL developer, it took only 23 seconds.
    Do I need to change any configuration settings in the enterprise manager or someother place to increase the performance. Someone please advice.
    I am using Oracle SOA Suite 10.1.3.4
    Thanks,
    RV

    Hi,
    I have an ESB service which has to select data from seven different tables(using join operations) of one database and insert it into a single table of another database.
    It takes unduly long time to do this operation.
    For ex: it takes over 2 hours to select and insert 3000 records.
    When ran the same query to select the records from the tables using SQL developer, it took only 23 seconds.
    Do I need to change any configuration settings in the enterprise manager or someother place to increase the performance. Someone please advice.
    I am using Oracle SOA Suite 10.1.3.4
    Thanks,
    RV

  • Problem with overwrite and insert keyboard commands

    I'm a new user, switching from FCP. I edited one project successfully with no trouble a couple of weeks ago. Now I'm in a second project and having a weird difficulty. Using a pretty new Mac 8 core tower.
    The insert and overlay keyboard commands (comma and period keys) don't work. They still work in the old project but not this one. If I start a new sequence and copy my timeline to it, the commands will work for awhile but ONLY with video, not with the audio tracks. Drag and drop works fine but that really slows me down.
    The clips I'm using are all the same format (H.264 from Canon 5DII and some still photos) as the first project. Only difference in this project is lots of chroma keying and some resizing of background still photos. Nothing unrendered.
    I started a new project just now and imported the problem project into it, started a new sequence, copied old sequence, and I get the same problem. I can drop in video with a keyboard command but not audio. Earlier it was not even doing video. Yesterday when I'd start a new sequence and do the same thing, it would give me video on the keyboard command but then eventually that would stop and it would do nothing. At one point the cursor would move over the width of the clip, as if it had been dropped into the timeline, but then that stopped as well.
    I've trashed preferences and that didn't work. I did that according to a procedure I found online. It said open up PP while holding down the Shift and Option keys. I did that twice. Nothing.
    To summarize: Keyboard commands for overwrite and insert edit do not work in this project but do in an older project.
    Any ideas?
    Thanks.
    Bill Pryor
    [email protected]

    Well, thanks to an email from another person who was having the same problem, it's all solved not.
    Operator error. Dang. Who knew--in FCP you select a track by clicking on the V or A buttons to the far left. In Premiere Pro you have to make sure BOTH the far left button and the one to the right that says Video 1, Audio 1, etc. are also clicked. They BOTH have to be light gray. In my first project, everything was properly activated but in the next project apparently they were not and that carried over to succeeding projects (even though I didn't change anything...at least consciously).
    So all as well now. No glitch, no bug. Just good ol' fashioned operator error. I will wear the dunce hat today.

  • Use of the "updlock" hint with update and insert statements

    I have inherited some stored procedures and am trying to figure out why the developers decided to use the "updlock" hint on many of the update and insert statements. I have looked around everywhere and have found only one explanation of why "update...with
    (updlock)" can be useful, namely when a table has no clustered index:
    http://www.sqlnotes.info/2012/10/10/update-with-updlock/ I have found nothing yet that mentions why "insert into...with (updlock)" might be used. I understand why the hint
    might be useful on select statements in some cases, but if all of the tables have clustered indexes, is there any good reason to use it on update and insert statements?
    Thanks,
    Ron
    Ron Rice

    This form of deadlock error can occur on a table which has a clustered index.
    If you are doing updates on a table which has a clustered index and that table also has a nonclustered index and the nonclustered index is used to find the row to update you can see this type of deadlock.  For example create a table with a clustered
    primary key index and a nonclustered index by running
    Create Table Foo(PK int primary key identity, OtherKey varchar(10), OtherData int);
    go
    Insert Foo Default Values;
    go 10000
    Update Foo Set OtherKey = 'C' + Cast(PK As varchar(10))
    Create Unique Index FooIdx On Foo(OtherKey);
    That creates a table with 10000 rows, a clustered index and a nonclustered index.  Then run
    Begin Transaction
    Update Foo Set OtherData = 1 Where OtherKey = 'C5'
    That will use the FooIdx index to find the row that needs to be updated.  It will get a U lock on the index row in the FooIdx index, then an X lock on the row in the clustered index, update that row, then free the U lock on FooIdx, but keep the X lock
    on the row in the clustered index.  (There is other locking going on, but to simplify things, I'm only showing the locks that lead to the deadlock).
    Then in another window, run
    Begin Transaction
    Update Foo Set OtherData = 2 Where OtherKey = 'C5'
    This will get a U lock on the index row in the FooIdx index, then try to get an X lock on the row in the clustered index.  But that row is already exclusively locked, so this second window will wait holding a U lock on FooIdx row and is waiting for
    an X lock on the clustered index row.
    Now go back to the first window and run
    Update Foo Set OtherData = 3 Where OtherKey = 'C5'
    This will once again try to get the U lock on the FooIdx row, but it is blocked by the U lock the second window holds.  Of course the second window is blocked by the X lock on the clustered index row and you have a deadlock.
    All that said, I certainly do not routinely code my updates with UPDLOCK.  I try to design databases and write code so that deadlocks will be rare without holding excessive locks.  The more locks you hold and the longer you hold them, the more
    blocking you will get and the slower your system will run.  So I write code that if a deadlock exception occurs, it is properly handled.  Then if too many deadlocks occur, that is the time to go back to the code to see what changes are needed to
    decrease the number of deadlocks (one way to do that may be to get locks earlier and/or hold them longer. 
    But I wouldn't worry much about this form of deadlock.  It is, in my experience, vary rare.  I don't recall ever seeing it in a production environment.
    Tom

  • Change the value of column from select and insert different

    Hi All,
    I have written a procedure where i am selecting values from some table and inserting in a new table. The code is below
    If you see the line 54 in code, you will find the combined_bu_code is is coming from one procedure and the value of BU is stored in prod.SEM_BACKLOG_LOG table. I have to check, if the combined_bu_code is coming as PWR then insert as POWER in BACKLOG_OTD_NEW table not as PWR.
    Looking for a help on this. Thanks in advance
    Regards
    Edited by: User_Apex on Jun 23, 2011 3:03 AM
    Edited by: User_Apex on Jun 23, 2011 3:53 AM

    Hi Martin,
    sorry i wrote wrong at that time
    If you see my code you will find alias of prod.SEM_BACKLOG_LOG is 'a' not 'b' and BU is coming from 'a'
    I just want a if startement to be written in this column "SMTC_OTD_CHART.get_combined_bu_code (a.BU)COMBINED_BU_CODE" that if the a.BU is PWR insert as POWER in the BACKLOG_OTD_NEW table
    Regards
    Edited by: User_Apex on Jun 23, 2011 3:02 AM

  • Select and insert statments

    I am running PHP 4.3.9 and Orace 10g.<p>
    I have a simple select query to check for the existence of a unique row.<p>
     $idCheck="select * from fuel.trip_segment where id='$id'";     <br>     
          $statementa= OCIParse($c, $idCheck);<br>
          OCIExecute($statementa);<br>
          $rows = OCIFetchStatement($statementa, $results);<br>
      echo "row: ".$rows ;<p>
    The output should be "1" when a row is found. But for some reason it always returns "0" regardless. If i execute this query ($idCheck) with out database/sql interface software, it will return the row of the given id. <p>
    Problem 2<br>
    I also have an insert query which will work if put directly into the database/sql interface software, but will not work when executed in PHP.<p>
     $upload="insert into fuel.trip_segment (id, unitno, downloaddate, drive_time, distance, fuel, idle_time, idle_fuel, idle_percent, load_factor, ave_speed, ave_Dspeed, max_speed, max_rpm, start_time, end_time, start_odo, end_odo)<br>
     values ('$id', '$unit', to_date('$dateFormatted', 'dd-mon-yyyy hh:mi AM'), '$drive_time', '$distance', '$fuel', '$idle_time', '$idle_fuel', '$idle_percent', '$load_factor', '$ave_speed',     '$ave_Dspeed', max_speed', '$max_rpm', '$start_time', '$end_time', '$start_odo', '$end_odo')";<p>
     $statementb= OCIParse($c, $upload);<p>
     OCIExecute($statmentb);<p>
    The information is not being inserted at all.<p>
    Any help would be great.<p>
    Disclaimer: Oracle novice
    Message was edited by:
    tckephart

    Hello!
    Problem 1:
    Try to use select id and not to use select *
    then try to use a while maybe the result is more than one row
    $idCheck="select id from fuel.trip_segment where id='$id'";
    $statementa= OCIParse($c, $idCheck);
    OCIExecute($statementa);
    while(OCIFetchInto($statementa, $results))
    echo "id: ".$results[0];
    } //end while
    Problem 2
    Maybe you have wrong the query insert, max_speed need $.
    but anyway try this:
    $upload="insert into fuel.trip_segment
    values
    '".$id."',
    '".$unit."',
    to_date('".$dateFormatted."', 'dd-mon-yyyy hh:mi AM'),
    '".$drive_time."',
    '".$distance."',
    '".$fuel."',
    '".$idle_time."',
    '".$idle_fuel."',
    '".$idle_percent."',
    '".$load_factor."',
    '".$ave_speed."',
    '".$ave_Dspeed."',
    '".$max_speed.'",
    '".$max_rpm."',
    '".$start_time."',
    '".$end_time."',
    '".$start_odo."',
    '".$end_odo."'
    $statementb= OCIParse($c, $upload);
    OCIExecute($statmentb);
    $record_insert = @OCIRowCount($statmentb);
    This count how many record you have inserted.
    Have a nice work
    Angelo

  • Toplink Select and Insert Order

    Hi,
    We have a situation where we have to insert a row into database with a sequence primary key and do a select on the same record with the newly generated sequence number. (Here sequence is generated via TopLink's SQLCall class, but not through work bench at runtime.) When we try this with TopLink it was trying to select first with the new sequnce number and then insert. So we are getting a NULL back. Is there a way to force toplink to create first and then do selects? Please let me know ASAP.
    Thanks..

    I am not sure why you want to do a select of an object you just committed. When you register an object in a Unit Of Work, you get an object back from the function of type Object. Caste that object to the "real" type. After you make the commit call, toplink will grab the next sequence and put the value into the object that was returned from the register function.
    Anyway, if that does not work for you. Create your object in a Unit of Work, and then commit that. In a Client Session object, do your query function. That will force your changes to happen prior to the query. Hope that helps.

  • I have a requirement with select and text boxes. JSP / JDBC

    I have a Combo Box which iswritten by a JSP by connecting to DB!
    When i click on a <option> corresponding the other two text boxes must be loaded with data!
    if i have list of EmpID in <select>, in one text box i should get his CITY and other Occupation !
    What i thought is .... getting all the data from database. select empid from emp and write a combo and select city,occupation from emp, intp ARRAYLISTs!
    function updatData(){
    var index=document.projalloc.associateid.selectedIndex;
    }if i onSelect=updateData(), (i will get index of empid,as it is a combobox) using which i have to retrieve the values of city and occupation !!
    BUT HOW !
    I am gettin the index of empid but how to get the data into textbox !!!!

    well there are many ways of doing this.
    1).Render all the data corresponding to each employee at a time.By making a javascript arrays and try to get back the data from there.
    2).Save the ArrayList of DTO beans in the scope of session.Use AJAX call a CGI(Servlet/JSP action) fetch the values from the session render the response as XML now parse the XML data using javascript DOM and then update the consecutive textboxes.
    Just as an example checkout my answer in the below post.It was an example given for a dependent drop downs.however, we can definately use the same concept to update textboxes too.
    http://forum.java.sun.com/thread.jspa?threadID=5209661&messageID=9844137#9844137
    Hope that might help :)
    REGARDS,
    RaHuL

  • Where clause with XMLExists and join on another table

    Hi,
    We have table like:
    drop table xml_tbl;
    create table xml_tbl (
    xml_msg_id integer,
    xml_msg_text xmltype
    insert into xml_tbl values
    (1, '<main><id>1</id></main>') ;
    insert into xml_tbl values --(xml_msg_id,xml_msg_text)
    (1, '<main><id>2</id></main>') ;
    Another table like:
    create Table Table1
    ( id1 int);
    Insert into Table1 values(2);
    Insert into Table1 values(3);
    We need to have a view on top of the table xml_tbl where /main/id should have only those values which are in id1 column of table Table1.
    Something like
    CREATE OR REPLACE VIEW V_xml_tbl
    xml_msg_text
    AS
    SELECT T.xml_msg_text
    FROM xml_tbl T
    WHERE XMLEXISTS (
    'declare namespace Namesp1 ="Abc:Set";
    let $Results as xs:boolean := fn:exists($p/main/id in (Select id1 from Table1)) --Now here I know I can't do Select id1 from
    Table1*
    return if ($Results ) then true() else ()'
    PASSING T.xml_msg_text AS "p");
    Actually in the real scenario Table1 will have many IDs and xml_tbl has many XML files..
    So I am stuck on how to do it. Please help.
    Thanks..
    Edited by: user8941550 on Nov 20, 2012 7:19 PM

    One of these two :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where exists (
      4    select null
      5    from table1 t1
      6    where t1.id1 = xmlcast(
      7                     xmlquery('/main/id' passing t.xml_msg_text returning content)
      8                     as integer
      9                   )
    10  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3     , xmltable('/main' passing t.xml_msg_text
      4         columns id integer path 'id'
      5       ) x
      6  where exists (
      7    select null
      8    from table1 t1
      9    where t1.id1 = x.id
    10  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    And a third one, using XMLExists :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where xmlexists (
      4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=$d/main/id]'
      5    passing t.xml_msg_text as "d"
      6  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    Execution Plan
    Plan hash value: 3633580934
    | Id  | Operation           | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |         |     2 |   116 |     8   (0)| 00:00:01 |
    |*  1 |  FILTER             |         |       |       |            |          |
    |   2 |   TABLE ACCESS FULL | XML_TBL |     2 |   116 |     3   (0)| 00:00:01 |
    |   3 |   NESTED LOOPS      |         |     1 |     5 |     5   (0)| 00:00:01 |
    |   4 |    TABLE ACCESS FULL| TABLE1  |     2 |     6 |     3   (0)| 00:00:01 |
    |*  5 |    XPATH EVALUATION |         |       |       |            |          |
    Predicate Information (identified by operation id):
       1 - filter( EXISTS (SELECT 0 FROM "DEV"."TABLE1"
                  "SYS_ORAVW_2",XPATHTABLE('/main/id' PASSING :B1 COLUMNS "C_00$" XMLTYPE
                  PATH '.', "C_01$" XQEXVAL CHAR PATH '.')  "P" WHERE
                  TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$")))
       5 - filter(TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$"))The plan is similar to that of the second query above (XMLTable/EXISTS).
    Still using XMLExists, a plan similar to the first query (EXISTS/XMLCast/XMLQuery) can be achieved by casting id to an integer datatype :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where xmlexists (
      4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=xs:int($d/main/id)]'
      5    passing t.xml_msg_text as "d"
      6  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    Execution Plan
    Plan hash value: 1149640166
    | Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |         |     1 |    61 |     7  (15)| 00:00:01 |
    |*  1 |  HASH JOIN SEMI    |         |     1 |    61 |     7  (15)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| XML_TBL |     2 |   116 |     3   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL| TABLE1  |     2 |     6 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("ID1"=SYS_XQ_ATOMCNVCHK(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQ
                  EXVAL(SYS_XQEXTRACT(SYS_MAKEXML(0,"T"."SYS_NC00003$"),'/main/id'),1,50,3
                  3792,8192),50,1,0)),2,37))
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)Check each one on your real scenario to see which show best performance.
    (I would tend to say the ones involving streaming evaluation)
    Edited by: odie_63 on 5 nov. 2012 12:24
    Edited by: odie_63 on 5 nov. 2012 12:38

  • "Invalid Column" on multiple where clauses with subqueries and cfqueryparam

    I'm seeing a behavior in the coldfusion cfquery that I'd like to find an exmplanation for .  I've got a query that does a subquery in the select portion and if I have multiple where lines, I get an "invalid column name" message for my second where clause, but only when I'm using cfqueryparam
    For example on the following I get "Invalid column name 'position_id'"
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND     position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND     staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">
    If I change the order of my where clause so staff_id is first, then it tells me "department_id" is an invalid column.
    If I only have one where clause, it works.  (i.e. WHERE position_id = <cfqueryparam value="#arguments.posid#" cfsqltype="cf_sql_integer">).
    If I remove the where clause from my subquery (WHERE     item_id = department_staff_tbl.staff_id) it works.
    It also works if I remove the cfqueryparam from my where clause so that my query looks like this:
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = #arguments.deptid#
    AND     position_id   = #arguments.posid#
    AND     staff_id      = #arguments.staffid#
    Any thoughts?

    I see two tables. So can the server. So, use qualified column-names.
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmarked_items_tbl.bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    bookmarked_items_tbl.item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_staff_tbl.department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">

  • I have problem with selecting and Copying is some of the applications

    I am using  blackberry passport.  I would like to know how to select text and  copy text from pages of YouVersion Bible.  When I was using blackberry bold 9790 it was simple but now I am using blackbery passport I have failed to know how to perform that task.

    While the content of many books, including the Bible have no copyright, the effort that the developer has gone through to be able to present it in an app could be. Not saying it is, I have encountered apps where I think the developer in advertently turned off features such as resize or copy. 
    Paul
    Torch 9810; PlayBook 64g; iPad1 64g; iPad2 64g; iPhone6 64g Passport
    Provider Bell (tablets all WiFi)

  • Help with CDOSYS,  and insert into DB

    I'm using Dreamweaver 8, SQL Server 2000, Windows 2003
    Server.
    This is what so far I was able to achieve. Have a form that
    inserts records into the database, a confirmation page of the
    insert, and a simple CDOSYS message to notify me that a record have
    been inserted.
    Basically on the Form action I call the insert page, wich in
    turn redirects to the confirmation page that virtually includes the
    file for the email.
    What I would like to achieve, is the email that I've setup,
    to include in the body of the message all the fields that have been
    inserted, instead of a simple message that a record have been
    inserted. Below is the simple code that I´m using for the
    email. Can someone explain what do I have to modify or add and
    where?
    Thanks.
    Manuel
    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="New Contact"
    myMail.From=""
    myMail.To="myMail@myProvider"
    myMail.Bcc="someonelse'sMail@hisProvider"
    myMail.Cc=""
    myMail.TextBody="There´s a new contact"
    myMail.Send
    set myMail=nothing
    %>

    Thanks if you read my first post, but I've figured it out.
    Thanks anyway
    Manuel

  • Select * and Insert question

    I have my ResultSet and Query to get the data form an Oracle database. Would I use the same rs for an executeUpdate statement? Or how would I go about doing that?
    Basically I'm querying the database, getting the resultset, processing the data around, and then inputing the processed data as a new row in the same database. I have the first part down pat, but I'm a little hazy on the 2nd part, the INSERT INTO bit.
    Any help would be greatly appreciated.

    This is my code:
    public class LimitCheck extends HttpServlet
         private static int UsageAmount = 0;
         private static double TotalPurchased = 0.00;
         private static String Maybe = "Blurbo!";
         private static String Third = "Snafu!";
         private static int CustID = 0;
         private static void loadOracleJDBCDriver () {
    System.out.println ("Loading database driver...");
    try {
         DriverManager.registerDriver ( new oracle.jdbc.driver.OracleDriver());
    System.out.println ("Database driver loaded...");
    catch (SQLException e) {
    System.err.println (e.getMessage ());
    System.exit (1); // Driver error
    private static Connection getConnected () {
    System.out.println ("LC getting connection...");
    try {
    String jdbc_url = "jdbc:oracle:thin:@localhost:1521:oracle";
    Connection conn = DriverManager.getConnection (jdbc_url, "scott", "tiger");
    System.out.println ("LC connection created ...");
    return conn;
    catch (SQLException e) {
    System.err.println (e.getMessage () ) ;
    System.exit (1); // Driver failure
    return null;     // never happen
         private static Statement makeStatement (Connection conn) {
    try {
    System.out.println ("LC Making a Statement...");
    Statement stmt = conn.createStatement ();
    System.out.println ("LC Statement created...");
    return stmt;
    catch (SQLException e) {
    System.err.println (e.getMessage () ) ;
    System.exit (2); // Driver failure
    return null;     // never happen
    private static ResultSet openResultSet (Statement stmt, String query, String update) {
    try {
    System.out.println ("LC Creating resultSet...");
    ResultSet rs = stmt.executeQuery (query);
                   stmt.executeUpdate(update);
    System.out.println ("LC Resultset created...");
    return rs;
    catch (SQLException e) {
    System.err.println (e.getMessage () ) ;
    System.exit (3); // ResultSet error
    return null;     // never happen
         private static void processResultSet (ServletOutputStream out, ResultSet rs)
    try {
    System.out.println ("\n\n+++++ Processing ResultSet for LimitCheck+++++\n");
                   while (rs.next() )
                        CustID = (rs.getInt(2));
                        System.out.println(rs.getInt(2));
                        UsageAmount = UsageAmount + 1;
                        System.out.println(rs.getString(5));
                        System.out.println(rs.getDouble(4));
                        TotalPurchased = TotalPurchased + rs.getDouble(4);
    System.out.println ("\n\n+++++ ResultSet Processed for LimitCheck+++++\n");
              catch (SQLException e) {
    System.err.println (e.getMessage () ) ;
    System.exit (5); // Processing error
    private static void closeThingsDown (ResultSet rs, Statement stmt, Connection conn) {
    try {
    System.out.println ("LC Closing Things Down...");
    rs.close();
    System.out.println ("LC ResultSet Closed...");
    stmt.close ();
    System.out.println ("LC Statement closed...");
    conn.close();
    System.out.println ("LC Connection closed...");
    catch (SQLException e) {
    System.err.println (e.getMessage () ) ;
    System.exit (5); // Closure failure
    Then I have my doGet, and in it I have:
    ResultSet rs = openResultSet (stmt, query, update);
    processResultSet (out, rs);               
    closeThingsDown (rs, stmt, conn);
    When I javac it, I don't get any errors, but when I try to run it, my server craps out and the page can't be displayed. The problem is in my openResultset somewhere, but I can't see where.
    I have a sneaking suspicion that the update is supposed to come after I processResultSet, but it complains if I move the update to after it.

Maybe you are looking for

  • Why do i have a lot of "other" storage?

    I just restored my iPod touch 5. It was having problems syncing doubles of all my music. I restored my iPod and re synced all my music. All my music synced properly but now I have over 11 GB of "other" storage. How do i get rid of the other storage.

  • How to return more than one record through OUT parameter in procedure

    Hi, I want to create a procedure which accepts one input and returns more than one record as output. example: Input = DeptNo Output= Empno,ename,sal,comm,job Scenario: There can be more than one employee in department we pass as the IN parameter. OUT

  • How to Transper data Model Node to Vallue Node

    Hi Friends I am getting problem in Create the Check box in Table I am getting model node from ECC System(Zmmoa_Pending_Getlist_Input) This is path for attributes avaliable Zmmoa_Pending_Getlist_Input-Output-outtab  Under outtab  all attributes avai

  • I can't install mac os x 10.2.1 from mac os x 10.1.5 installed.

    I can install mac os x 10.1 perfectly but when I try install mac os x 10.2.1 the the mouse pointer freeze in the upper left corner and I can't click the "continue" button of the installer. I tried with a USB mouse but I can't type after install, the

  • MacBookPro 5,2 17", CPU underperforming

    My MacBookPro, a Unibody 17" recently slowed down so much it was unusable. I upgraded to OS X Lion and thought that would help with the problem but it didn't. I've done everything I could find, repairing permissions and verifying disc, cleaning up an