If I use this in interactive it works:
declare @time1 time
declare @Time2 time
declare @time3 time
select
@time1 = t_time1,
@Time2 = t_time2,
@time3 = t_time3
from
tblTimes
select @time1, @Time2, @time3
But if I try to use it in a procedure I get error on the declares:
declare @time1 time;
declare @Time2 time;
declare @time3 time;
select
@time1 = t_time1,
@Time2 = t_time2,
@time3 = t_time3
from
tblTimes;
So my question is how I do this in the best way in a procedure?
Request clarification before answering.
The "select @time1 = t_time1" is written using Transact SQL, so the procedure will have to be written using Transact SQL as well...
CREATE PROCEDURE p AS
declare @time1 time
declare @time2 time
declare @time3 time
select
@time1 = t_time1,
@time2 = t_time2,
@time3 = t_time3
from
tblTimes
select @time1, @time2, @time3
go
SELECT * FROM p()
go
If you want to use Watcom SQL (highly recommended!) then use the INTO clause...
CREATE PROCEDURE q()
BEGIN
declare @time1 time;
declare @time2 time;
declare @time3 time;
select
t_time1, t_time2, t_time3
into
@time1, @time2, @time3
from
tblTimes;
select
@time1, @time2, @time3;
END;
SELECT * FROM q();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.