mysql how is possible look if query is going ok or not?

13 views
Skip to first unread message

stefano cerbioni

unread,
Jul 25, 2022, 8:59:36 AMJul 25
to The Ring Programming Language
hi  fellows , i remember ..probably we  just talk about this  but not  find  in email sorry again
how is possible verify if command mysql_query is  going   ok  or not?? 
my code

func SelectDBinance (sTableName,Column,IDFind,iGear) {
con = mysql_init()
if mysql_connect(con, aDataDB[1], aDataDB[2], aDataDB[3],aDataDB[4]) = 0
system_error(con)
ok
if iGear = 0
// return a name of column inside of table
mysql_query(con, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '"+sTableName+"'")
// system_error(con)
ok
if iGear = 1
//return last ID in table
//? "SELECT max(id) as id FROM "+sTableName
mysql_query(con, "SELECT max(id) as id FROM "+sTableName)
// system_error(con)
ok
if iGear = 2
// return all from table
mysql_query(con, "SELECT * FROM "+sTableName)//" WHERE ID = 1")
ok
if iGear = 3
// return column from table
mysql_query(con, "SELECT "+Column+" FROM "+sTableName)//" WHERE ID = 1")
ok
if iGear = 4
// return difference from 2 table
// use this model: SELECT OpenOrderTemp.orderid FROM OpenOrderTemp WHERE OpenOrderTemp.orderid NOT IN ( SELECT OpenOrder.orderId FROM OpenOrder WHERE OpenOrder.orderId IS NOT NULL);
// syntax.....: SelectDBinance("OpenOrderTemp|OpenOrder","orderid",4) only 2 table and only one column
aListTable = split(sTableName, "|")
//? ("SELECT "+aListTable[1]+"."+Column+" FROM "+aListTable[1]+" WHERE "+aListTable[1]+"."+Column+" NOT IN ( SELECT "+ aListTable[2]+"."+Column+" FROM "+aListTable[2]+" WHERE "+aListTable[2]+"."+Column+" IS NOT NULL)")
mysql_query(con, "SELECT "+aListTable[1]+"."+Column+" FROM "+aListTable[1]+" WHERE "+aListTable[1]+"."+Column+" NOT IN ( SELECT "+ aListTable[2]+"."+Column+" FROM "+aListTable[2]+" WHERE "+aListTable[2]+"."+Column+" IS NOT NULL)")
ok
if iGear = 5
// return data row from table where column is equal to ....
//? ("SELECT * FROM "+sTableName+" WHERE "+Column+" = "+ IDFind)
mysql_query(con, "SELECT * FROM "+sTableName+" WHERE "+Column+" = "+IDFind)
ok
if iGear = 6
// return records without duplicate on just one field in SQL and without empty record
//SELECT DISTINCT title,id FROM tbl_countries
mysql_query(con, "SELECT DISTINCT "+Column+" FROM "+sTableName+ " WHERE "+Column+" IS NOT NULL AND "+Column+" <> ''" )
ok
infoTable = mysql_result(con)
//see "Close connection" + nl
mysql_close(con)
// 4 debug *****************
//for i=1 to Len(infoTable)
//see infoTable[i]
//next
//**************************
return infoTable
}
Reply all
Reply to author
Forward
0 new messages