SQL Apprentice Question
I'm trying to create several insert statements in a stored procedures
as in below, but it will insert the reocrds sequentially and i want the
stored procedures to populate the fields that are parrallel. I also tried
set rowcount 0 - it didn't accept that and I don't know how to use the
this like "set Count_H = exec LOE_H_Counts" and it didn't work.
Does anybody know how I can call a stored procedure in an UPDATE clause or
if there is another way to get around this?
Thank you so much for your time!
CREATE Procedure LOE_Counts
create table #tempLOE( Status varchar(50) ,Type varchar (50) ,
Count_H int, Count_M int, Count_L int, Count_Total int)
insert #tempLOE(id, Status, TYPE, Count_Total)
select * from #tempLOE
>>I'm trying to create several insert statements in a stored procedures
as in below, but it will insert the records [sic] sequentially and i
stored procedures to populate the fields [sic] that are parrallel
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files; there is no sequential access or
ordering in an RDBMS, so "first", "next" and "last" are totally
meaningless. If you want an ordering, then you need to have a column
that defines that ordering. You must use an ORDER BY clause on a
cursor or in an OVER() clause.
In SQL, the INSERT, UPDATE and DELETE statements work on rows as a
unit. This is not a file system, wher you can move a read/write head
to a field and do your work. This is what happens when you use the
I will not even get into the vagueness of "id", "type" and "status" as
attempts at data element names.
Next, good SQL programmers avoid UDF and procedural code. That is 3GL
programming and not declarative coding.