Setting up default values from the passed value

Setting up default values from the passed value

Post by William Enlo » Sat, 10 Jan 2004 23:24:28



Please see the sample code below to follow question.  

How can I allow a default value be set by another inputted value within
a stored procedure?

Create Procedure PROC_build_file



AS


                Begin
                Some stuff
                End
        Else
                Begin
                Some Other Stuff
                End

-- End of Procedure

-- Sample run 1

-- to accomplish var_1 = 'FIN' and var_2 = 'FIN_other_Standard'

-- Sample run 2

'FIN_other_Standard'
-- to accomplish var_1 = 'CIS' and var_2 = 'FIN_other_Standard'

Thank you,
Bill

 
 
 

Setting up default values from the passed value

Post by Aaron Bertrand - MV » Sat, 10 Jan 2004 23:52:05


You can't, you will need to do that within the procedure body.

CREATE PROC build_file


AS
BEGIN


    ELSE
        -- there was
END

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


> Please see the sample code below to follow question.

> How can I allow a default value be set by another inputted value within
> a stored procedure?

> Create Procedure PROC_build_file



> AS


> Begin
> Some stuff
> End
> Else
> Begin
> Some Other Stuff
> End

> -- End of Procedure

> -- Sample run 1

> -- to accomplish var_1 = 'FIN' and var_2 = 'FIN_other_Standard'

> -- Sample run 2

> 'FIN_other_Standard'
> -- to accomplish var_1 = 'CIS' and var_2 = 'FIN_other_Standard'

> Thank you,
> Bill


 
 
 

Setting up default values from the passed value

Post by Mary Bra » Sat, 10 Jan 2004 23:55:18


I I understand the question you could check to see if the second parameter
has not been set (is null), and if so set it using the value from the first
parameter eg:

> Create Procedure PROC_build_file



> AS



> Please see the sample code below to follow question.

> How can I allow a default value be set by another inputted value within
> a stored procedure?

> Create Procedure PROC_build_file



> AS


> Begin
> Some stuff
> End
> Else
> Begin
> Some Other Stuff
> End

> -- End of Procedure

> -- Sample run 1

> -- to accomplish var_1 = 'FIN' and var_2 = 'FIN_other_Standard'

> -- Sample run 2

> 'FIN_other_Standard'
> -- to accomplish var_1 = 'CIS' and var_2 = 'FIN_other_Standard'

> Thank you,
> Bill

 
 
 

Setting up default values from the passed value

Post by Trey Walpol » Sat, 10 Jan 2004 23:55:27


afaik, you'd have to catch it in your proc, instead of the parm, e.g.

Create Procedure PROC_build_file


as


etc...


> Please see the sample code below to follow question.

> How can I allow a default value be set by another inputted value within
> a stored procedure?

> Create Procedure PROC_build_file



> AS


> Begin
> Some stuff
> End
> Else
> Begin
> Some Other Stuff
> End

> -- End of Procedure

> -- Sample run 1

> -- to accomplish var_1 = 'FIN' and var_2 = 'FIN_other_Standard'

> -- Sample run 2

> 'FIN_other_Standard'
> -- to accomplish var_1 = 'CIS' and var_2 = 'FIN_other_Standard'

> Thank you,
> Bill

 
 
 

1. Setting Default Value to value of another column

I've got a database table with some existing data.  I'd like to add another
column, not allowing NULLs.  When the column is added, I want its value to
be equal to the value of another column (TypeID being the existing column,
TypeID2 being the new column).

Anyone know if there is a way in the management console (design table) to do
this?  Or is there a "modify table" command to do it?

TIA,
Owen

2. Can I use the TO_DATE function in views for INSERTS and UPDATES?

3. Use ISNULL to set the value to the default value when NULL

4. GPF in NL.DLL

5. How to set default value of combo box to value of record in database

6. JBuilder / DataExpress: Boolean Defaults ignored

7. Problem passing default textbox properties to a field value

8. Can ADO to Oracle do this?

9. default values; assigning constant values in XDR Schemas

10. current value of default value in column?

11. simulating INSERT return values with default values of sequences

12. simulating INSERT return values with default values

13. Query returning value or default value