i 've made some dislocations with creating a demo though
You need to have an Ms-SQL instance
I have a ms-sql200k herre (old but running)
creating tables with MS-Databasemanager , isql or something like that
f.i. you find the cool
DbaMgr2k (0.21.1) (uses ado/ sql-dmo) somewhere in the depths of the net
Code: Select all
CREATE TABLE zz_test_b (
"id" int identity NOT NULL PRIMARY KEY,
"b_no" int,
"r_name" varchar(255),
)
GO
CREATE UNIQUE INDEX b_no ON dbo.zz_test_b(b_no)
GO
create table zz_test_a(
"id" int identity NOT NULL PRIMARY KEY,
"a_no" int,
"a_title" varchar(50) NOT NULL,
"a_name" varchar(1024) NOT NULL,
"a_callnumber" varchar(50),
"a_b_no" int
)
Go
CREATE UNIQUE INDEX a_idx_a_no ON dbo.zz_test_a(a_no)
GO
CREATE TABLE zz_test_ac (
"id" bigint identity NOT NULL PRIMARY KEY,
"call_ni" varchar(50),
"ac_state" bit,
"ac_planned" bit,
"ac_last" bit,
"ac_dt" datetime,
"ac_b_no" int,
"ac_type" int,
"ac_noduty" bit,
"ac_changesource" int,
"ac_changedt" datetime,
"ac_change_a_no" int,
"ac_destcallno" varchar(50),
"ac_dest_a_no" int,
"ac_officeon" datetime,
"ac_officeoff" datetime,
"acd" bit,
"ac_dest_a_no_2" int,
"ac_dest_call_no_2" varchar(50)
)
GO
the stored_procedure (installed with the same tool like above)
Code: Select all
CREATE PROCEDURE _getitnow AS
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmpitab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tmpitab];
create table tmpitab (
ac_dt datetime,
a_title varchar(50),
a_name varchar(50),
a_no int,
a_b_no int,
b_no int,
r_name varchar(50),
ac_b_no int,
ac_dest_a_no int)
declare @tmpb as integer
declare tmpc CURSOR FOR (select b_no from zz_test_b)
open tmpc;
Fetch NEXT From tmpc Into @tmpb;
While @@FETCH_STATUS=0
BEGIN
insert into tmpitab
select top 1 ac.ac_dt,a.a_title,a.a_name,a.a_no,a.a_b_no,b.b_no,b.r_name,ac.ac_b_no,ac.ac_dest_a_no
from zz_test_a a left join zz_test_b b on a.a_b_no=b.b_no
left join zz_test_ac ac on a.a_no=ac.ac_dest_a_no
where b.b_no=@tmpb
and ac.ac_dt>getdate()
order by ac.ac_dt
Fetch NEXT From tmpc Into @tmpb;
END
CLOSE tmpc;
DEALLOCATE tmpc;
GO
now create an odbcconnection to the db and table
fill databases now purebasic-Code (takes some
time, i can't speed it up because my db is hot)
Code: Select all
UseODBCDatabase()
odbc_db.s="mydb" ;your odbcconnection here
odbc_user.s="user" ;your odbcconnection here
odbc_pass.s="pass" ;your odbcconnection here
OpenDatabase(0,odbc_db,odbc_user,odbc_pass,#PB_Database_ODBC)
;acs
For i=1 To 150000
d=Date()+Random(100000)+45000
out.s+"insert into zz_test_ac values ('hnyuv_ntxwm_',1,0,0,'"+FormatDate("%hh:%ii %dd.%mm.%yyyy",d)+"',"+Str(Random(499)+1)+",1,0,9,'15:00 15.10.2013',999001,'0123 012345"+Str(i)+"',"+Str(Random(3000)+4500)+",NULL,NULL,1,NULL,NULL);"
ii+1
If ii>400 ;some collecting to speed it up
Debug i
ii=0
DatabaseUpdate(0,out)
try.s= DatabaseError()
If tryold.s<>try
Debug try
EndIf
tryold.s=try
out.s=""
EndIf
Next i
DatabaseUpdate(0,out)
Debug DatabaseError()
;regs
For i=1 To 500
out.s="insert into zz_test_b values ("+Str(i)+",'bezreg_"+Str(i)+"');"
DatabaseUpdate(0,out)
try.s= DatabaseError()
If tryold.s<>try
Debug try
EndIf
tryold.s=try
Next i
;zoppos
For i=1 To 15000
out.s="insert into zz_test_a values ("+Str(i+4500)+",'title_"+Str(i)+"','name_"+Str(i)+"','01234 5678910',"+Str(Random(499)+1)+");"
DatabaseUpdate(0,out)
try.s= DatabaseError()
If tryold.s<>try
Debug try
EndIf
tryold.s=try
Next i
CloseDatabase(0)
End
when calling the stored_procedure with the follwing code out of PB
Code: Select all
UseODBCDatabase()
odbc_db.s="mydb" ;your odbcconnection here
odbc_user.s="user" ;your odbcconnection here
odbc_pass.s="pass" ;your odbcconnection here
OpenDatabase(0,odbc_db,odbc_user,odbc_pass,#PB_Database_ODBC)
SQL$ = "_getitnow"
DatabaseQuery(0,SQL$) ; databaseupdate doesn't change the resultset
While NextDatabaseRow(0)
Debug "ui"
Wend
FinishDatabaseQuery(0)
CloseDatabase(0)
it results 91 Lines and that is wrong
When calling the stored_proc with pb and adomate or the tool above it results in 500 lines (witch seems to be correct)