• Welcome, Guest. Please login.
 
May 11, 2021, 09:23:48 PM

News:

Welcome to the SQLitening support forums!


Getting RowCount Result

Started by R Robinson, June 17, 2010, 02:22:55 PM

Previous topic - Next topic

R Robinson

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")