Table used in procedure
is it possible to know the table A used in Some procedure
using the dependencies views you can find out the views, procedures and packages that use a table. The only limitation is that you can't see the procedures within a package that use the table, it will just be listed under the package itself. Not sure if this limitation has changed in 11g
Similar Messages
-
Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]I also Tried to Use This
But How can i Use SQLLDR Command In Stored Procedure.
Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure. -
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
How to insert into a table using a procedure in a trigger
I have following trigger and based on the some condition, it should inser a row in to a table using the procedure:
CREATE OR REPLACE TRIGGER RSSC.RR_SERV_ADD_ON_REQ_bu before update on RSSC.RR_SERV_ADD_ON_REQ
for each row
DECLARE
lr_appr_trans_hdr APPR_TRANS_HDR%ROWTYPE;
-- Inserting a row into APPR_TRANS_HDR table
lr_appr_trans_hdr.apth_ref_system := 'RSAO';
lr_appr_trans_hdr.apth_xref_col_name := 'RSAO_ADD_ON_REQ_NUM';
lr_appr_trans_hdr.apth_xref_id := :NEW.RSAO_ADD_ON_REQ_NUM;
lr_appr_trans_hdr.apth_trans_srce := 'I';
lr_appr_trans_hdr.apth_balance_amt := :NEW.RSAO_TOT_AMT;
lr_appr_trans_hdr.apth_is_finance_adj := 'N';
SPI_APPR_TRANS_HDR (
lr_appr_trans_hdr.apth_id
,lr_appr_trans_hdr.apth_create_dt
,lr_appr_trans_hdr.apth_create_user_id
,lr_appr_trans_hdr.apth_update_dt
,lr_appr_trans_hdr.apth_update_user_id
,lr_appr_trans_hdr.apth_ref_system
,lr_appr_trans_hdr.apth_xref_col_name
,lr_appr_trans_hdr.apth_xref_id
,lr_appr_trans_hdr.apth_trans_srce
,lr_appr_trans_hdr.apth_udc_name_cd
,lr_appr_trans_hdr.apth_udc_acct_num
,lr_appr_trans_hdr.apth_level1_apprvl_stat
,lr_appr_trans_hdr.apth_level1_apprvl_dt
,lr_appr_trans_hdr.apth_level1_apprvr_id
,lr_appr_trans_hdr.apth_level2_apprvl_stat
,lr_appr_trans_hdr.apth_level2_apprvl_dt
,lr_appr_trans_hdr.apth_level2_apprvr_id
,lr_appr_trans_hdr.apth_received_dt
,lr_appr_trans_hdr.apth_balance_amt
,lr_appr_trans_hdr.apth_cust_name
,lr_appr_trans_hdr.apth_sent_dt
,lr_appr_trans_hdr.apth_wbs_element
,lr_appr_trans_hdr.apth_gl_acct_num
,lr_appr_trans_hdr.apth_is_finance_adj );
When I use the above, it is saying wrong number of argument or type.
When I use the following instead, I am getting :NEW.APTH_ID must be declared.
SPI_APPR_TRANS_HDR('APPR_TRANS_HDR',to_char(:NEW.APTH_ID),'APTH_ID',:OLD.APTH_ID,:NEW.APTH_ID);
How can use the procedure in a trigger.
Following is the table structure:
Column Name Data Type Column Comments
APTH_ID NUMBER(16) Computed unique identified per large table standards (yyyymmddnnnnnnnn)
APTH_CREATE_DT DATE sysdate
APTH_CREATE_USER_ID VARCHAR2(65) ‘conv’
APTH_UPDATE_DT DATE sysdate
APTH_UPDATE_USER_ID VARCHAR2(65) ‘conv’
APTH_REF_SYSTEM VARCHAR2(4) ‘RSAO’
CPA_PREM_NUM NUMBER(13,0) NULL
RSR_REQ_NUM NUMBER(16) NULL
RSAO_ADD_ON_REQ_NUM NUMBER(16) rsao_add_on_req_num
APTH_TRANS_SRCE VARCHAR2(2) ‘I’
APTH_LDC_NAME_CD VARCHAR2(4) NULL
APTH_LDC_ACCT_NUM VARCHAR2(25) NULL
APTH_LEVEL1_APPROVAL_STAT VARCHAR2(1) NULL
APTH_LEVEL1_APPROVAL_DT DATE NULL.
APTH_LEVEL1_APPROVAL_ID VARCHAR2(30) NULL
APTH_LEVEL2_APPROVAL_STAT VARCHAR2(1) NULL
APTH_LEVEL2_APPROVAL_DT DATE NULL.
APTH_LEVEL2_APPROVAL_ID VARCHAR2(30) NULL
APTH_RECEIVED_DT DATE NULL
APTH_BALANCE_AMT NUMBER(11,2) RR_SERV_ADD_ON_REQ.rsao_tot_amt – amount previously extracted to sap
APTH_CUST_NAME VARCHAR2(65) NULL
APTH_SENT_DT DATE NULL
APTH_WBS_ELEMENT VARCHAR2(25) NULL
APTH_GL_ACCT_NUM VARCHAR2(15) NULL
APTH_IS_FINANC_ADJ VARCHAR2(1) ‘N’
Edited by: user652807 on Sep 3, 2008 4:51 PMIt appears you're missing the format mask in the TO_CHAR, ...
TO_CHAR(:new.apth,'YYYYMMHR24MISS')
The full code would help a bit more. -
How to read I$ table using ODI procedure
Hi
Can any one help me how to drop a I$ table from out sie of interface.
I have tried below approches but no luck
I have created ODI procedure with technology oracle and target logical schema (I$ tables are creating on target DB) with and with out begin and end;
Approch 1:
Given below code in ODi procedure
drop table <%=odiRef.getTable("L", "INT_NAME", "W")%> <% if (new Integer(odiRef.getOption( "COMPATIBLE" )).intValue() >= 10 ) { out.print( "purge" ); }; %>
Approch 2:
drop table I$_<%=odiRef.getTable("L", "TARG_NAME", "A") %>;
Approch 3:
drop table <%=odiRef.getTable("L", "INT_NAME", "W")%> (but it is fetching target dtabase schema anme not I$ table)
Please help me any other alternative way to drop a I$ table, more over this code should be unique for all interface
Regards,
PhanikanthThanks bhabani,
Actaul my requirement is some time my scenario is stoping due some issue at Merge Rows Step (I am using IKM Oracle Incremental Update(Merge) KM) when the next iteration starts it is thwoing and error at create flow table I$ step and error is table name is already exists, so i am doing is if the interface went failed I am storing those information in one table using ODI procedure (INF--ko-->ODI procedure) in same ODI procedure I want to call a I$ table to drop.
Can you please provide the steps so it will very useful for me using Java variable.
I have gievn a step as below on create I$ table step (after create I$ statement)
<@ java.lang.String Idollertable = <%=odiRef.getTable("L", "INT_NAME", "W")%> ; @>
I am calling Idollertable variable in ODI procedure which is ko>* of INF as <@=Idollertable@>
Note: I have followed below approch
ODI Procedure Code:
drop table <@=Idollertable@>; --> *2nd approch*
begin
insert into ODI_EXECUTION_ERROR_DETAILS
(SESSION_NO,
SCENARIO_NAME,
CONTEXT_NAME,
ERR_MESSAGE,
INSERT_COUNT,
ERROR_COUNT)
values
<%=snpRef.getSession("SESS_NO")%>,
'<%=odiRef.getPrevStepLog("STEP_NAME")%>',
'<%=odiRef.getContext( "CTX_NAME" )%>',
'<%=odiRef.getPrevStepLog("MESSAGE")%>',
'<%=odiRef.getPrevStepLog("INSERT_COUNT")%>',
'<%=odiRef.getPrevStepLog("ERROR_COUNT")%>'
commit;
drop table <@=Idollertable@>; --> * first approch *
end;
Please help me
Regards,
Phanikanth
Edited by: Phanikanth on Mar 3, 2013 9:52 PM
Edited by: Phanikanth on Mar 3, 2013 9:52 PM -
Line 390 Under the (Insert into SALES_TRADEIN Table)
I need to insert (TradeIn_1_VIN) Values If there is no values in (TradeIn_1_VIN) then i have to insert (TradeIn_2_VIN) values to the (SALES_TRADEIN) Table.
After i run then below script only (TradeIn_2_VIN) values are get inserted in the table. (TradeIn_1_VIN) are not getting loaded in to the table.
I think there is the problem from Line No (404 to 414) Please help me change those particular lines to insert (TradeIn_1_VIN) Values also.If there is no details then (TradeIn_2_VIN) need to be inserted.
-- =============================================
-- Stored Procedure for Flatfile_Sales
-- =============================================
USE [IconicMarketing]
---==========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),
@myerror
varchar(500),
@SalesID
int,
@errornumber int,
@errorseverity varchar(500),
@errorstate int,
@errorprocedure varchar(500),
@errorline varchar(50),
@errormessage varchar(1000);
DECLARE Sales_Cursor CURSOR FOR
SELECT * from FLATFILE_SALES;
OPEN Sales_Cursor;
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @VehicleVIN ;
--===============================================================================
-- ****************** insert into Sales Table ***********
BEGIN TRY
INSERT INTO Sales
IconicDealerID,
DealNumber,
CustomerNumber,
DMSType,
ContractDate
VALUES (@ClientDealerID,@DealNumber,@CustomerNumber,@DMSType,@ContractDate);
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER()
,@errorseverity = ERROR_SEVERITY()
,@errorstate = ERROR_STATE()
,@errorprocedure = ERROR_PROCEDURE()
,@errorline = ERROR_LINE()
,@errormessage = ERROR_MESSAGE();
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
@errornumber ,
@errorseverity ,
@errorstate,
@errorprocedure,
@errorline,
@errormessage);
END CATCH
PRINT @errornumber;
PRINT @errorseverity;
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 @SalesID = scope_identity();
PRINT @SalesID;
--================================================================================
--Insert into SALES_TRADEIN Table
BEGIN TRY
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 is not null then @TradeIn_2_VIN end,
case when @TradeIn_1_Make is not null then @TradeIn_2_Make end,
case when @TradeIn_1_Model is not null then @TradeIn_2_Model end,
case when @TradeIn_1_ExteriorColor is not null then @TradeIn_2_ExteriorColor end,
case when @TradeIn_1_Year is not null then @TradeIn_2_Year end,
case when @TradeIn_1_Mileage is not null then @TradeIn_2_Mileage end,
case when @TradeIn_1_Gross is not null then @TradeIn_2_Gross end,
case when @TradeIn_1_Payoff is not null then @TradeIn_2_Payoff end,
case when @TradeIn_1_ACV is not null then @TradeIn_2_ACV end,
case when @TradeIn_1_InteriorColor is not null then @TradeIn_2_InteriorColor end
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER()
,@errorseverity = ERROR_SEVERITY()
,@errorstate = ERROR_STATE()
,@errorprocedure = ERROR_PROCEDURE()
,@errorline = ERROR_LINE()
,@errormessage = ERROR_MESSAGE();
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
END CATCHThis is what I've understood from your question. You want to replace @TradeIn_2_VIN value if @TradeIn_1_VIN
is NULL, else the value of @TradeIn_1_VIN.
If this is the requirement then, your CASE statement is missing ELSE part. You can re-write this as below
case when @TradeIn_1_VIN is null then @TradeIn_2_VIN
ELSE @TradeIn_1_VIN end,
or simply you can replace the CASE statement with the below
COALESCE function,
COALESCE(@TradeIn_1_VIN, @TradeIn_2_VIN),
Krishnakumar S -
Update a table using plsql procedure
Can any one help me to write a plsql procedure to update a table with new records and changes;
Table rtest1 contains following records:
deptno(number) deptname(varchar2(10)
10 EWP
20 PWD
30 EPF
Table rtest2 contains follwing records:
deptno(number) deptname(varchar2(10)
10 prod
40 ops
how to write a plsql procedure to to update table rtest2 using rtest1 data .use a merge statement, like this:
SQL> create table rtest1
2 as
3 select 10 deptno, 'EWP' deptname from dual union all
4 select 20, 'PWD' from dual union all
5 select 30, 'EPF' from dual
6 /
Tabel is aangemaakt.
SQL> create table rtest2
2 as
3 select 10 deptno, 'prod' deptname from dual union all
4 select 40, 'ops' from dual
5 /
Tabel is aangemaakt.
SQL> create procedure my_merge
2 is
3 begin
4 merge into rtest2 r2
5 using (select deptno, deptname from rtest1) r1
6 on (r2.deptno = r1.deptno)
7 when matched then
8 update set deptname = r1.deptname
9 when not matched then
10 insert (deptno,deptname) values (r1.deptno,r1.deptname)
11 ;
12 end;
13 /
Procedure is aangemaakt.
SQL> exec my_merge
PL/SQL-procedure is geslaagd.
SQL> select * from rtest2 order by deptno
2 /
DEPTNO DEPT
10 EWP
20 PWD
30 EPF
40 ops
4 rijen zijn geselecteerd.Regards,
Rob. -
Retrive a new sequence value from a table using Stored Procedure
Dear experts
i have written the following stored procedure, but i want this to return itemid to the environment. Please help as i am absolutely new to oracle.
create or replace procedure "SP_ITEMS"
(vitem IN VARCHAR2,
vqty IN NUMBER,
vrate IN NUMBER)
is
begin
INSERT INTO ITEMS (item,qty,rate)
VALUES (vitem,vqty,vrate);
end;
Thanks
With regards
Manish SawjianiIf you want a column to be automatically populated with a sequence, then you need to create a sequence, and create a trigger to populate the column with the sequence. You can use the returning clause in a select statement to return the value of the inserted sequence. You can do this with just sql or you can put it in a procedure. I have demonstrated both below. This is a general sql and pl/sql problem, not something specific to the Express Edition, so please post future such questions in the sql and pl/sql discussion group instead.
SCOTT@10gXE> CREATE TABLE items
2 (itemid NUMBER,
3 item VARCHAR2 (50),
4 qty NUMBER (10, 3),
5 rate NUMBER (10, 3))
6 /
Table created.
SCOTT@10gXE> CREATE SEQUENCE item_sequence
2 /
Sequence created.
SCOTT@10gXE> CREATE OR REPLACE TRIGGER items_bir
2 BEFORE INSERT ON items
3 FOR EACH ROW
4 BEGIN
5 SELECT item_sequence.NEXTVAL
6 INTO :NEW.itemid
7 FROM DUAL;
8 END items_bir;
9 /
Trigger created.
SCOTT@10gXE> SHOW ERRORS
No errors.
SCOTT@10gXE> VARIABLE g_itemid NUMBER
SCOTT@10gXE> INSERT INTO items (item, qty, rate)
2 VALUES ('item1', 2, 3)
3 RETURNING itemid INTO :g_itemid
4 /
1 row created.
SCOTT@10gXE> PRINT g_itemid
G_ITEMID
1
SCOTT@10gXE> CREATE OR REPLACE PROCEDURE sp_items
2 (p_item IN VARCHAR2,
3 p_qty IN NUMBER,
4 p_rate IN NUMBER,
5 p_itemid OUT NUMBER)
6 AS
7 BEGIN
8 INSERT INTO ITEMS (item, qty, rate)
9 VALUES (p_item, p_qty, p_rate)
10 RETURNING itemid INTO p_itemid;
11 END sp_items;
12 /
Procedure created.
SCOTT@10gXE> SHOW ERRORS
No errors.
SCOTT@10gXE> EXECUTE sp_items ('item2', 3, 4, :g_itemid)
PL/SQL procedure successfully completed.
SCOTT@10gXE> PRINT g_itemid
G_ITEMID
2
SCOTT@10gXE> SELECT * FROM items
2 /
ITEMID ITEM QTY RATE
1 item1 2 3
2 item2 3 4
2 rows selected.
SCOTT@10gXE> -
Form on table: Using stored procedure to update?
I have a view which joins a handful of tables. I have a PL/SQL API that contains all the necessary business logic and translations to update the tables underlying this view.
If I use the HTMLDB wizard to create a form on this view, it would automatically generate plain INSERT/UPDATE statements for DML against the view. How can I make it use my API instead? (Yes, I can probably plug in my API in INSTEAD OF triggers on the view, but I really dont want to do that)
[Of course, the reason I would use the built-in form-on-table wizard is to get the automatic lost-update detection, locking, etc features]
Help? ThanksThe wizards are there to help you build typical pages like "form based on a table", "form on based a stored procedure".
There is no wizard for "form based on a view, using my own API for inserts, updates and delete" - but that doesn't prevent you building such a form by hand. I have built similar forms, and found it quite easy to approach it like this:
1) use "form based on a stored procedure" to create a form based on your API insert procedure
2) add further buttons and processes to call your API's update and delete procedures
3) add an "on load" process to select the row from the view and populate the form for update or delete
You need to add some logic for context-sensitivity - e.g. Update and Delete buttons only appear when in "update mode", etc. -
From the Parent Table i need to insert rows which are all under this column {(TradeIn_1_VIN),(TradeIn_2_VIN),(TradeIn_3_VIN) } into SALES_TRADEIN Table .
I have used the below Query,
But it reads only (TradeIn _1_Vin) Column in the SALES_TRADEIN table rest 2 records got skipped..
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 is null then @TradeIn_2_VIN else @TradeIn_1_VIN end,
case when @TradeIn_1_Make is null then @TradeIn_2_Make else @TradeIn_1_Make end,
case when @TradeIn_1_Model is null then @TradeIn_2_Model else @TradeIn_1_Model end,
case when @TradeIn_1_ExteriorColor is null then @TradeIn_2_ExteriorColor else @TradeIn_1_ExteriorColor end,
case when @TradeIn_1_Year is null then @TradeIn_2_Year else @TradeIn_1_Year end,
case when @TradeIn_1_Mileage is null then @TradeIn_2_Mileage else @TradeIn_1_Mileage end,
case when @TradeIn_1_Gross is null then @TradeIn_2_Gross else @TradeIn_1_Gross end,
case when @TradeIn_1_Payoff is null then @TradeIn_2_Payoff else @TradeIn_1_Payoff end,
case when @TradeIn_1_ACV is null then @TradeIn_2_ACV else @TradeIn_1_ACV end,
case when @TradeIn_1_InteriorColor is null then @TradeIn_2_InteriorColor else @TradeIn_1_InteriorColor end
END TRY
Actually my problem is
If [(TradeIn_1_VIN),(TradeIn_2_VIN),(TradeIn_3_VIN)] these 3 columns have details i need all the 3 columns details need to be read to SALES_TRADEIN table.
Suppose if we have data only in [(TradeIn_1_VIN),(TradeIn_2_VIN)] then these column details need to loaded in the SALES_TRADEIN table.
If any columns are blank no problem it can move next process.
Please help me change those particular lines to insert all the 3 records (TradeIn_1_VIN) (TradeIn_2_VIN) (TradeIn_3_VIN) in to the table.From SQL2008 on, besides INSERT-SELECT, and INSERT-EXEC, the INSERT-VALUES form of the insert command is improved. It can insert multiple rows like this:
INSERT INTO my_table(MyColA, MyColB)
VALUES
(1, 1),
(2, 2),
(3, 3)
You could also use that in SELECTs, like this:
SELECT *
FROM
( VALUES (1,2), (3,4)
) t(a, b) -
How to save images to table using stored procedures?
hi all,
i created a stored procedure
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members values ( id, name, avatar);
commit;
end;i have 3 items in page..
1. Hidden -> P1_ID
2. Text field - > P1_NAME
3. File Browse - P1_AVATAR
but when invoking the procedure in Processes like
begin
add_member ( id => :P1_ID, name => :P1_NAME, avatar => :P1_AVATAR );
end;i get an error
1 error has occurred
* ORA-06550: line 3, column 3: PLS-00306: wrong number or types of arguments in call to 'ADD_MEMBERR' ORA-06550: line 3, column 3: PL/SQL: Statement ignoredcan anyone tell me why it errors out?
thanks
allenDid you do as fac586 suggested:
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members values ( id, name, avatar);
commit;
end;should be something like:
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members (id, name, avatar) values ( id, name, avatar);
commit;
end;You need to specify the columns of the table that you will be inserting values into.
Also, you should probably rename the parameters of your procedure so you can differentiate between the parameters, and the database columns.
i.e.:
create or replace add_ member ( p_id number, p_name varchar2, p_avatar blob ) -
Help with truncating a table using plsql procedure in different schema
I have a plsql procedure in schema A that truncates a table that is given in as parameter.
create or replace procedure truncate_table(schema, table_name)
EXECUTE IMMEDIATE 'TRUNCATE TABLE '||schema||'.'||table_name;
end;
The above procedure has public execute grant.
I need to truncate a table in schema B. I have a plsql procedure in schema B that calls the truncate_table procedure and passes in the schema B table name.
Since the table is in schema B, should the delete grant on the table be given to user A or user B to truncate the table in schema B?
Thanks in advance.Procedure created in schema A
create or replace
procedure truncate_table(l_schema varchar2, table_name varchar2) authid current_user
as
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE '||l_schema||'.'||table_name;
end;from schema B
grant delete on table1 to Schema_A
from schema A
exec truncate_table('Schema_B','Table1');
Hope this helps.
Alvinder -
Insert and update same record of table using store procedure in oracle 10g
Hi,
I am using oracle sql developer for this.
I have created Store procedure which run after every 30mins of interval.
the problem is Ii need to insert data for first time of day then later that same record should update for particular field(here its plan code).
if new field is coming (if new plan code is generated) then it should insert data and again update same for interval.
means for each plan individual record(i.e. plan wise summary) should be there for only a day. next day new record for same plan.Hi,
You should use Merge like shown below:-
Merge into original_table a
using second_table b
on (a.primary_key=b.primary_key and a.primary_key........)
when match then
update set column_list=b.column_list
when not match then
isert into (column list)
values(a.column_list)If you dont know much about merge then follow below link..
http://www.oracle-developer.net/display.php?id=203
http://www.oracle-base.com/articles/10g/merge-enhancements-10g.php -
How to update all the rows of table using stored procedures
Hi,
I want to update all the rows of a table of a specific column
sp_a male
sp_b female
sp_c male
sp_d female
in above table
gender of all the columns has to be interchanged.Sir table is like this detail(name varchar(10),gender varchar(10))
Where Details are like this
Name Gender
sp_a
male
sp_b
female
sp_c
male
sp_d
female
I want to create a stored procedure which automtically updates gender from male to female and female to male
for all the rows . i.e., all the rows are updated for column gender by just running a stored procedure.
So after execution of stored proc the above table looks
Name Gender
sp_a
female
sp_b
male
sp_c
female
sp_d
male -
hello, we need to remove the dirty data from MDS, but we found we can only do this from MDS web, and we need to do this by store procedure to make this process automatically. is there any easy method to remove the data from MDS automatically? thank.
WarrenHi Warren,
Assuming the dirty data is easily identifiable, all you need to do is use the staging process with import type of 5 (de-activate - i.e., soft delete) or import type of 6 (hard delete).
Could give more details if I knew the version of MDS you are running (SQL 2008R2 or SQL 2012).
Kind regards,
M
Maybe you are looking for
-
IPhoto Crash on Import (9.2, after Lion/iCloud Update
This first happens on when i plugged in the ipad and it pops up to ask if i want to upgrade iPhoto. Now, iPhoto still opens but whenever I try to import photo it would crash and quit itself. I have turned off photo stream, as if I have that on I cann
-
Headphone jack/hookup to stereo problem with existing jack??
Is it just me, or is the jack port different for the iPhone? Went to use it in my boat today where no less than 3 other ipods have been plugged in..... the jack won't go all the way into the hole. The iphone jack requires a skinny little plug to slip
-
Reverse reset of Clearing Restriction
Dear All, I have a requirement where I need to block a clearing of an invoice until customer signs an agreement. I have set a clearing restriction on the invoice. And I made an entry in modifiable clearing restriction in IMG. This allows manual reset
-
How to put data in the table for Absence Quotas.
Hello Gurus, How to configure in the table (V_556A_B)Absence Quota for increase in SicK Leave and Priviledge Leave. Kindly provide me with steps.
-
Installing Flash Player on Surface tablet.
Hello, how can I install the latest flash player on my Windows Surface tablet..?