hi,
I need to handle the error message in stored procedure.
I am doing following things...
1. First i will be loading data into a table from flat file which is of .CSV format.
2. I am loading the data along with header.
3. I use normal delete statement to delete the row which has header by comparing with column headers from the table.
The statement goes like this......
If all the columns match each other, the message should be displayed as header's are deleted. If any of the header is not matched, it should not delete the header, instead it should throw an error message saying this particular table header is not deleted.
Currently i am using following syntax. The execution of the stored procedure is happening successfully and a message 'header is deleted' is also displayed. To cross verify, we gave wrong header name in the file, but it is not throwing any error message for that particular table.
Your help is required to trouble shoot this error.
Thanks in advance
VIJ
I need to handle the error message in stored procedure.
I am doing following things...
1. First i will be loading data into a table from flat file which is of .CSV format.
2. I am loading the data along with header.
3. I use normal delete statement to delete the row which has header by comparing with column headers from the table.
The statement goes like this......
Code:
delete from dbo.ListingTrend_State_BE
where STATE_CODE='STATE_CODE' and STATE_NAME='STATE_NAME' and YYYYMM='YYYYMM' and DATA_PERIOD='DATA_PERIOD'
If all the columns match each other, the message should be displayed as header's are deleted. If any of the header is not matched, it should not delete the header, instead it should throw an error message saying this particular table header is not deleted.
Currently i am using following syntax. The execution of the stored procedure is happening successfully and a message 'header is deleted' is also displayed. To cross verify, we gave wrong header name in the file, but it is not throwing any error message for that particular table.
Code:
Begin
if object_id ('dbo.ListingTrend_State_BE') is not NULL
begin
delete from dbo.ListingTrend_State_BE
where STATE_CODE='STATE_CODE' and STATE_NAME='STATE_NAME' and YYYYMM='YYYYMM' and DATA_PERIOD='DATA_PERIOD'
and ALL_INV_COUNT='ALL_INV_COUNT'
and ASK_SPRD_STD='ASK_SPRD_STD'
and MNT_SPLY_COUNT='MNT_SPLY_COUNT'
and MKT_VELC='MKT_VELC'
and MKT_INDC_MEAN='MKT_INDC_MEAN'
and MKT_INDC_MED='MKT_INDC_MED'
and MKT_INDC_STD='MKT_INDC_STD'
select 'state header deleted'
end
else select 'state header not deleted'
Your help is required to trouble shoot this error.
Thanks in advance
VIJ