| Author |
Topic |
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 15:09:16
|
hello anyone... i got this message "Error converting data type varchar to float" when i was trying to insert values into table using instead of trigger...below is my table ClimateData quote: USE [PVMC Database]GO/****** Object: Table [dbo].[ClimateData] Script Date: 03/26/2008 03:04:44 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[ClimateData]( [Climate_application_id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_ClimateData_Climate_application_id] DEFAULT (newid()), [Latitude] [float] NULL, [Longitude] [float] NULL, [Altitude] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [Climate_type] [varchar](100) COLLATE Latin1_General_CI_AI NULL, [PV_application_id] [uniqueidentifier] NULL, CONSTRAINT [PK_ClimateData_1] PRIMARY KEY CLUSTERED ( [Climate_application_id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFGOUSE [PVMC Database]GOALTER TABLE [dbo].[ClimateData] WITH CHECK ADD CONSTRAINT [FK_ClimateData_Photovoltaic] FOREIGN KEY([PV_application_id])REFERENCES [dbo].[Photovoltaic] ([PV_application_id])ON UPDATE CASCADEON DELETE CASCADE
Below is photovoltaic table quote: USE [PVMC Database]GO/****** Object: Table [dbo].[Photovoltaic] Script Date: 03/26/2008 03:06:58 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[Photovoltaic]( [PV_application_id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Photovoltaic_PV_application_id] DEFAULT (newid()), [PV_site] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_state] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_type_of_system] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_nominal_power] [float] NULL, [PV_module] [varchar](150) COLLATE Latin1_General_CI_AI NULL, [PV_mounting] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_building_type] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_topology] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_new_or_retrofit] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_period_of_design] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_period_of_construction] [varchar](50) COLLATE Latin1_General_CI_AI NULL, [PV_commissioning_date] [datetime] NULL CONSTRAINT [DF_Photovoltaic_PV_commissioning_date] DEFAULT (getdate()), [PV_site_photo] [varbinary](max) NULL, [PV_peak_nominal_rating] [float] NULL, [User_application_id] [uniqueidentifier] NULL, [Org_application_id] [uniqueidentifier] NULL, CONSTRAINT [PK_Photovoltaic_1] PRIMARY KEY CLUSTERED ( [PV_application_id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFGOUSE [PVMC Database]GOALTER TABLE [dbo].[Photovoltaic] WITH CHECK ADD CONSTRAINT [FK_Photovoltaic_OrganizationDetail] FOREIGN KEY([Org_application_id])REFERENCES [dbo].[OrganizationDetail] ([Org_application_id])ON UPDATE CASCADEON DELETE CASCADEGOALTER TABLE [dbo].[Photovoltaic] WITH CHECK ADD CONSTRAINT [FK_Photovoltaic_Users] FOREIGN KEY([User_application_id])REFERENCES [dbo].[Users] ([User_application_id])ON UPDATE CASCADEON DELETE CASCADE
Below also my command for instead of trigger quote: set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoCREATE trigger [tr_v_PhotovoltaicClimateData] on [dbo].[v_PhotovoltaicClimateData] instead of insert asBEGIN insert Photovoltaic (PV_site, PV_state, PV_type_of_system, PV_nominal_power, PV_module, PV_mounting) select distinct inserted.PV_site, inserted.PV_state, inserted.PV_type_of_system, inserted.PV_nominal_power, inserted.PV_module, inserted.PV_mounting from inserted left join Photovoltaic on inserted.PV_site = Photovoltaic.PV_site and inserted.PV_state = Photovoltaic.PV_state and inserted.PV_type_of_system = Photovoltaic.PV_type_of_system and inserted.PV_nominal_power = Photovoltaic.PV_nominal_power and inserted.PV_nominal_power = Photovoltaic.PV_module and inserted.PV_nominal_power = Photovoltaic.PV_mounting where Photovoltaic.PV_site IS NULL /*** Exclude Organization Detail already in the table ***/ insert ClimateData (Latitude, Longitude, Altitude, Climate_type, PV_application_id) select distinct inserted.Latitude, inserted.Longitude, inserted.Altitude, inserted.Climate_type, Photovoltaic.PV_application_id from inserted inner join Photovoltaic on inserted.PV_site = Photovoltaic.PV_site left join ClimateData on inserted.Latitude = ClimateData.Latitude and inserted.Longitude = ClimateData.Longitude and inserted.Altitude = ClimateData.Altitude and inserted.Climate_type = ClimateData.Climate_type where ClimateData.Latitude IS NULL /*** Exclude Organization Types already in the table ***/ END -- trigger def
and finally, i hav tried using this command to insert into table v_PhotovoltaicClimateData.. this is the command to insert quote: insert into v_PhotovoltaicClimateData(PV_site, PV_state, PV_type_of_system, PV_nominal_power, PV_module, PV_mounting, Latitude, Longitude, Altitude, Climate_type)values ('CETDEM', 'Sequ Inspection', 'Cheras', 34.44, 'ew', 'ewew',34343.44, 323.32, 'ewew', 'ewewe')
and i got this error... quote: Msg 8114, Level 16, State 5, Procedure tr_v_PhotovoltaicClimateData, Line 6Error converting data type varchar to float.
so anyone... plzz help me...  |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-25 : 15:17:20
|
| Can you provide DDL for v_PhotovoltaicClimateData as well? it seems like you are trying to populate a varchar value to a float type column. |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 15:26:42
|
| i have no DDL... the prob here is how to convert data type varchar to float.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-25 : 15:29:21
|
| use CAST() to cast it to float. Cant understand why you dont have DDL? DDL means table structure just as you posted for other two tables. |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 15:33:36
|
| use cast() ?? how visakh? in where? |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 15:46:02
|
| see my structure <a href="http://allyoucanupload.webshots.com/v/2002713281215751145"><img border="0" src="http://aycu35.webshots.com/image/46474/2002713281215751145_rs.jpg" alt="Free Image Hosting at allyoucanupload.com"/></a><a href="http://allyoucanupload.webshots.com/v/2002770590529628334"><img border="0" src="http://aycu17.webshots.com/image/47216/2002770590529628334_rs.jpg" alt="Free Image Hosting at allyoucanupload.com"/></a> |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-25 : 15:51:30
|
| Structure looks ok. Can you change like this?insert into v_PhotovoltaicClimateData(PV_site, PV_state, PV_type_of_system, PV_nominal_power, PV_module, PV_mounting, Latitude, Longitude, Altitude, Climate_type)values ('CETDEM', 'Sequ Inspection', 'Cheras', CAST(34.44 AS float), 'ew', 'ewew',34343.44, 323.32, 'ewew', 'ewewe') |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 15:59:16
|
visakh.. i still got the same error... Msg 8114, Level 16, State 5, Procedure tr_v_PhotovoltaicClimateData, Line 5Error converting data type varchar to float. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-25 : 16:04:35
|
| then error is somewhere else. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-25 : 16:05:26
|
How can last "ewew" be an altitude?insert into v_PhotovoltaicClimateData(PV_site, PV_state, PV_type_of_system, PV_nominal_power, PV_module, PV_mounting, Latitude, Longitude, Altitude, Climate_type)values ('CETDEM', 'Sequ Inspection', 'Cheras', 34.44, 'ew', 'ewew',34343.44, 323.32, 'ewew', 'ewewe') E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 16:07:45
|
| altitude i put VARCHAR because for example...i will insert data like this.. 30 metres above sea level... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-25 : 16:08:25
|
Didnt spot that one |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 16:09:36
|
| errmm.. what shud i do?? i hav no idea... |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-25 : 16:13:01
|
Also, v_PhotovoltaicClimateData doesn't exist in any of the DDLs above.Table PhotovoltaicClimateData does, but not the view(?) v_PhotovoltaicClimateData. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-25 : 16:18:17
|
| i forgot to show... i also hav view table v_PhotovoltaicClimateData..see this structure<a href="http://allyoucanupload.webshots.com/v/2005053021185074206"><img border="0" src="http://aycu13.webshots.com/image/50012/2005053021185074206_rs.jpg" alt="Free Image Hosting at allyoucanupload.com"/></a> |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-26 : 01:53:30
|
help me??? |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-26 : 11:47:58
|
| anyone???? |
 |
|
|
ejoeyz_85
Yak Posting Veteran
54 Posts |
Posted - 2008-03-28 : 03:11:47
|
| comon...plz.. i've tried many time... |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|