• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - R Robinson

#1
Been reading a bit on here and see where people have different ways to return the number of rows from a select statement. Maybe this will help someone who is struggling with SQL syntax

Here is another technique: We use this as the temp view created is based upon login name, gives each person a view of the data, and is updated as main tables are updated.

Keep in mind you can not insert, delete, or Update rows in views.

Two Subs slCreateView and slDropView, you would first check to see if view already exists

SUB slCreateView(TempView AS STRING, slSelect AS STRING)
   LOCAL slCmd AS STRING
      slcmd = "Create View [" & TempView & "] as " & slSelect
      slEXE(slcmd)
END SUB

SUB slDropView(TempView AS STRING)
    LOCAL slCMD AS STRING
      slCmd = "Drop View [" & TempView & "]"
      slexe(slcmd)
END SUB


Getting the Rowcount for a select statement, once view is created you just use Select * or you can further limit your returns.


slCMD = "Select distinct sfolder from tdrive"
      slCreateView("RRR.TEMP", slCMD)
      slCMD = "Select count(*) as RowCount from [RRR.Temp]"
      slsel(slcmd)
      slgetrow
            Rec = slFn("RowCount")  <- you can return as val
'whatever else you need to do with this data
    slDropView("RRR.TEMP")
#2
Mass importing around 6 Million records, each containing no more the 1024 Bytes of information, what should the expectation be?

Working Remote server is XP 64-bit, 1GB network connection 8GB RAM, I am on same subnet and switch.
Local Client Win7 32-bit PBWin9, 1GB NIC

Local mode test imported (5,923,186 records) in 5m30s minutes (impressive)
Remote mode is taking 4m22s for 50,000 records (bulk of time is spent in the For/Next loop)

'Routine that creates this file takes approx. 4 hours to run, it will call this routine when complete
'Temp location/filename for now location will be moved
OPEN "C:\AllTFiles.txt" FOR INPUT AS #1
'how many records are we dealing with (5,923,186 in this recordset)
FILESCAN #1, RECORDS TO RecCount
'****testing purposes limit records****
RecCount = 50000

  DIM FileData(1 TO RecCount) AS STRING
LINE INPUT #1, FileData() TO RecCount
CLOSE #1 'Taking 28 seconds to get to here
SLEXE "BEGIN IMMEDIATE TRANSACTION"
   FOR CurRec = 1 TO RecCount
      slcmd = "INSERT into TDrive(sFolder, sFile) values (""" & PATHNAME$(PATH,FileData(curRec)) + """ , """ + _
               PATHNAME$(NAMEX, Filedata(CurRec)) + """)"
      slexe(slcmd)
   NEXT '3m54s for this to run with 50000 limit
slexe "END TRANSACTION"