Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with Insert statement and web controls

Author  Topic 

TM2
Starting Member

4 Posts

Posted - 2007-08-03 : 18:15:27
Can someone help with this? Let me know if what I'm trying to do is possible...



Here's code example:



@ClientID int,

@QuoteID int,

@Base real,

@One real,

@DwellingLimit real

AS

BEGIN

Insert Into tblOne(ClientID,QuoteID,GuideID,GuideRate,GuideMult,Premium)

Select @ClientID, @QuoteID, GuideID,GuideRate, @+"GuideMult"+,GuideRate*GuideMult

From tblTwo

Where Choose = 'True';

END



I need the value stored in tblTwo.GuideMult (ie. One, BaseRate) to be translated

into the numerical value shown on a webform (ie. @One, @BaseRate) and then

insert the numerical values into tblOne.GuideMult



Clear as mud? Does somebody have a better way to do this?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-03 : 18:19:50
Can you show with some sample data what you are trying to do..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

TM2
Starting Member

4 Posts

Posted - 2007-08-03 : 18:33:20
tblTwo has data like this:
Row# - GuideRate - GuideMult
1 .10 Base
2 .20 Base
3 .15 One

On a web form:
@Base is the result of a calculation based on entered data
@One is the result of another calculation based on same entered data

I want to store the calculated numerical value in tblOne.GuideMult.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-03 : 18:41:59
Sorry, I dont think I still understand your question.

(1) What is the value that comes via the parameters
(2) How do you want to split the values in parameters into the table

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

TM2
Starting Member

4 Posts

Posted - 2007-08-03 : 19:32:01
The spacing was messed up on posting the last...

OK, let me try again.
tblTwo holds a list of options a user can choose from.
For each option chosen, a formula will calculate:
GuideRate * GuideMult

GuideRate is a real datatype
GuideMult is a varchar datatype
GuideMult will contain one of three values: One, Base, or Limit

On a web form, the controls (@One, @Base, @Limit) contain the result of different calculations based on entered data.

How can I retrieve the calculated values (@One,@Base,@Limit) to store in tblOne as real datatypes?
Does this help?
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-03 : 19:37:08
So only one of the three @One, @Base, @Limit will have values? and you need to figure out which one has the value? or do you need to concatenate all three values into one?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

TM2
Starting Member

4 Posts

Posted - 2007-08-03 : 20:06:14

If Option #1 in tblTwo has been chosen,
GuideRate has value of 0.10
and GuideMult has value of "Base"

Based on the web form calculations,
@One may contain 10.00
@Base may contain 25.83
@Limit may contain 40.00

I want to insert into tblOne.GuideRate (0.10) and into
tblOne.GuideMult (25.83) so that I can calculate
tblOne.Premium (GuideRate*GuideMult = 0.10*25.83) then final value of (2.583)

I want to be able to use & store whatever numerical value corresponds to tblTwo.GuideMult

Is there a way to modify (punctuation-wise) the "SELECT" statement in the first post to accomplish this?
Go to Top of Page
   

- Advertisement -