SQLitening Support Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the SQLitening support forums!

Pages: [1] 2 3 ... 10
 1 
 on: Today at 09:28:32 PM 
Started by Fredrick Ughimi - Last post by cj
'MaxConnections = Number ---  Controls the number OF concurrent connections. DEFAULT IS zero which will allow
'                                   an unlimited number OR connections. MAX IS 65535.

I have only tested using threads and second connection fails as expected.
MaxConnections=1
Code: [Select]
GLOBAL gConnectCount AS LONG
%MaxConnections = 2
$Host = "192.168.0.2" 'change to server ip
%Port = 51234         'change to listening port
#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG
 LOCAL x,hThread AS LONG
 FOR x = 1 TO %MaxConnections
  THREAD CREATE ConnectHere(0) TO hThread
  THREAD CLOSE hThread TO hThread
  SLEEP 50
 NEXT
 SLEEP 2000
 ? USING$("gConnectCount #",gConnectCount),%MB_SYSTEMMODAL
END FUNCTION
THREAD FUNCTION ConnectHere(BYVAL notused AS LONG) AS LONG
 slconnect $Host,%Port,"E2"
 IF slGetErrorNumber = 0 THEN INCR gConnectCount
 SLEEP 30000
END FUNCTION

 2 
 on: Today at 07:36:18 PM 
Started by Fredrick Ughimi - Last post by cj
>slEXE "insert into t1 values(" + sSubject  + ") on conflict(c1) do nothing"
  slEXE "insert into t1 values('" + sSubject + "') on conflict(c1) do nothing"

Attempt 20 inserts
#INCLUDE "sqlitening.inc"

FUNCTION PBMAIN () AS LONG
 LOCAL x,duplicates AS LONG
 slOpen "junk.db3","C"
 slexe "drop table if exists t1"
 slexe "create table if not exists t1(c1 unique)"

 FOR x = 1 TO 10
  slEXE "insert into t1 values('Maths')","E0"                       'ignore error
  IF slGetChangeCount = 0 THEN INCR duplicates

  slEXE "insert into t1 values('Maths') on conflict(c1) do nothing" 'or upsert
  IF slGetChangeCount = 0 THEN INCR duplicates
 NEXT

 Viewer "select rowid,* from t1",duplicates

END FUNCTION

SUB Viewer(sql AS STRING,duplicates AS LONG)
 LOCAL sArray() AS STRING
 slSelAry sql,sArray(),"Q9"
 ? sql + $CR + JOIN$(sArray(),$CR),%MB_SYSTEMMODAL,"Duplicates" + STR$(duplicates)
END SUB


 3 
 on: Today at 05:01:56 PM 
Started by Fredrick Ughimi - Last post by Fredrick Ughimi
Hello Bern,

Thank you for your response. i tried some other options except except the one you provided.

Now I get a new error:


 4 
 on: Today at 04:30:54 PM 
Started by Fredrick Ughimi - Last post by Bern Ertl
slEXE "insert into t1 values(" + sSubject + ") on conflict(c1) do nothing"

 5 
 on: Today at 09:37:50 AM 
Started by Fredrick Ughimi - Last post by Fredrick Ughimi
Hello,

Has anyone used the MaxConnections in the SqliteningServer settings to a good effect. I assume the MaxConnections is equal to total number of systems on the network including the server using the application.

I have this scenario:

1. Total Computers on the network (including the server) = 5
2. MaxConnections=5
3. Actual Connections = 4 (I get maximum connection exceeded error) *


*I noticed that if there are just 4 computers connected and using the application. I get maximum connection exceeded error.

Note: I made sure no multiple instances of the application is allowed to run on a system.

Has anyone experience this before?

Best regards,

 6 
 on: Today at 09:25:08 AM 
Started by Fredrick Ughimi - Last post by Fredrick Ughimi
Hello,

I am trying my hands on the new UPSERT and I am having issues trying to use a string variable to represent my value.

Code: [Select]
#COMPILE EXE
#DIM ALL

#INCLUDE "sqlitening.inc"

FUNCTION PBMAIN () AS LONG
 LOCAL sSubject AS STRING
 slOpen "junk.db3","C"
 slexe "drop table if exists t1"
 slexe "create table if not exists t1(c1 unique)"
 sSubject = "Maths"

 slEXE "insert into t1 values(sSubject) on conflict(c1) do nothing"

END FUNCTION         


Any push in the right direction would be very much appreciated.

Best regards.



 7 
 on: August 15, 2018, 02:20:21 AM 
Started by Scott Slater - Last post by cj
To display integers as money
select rowid,printf('%.2f',price*.01) as price,product from parts

 8 
 on: August 07, 2018, 10:44:21 AM 
Started by Fim - Last post by cj
Is this thread closed?

Quote
Yes my intention is to pull the MIN and MAX values from a range of rows using SQL, but how?

/Fim W


select min(temperature), max(temperature) from MyTable Where ......

Have no idea what the range of records is.  By year?  Between two dates?
Do you only want a 1-line recordset containing the lowest and highest temperature?

This is an example of getting lowest and highest temperature for any year and restricts temperature within a range.

REM $Now = "datetime('now','localtime')"  'minmax.bas
#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG
 LOCAL year,temperature,LowTemp,HighTemp AS SINGLE
 LOCAL sql AS STRING
 slOpen "junk.db3","C
 slexe "drop table if exists t1"
 slexe "create table if not exists t1(Date,temperature INTEGER)"

 'insert temperatures in 2017 and 2018
 FOR temperature = 1 TO 10
  InsertRecord "2017-01-02",temperature + 50  'insert temperatures 51 to 60 in 2017
  InsertRecord "2018-12-31",temperature       'insert termeratures 1  to 10 in 2018
 NEXT

 'show everything
 sql = "select rowid,* from t1 order by date"
 Viewer sql

 'search restricting to this range
 Year = 2018
 LowTemp  = 1  'probably don't need this
 HighTemp = 10 'probably dont't need this

 sql = "select min(temperature) AS MIN, max(temperature) AS MAX from t1 " +_
       "where strftime('%Y',Date) ='" + FORMAT$(Year) + "' and temperature between "+FORMAT$(LowTemp) + " and " + FORMAT$(HighTemp)

 Viewer sql
END FUNCTION

FUNCTION InsertRecord(sDate AS STRING,temperature AS SINGLE) AS LONG
 LOCAL s AS STRING
 s = "insert into t1 values('" + sDate + "'," + FORMAT$(temperature) + ")"
 slexe s
END FUNCTION

FUNCTION Viewer(sql AS STRING) AS STRING
 DIM sArray() AS STRING
 slSelAry sql,sArray(),"Q9"
 ? sql + STRING$(2,$CR) + JOIN$(sArray(),$CR),%MB_SYSTEMMODAL,FUNCNAME$
END FUNCTION

 9 
 on: August 06, 2018, 11:15:13 AM 
Started by Fim - Last post by Fim
Yes my intention is to pull the MIN and MAX values from a range of rows using SQL, but how?

/Fim W

 10 
 on: August 06, 2018, 08:50:15 AM 
Started by Fim - Last post by cj
I'd have to understand the question better so I flunk this test.

MIN_MAX_START:
    TEMP_MIN = 100
    TEMP_MAX = -100

MIN_MAX_SELECT:
    SQL_SATS = "SELECT TEMP FROM TEMPERATUR WHERE DATE LIKE " + $SQ + 2017% +$SQ
    slSel(SQL_SATS)

MIN_MAX_READING:
    IF slGetRow = 0 THEN EXIT FUNCTION
    TEMP_=  VAL(slFN("TEMP" ))

MIN_OCH_MAX_LAGRING:
    TEMP_MAX = MAX(TEMP_MAX, TEMP)
    TEMP_MIN = MIN(TEMP_MIN, TEMP)
    GOTO MIN_MAX_READING

Pages: [1] 2 3 ... 10