#Define crlf Chr(13) + Chr(10)

Local lcColoane, lcVals, lcAdresa, lcTabela, lcTable, nr, i, lnSucces, lcSql
External Array lacols
lcColoane = []
lcVals = []
lnSucces = 0
lctabela = UPPER([xitems])

gnconn = SQLConnect([jcsserver],[test_alex],[123])
If gnconn < 0
	Return
Endif


lcsql = [select * from user_tab_columns where table_name = '] + lctabela + [']
executasql(lcsql,'crsColoane',.t.)
lcsql = []
SELECT crscoloane
SCAN
	lcsql =lcsql + ALLTRIM(column_name) + [= TRIM(] + ALLTRIM(column_name) + [),]
ENDSCAN
lcsql = [update ] + lctabela + [ set ] + LEFT(lcsql,LEN(lcsql) - 1)
executasql(lcsql,'',.t.)

**********************************************************
Function executaSql
	Lparameters cmdSql, crsName, tlShowErr
	Local lnSucces

	lnSucces = -1

	If Pcount() < 2 And !m.tlShowErr
		crsName=""
	Endif

	If gnconn > 0
		lnSucces = SQLExec(gnconn,cmdSql,crsName)

		If lnSucces < 0 And m.tlShowErr
			Aerror(laEroare)
			eroaresql(@laEroare,cmdSql)
		Endif
	Endif

	Return lnSucces
Endfunc

**********************************************************
Procedure eroaresql
	Lparameters laErr, lcSql

	External Array laErr
	Local lcMesaj

	lcMesaj = [Eroare # : ] + Alltrim(Str(laErr(1))) + crlf + ;
		[Mesajul : ] + laErr(2) + ;
		IIF(!Empty(laErr(3)), [Eroare OLE : ] + laErr(3) ,[]) + ;
		[Aplicatie : ] + laErr(4) + ;
		IIF(Pcount() = 2, crlf + lcSql, [])
	Messagebox(lcMesaj,0+16)
Endproc
