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
allen
Did 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 )
Similar Messages
-
How to work on Data Analysis using Stored procedures
How to work on Data Analysis using Stored procedures any suggestions
Carefully? Precisely? Tomorrow? Your question has no context so it means little to an outside reader. Perhaps you should start with some basic research into the data mining features of sql server:
data mining homepage -
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 IT SAVES IMAGE IN TABLE?
Hi friends,
I have 1 table test with fields:
eid number,
e_pict long raw.
I have saved images through a form to the table from a file.
after saving I tried to see the table's data:
SQL> SELECT * FROM TEST;
EID E_PICT
123 4
20
789 4
456 4
4897 4
128 5
6 rows selected.
I've found for same type of image (say .gif) the E_PICT value is same, only when change the image type the value changes and does not depend on path or filename. Then how Oracle keeps track of exactly which image is saved?
Pls help me.
Regards,
Pragati.What version of Oracle, and what are you hoping to do with the images?
Oracle has something called interMedia which is included free in the Standard and Enterprise editions of the database. It handles audio, image and video.
The documentation even includes "The interMedia PL/SQL Web Toolkit Photo Album sample application" which demonstrates how to perform the following operations:
*Use the interMedia image object type to upload, retrieve, and process media data stored in Oracle Database.
*Combine the image metadata methods of interMedia with the XML document management capabilities of Oracle XML DB and the full-text indexing and search features of Oracle Text to create a solution that can extract, store, and search metadata that is embedded in binary image files.
*Collect new metadata from a user, format the metadata into an XML document, and store the document in the binary image.
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14302/ch_webapp.htm#sthref144 -
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 -
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. -
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 -
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> -
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 Insert date in 'DD/MM/YYYY' format in oracle using stored procedure?
Hi
How to Insert date in 'DD/MM/YYYY' format in oracle using stored procedure?
This is my Input data.
11/25/2007.
By using below query, it is inserted into database.
sql>Insert into tblname values(to_date('11/25/2007','MM/DD/YYYY'));
But using stored procedure, the same query is not running.
It shows error like
ORA-01843: not a valid month ORA-06512: at line 1
Procedure:
create or replace procedure Date_Test(datejoin in DATE) is
begin
insert into datetest values(to_date(datejoin,'MM/DD/YYYY'));
end Date_Test;
I had used 'nls_date_language = american' also.
Prcodeure is created but not worked in jsp. The same error is thrown.
Pls provide a solutionThis might help you....
SQL> Create Table DateTest(col1 Date);
Table created.
Elapsed: 00:00:00.00
SQL> create or replace procedure Date_Test(datejoin in DATE) is
2 begin
3 insert into datetest values(to_date(datejoin,'MM/DD/YYYY'));
4 end ;
5 /
Procedure created.
Elapsed: 00:00:00.00
SQL> exec Date_Test('11/25/2007');
BEGIN Date_Test('11/25/2007'); END;
ERROR at line 1:
ORA-01843: not a valid month
ORA-06512: at line 1
Elapsed: 00:00:00.00
SQL> exec Date_Test(To_Date('11/25/2007','mm/dd/yyyy'));
BEGIN Date_Test(To_Date('11/25/2007','mm/dd/yyyy')); END;
ERROR at line 1:
ORA-01843: not a valid month
ORA-06512: at "CTBATCH.DATE_TEST", line 3
ORA-06512: at line 1
Elapsed: 00:00:00.00
SQL> create or replace procedure Date_Test(datejoin in DATE) is
2 begin
3 insert into datetest values(datejoin);
4 end ;
5 /
Procedure created.
Elapsed: 00:00:00.00
SQL> exec Date_Test(To_Date('11/25/2007','mm/dd/yyyy'));
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> Select * from DateTest;
COL1
25-NOV-07
Elapsed: 00:00:00.00
SQL> create or replace procedure Date_Test(datejoin in VarChar2) is
2 begin
3 insert into datetest values(to_date(datejoin,'mm/dd/yyyy'));
4 end ;
5 /
Procedure created.
Elapsed: 00:00:00.00
SQL> exec Date_Test('11/25/2007');
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> select * from DateTest;
COL1
25-NOV-07
25-NOV-07
Elapsed: 00:00:00.00
SQL> -
How to use Stored Procedure Call in Sender JDBC adapter
Hi All,
Could someone send me a blog on how to use Stored Procedure call in Sender JDBC adapter?
XierHi Xler
refer these links
/people/yining.mao/blog/2006/09/13/tips-and-tutorial-for-sender-jdbc-adapter
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
Also, you can check Sriram's blog for executing Stored Procedures,
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
/people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
This blog might be helpfull on stored procedures for JDBC
JDBC Stored Procedures
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
Please go through these threads and see if it helps...
Re: How to execute Stored Procedure?
Re: Problem with JDBC stored procedure
Thnaks !! -
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 -
How to use dynamic parameter when a report is created using Stored Procedures
Hi all,
any one have the idea of how to use dynamic parameter in crystal report XI R2
when report is created using Stored Procedure.
Regards
shashi kant chauhanHi
You can create an SQL command in Database Expert > Expand your datasource > Add command
Then enter the SQL query that will create the list of values to supply to the user
eg select field1,field2 from table
Then edit the parameter of the report. These will be the SP parameters adn can be seen in field explorer.
Change the parameter type to Dynamic
Under the word Value click on Click here to add item
Scroll down to your Command and select one of the values that you want to appear in the list
e.g field1
Then click on the Parameters field - this is essential to create the param
You can edit other options as required
That should do it for you.
I must say that i use CR 2008 connected to Oracle 10g SP, but i reckon this will work for SQL DB and CR XI as well
Best of luck -
E61i -- HOW TO SAVE IMAGES FROM WEBSITE WHILE BROW...
ANYBODY KNOWS HOW TO SAVE IMAGES FROM WEBSITE WHILE BROWSING IN E61i ???
ABDULLAH SHAHID SHEIKH
IMANGROUP, IMAN ROAD, NOORPUR, ALI BLOCK, MUSLIM TOWN, FAISALABAD, PAKISTAN.
TEL. 0092418782792-93
CELL. 00923008651424which version should i use ,, i mean suitable for my E61i,,, the opera mini or the opera mobile????
is opera mini can save the images as well???
25-Aug-200702:43 PM
iantaylor27 wrote:
Hi
If you use opera mobile, it aloows saving of images to memory card etc
www.opera.com
ABDULLAH SHAHID SHEIKH
IMANGROUP, IMAN ROAD, NOORPUR, ALI BLOCK, MUSLIM TOWN, FAISALABAD, PAKISTAN.
TEL. 0092418782792-93
CELL. 00923008651424 -
How to build a report in webi XIr2 using stored procedure
Post Author: vijay123
CA Forum: WebIntelligence Reporting
hi,
Is anybody can help me out how to creat a report using stored procedure in webiXir2
thanks
vijayPost Author: amr_foci
CA Forum: WebIntelligence Reporting
this has been posted twice.. i think
Maybe you are looking for
-
Error while using container element _WF_PARFOREACH_INDEX in workflow
Hi All, I am using internal container element WFPARFOREACH_INDEX in internal table so that i can use it as index to read table row one by one..but in binding i am getting error "Container element '_WF_PARFOREACH_INDEX' does not exist" in form of an e
-
Black login screen, only the mouse appears.
Hello guys, My problem is this, Windows does all the updates normally without any error during the process, but each time the system reboots the machine, Windows logo appears carrying the system and when it arrives at logon screen nothing pops up, on
-
HI, I have a Dell 3000CN Network Laser Printer. How do I get it to work with my Mac (IMac i3 17 Quad Core) ? Help Please
-
Automator to sync with a memory Stick
i am looking to have a memory stick every time i plug it in to my mac, to automatically check with a folder on my hard drive and sync up any changes with the 1 folder (and subfolders) bi directionally (same stick and folder every time) this is a mem
-
I just installed Lion (10.7.2) and when I reboot, my desktop icons do not appear until I click on the Finder icon. What's the deal. Thanks, Barry