Sie sind auf Seite 1von 9

******************************************************************************************

uaLabase luncLlons llbrary



******************************************************************************************

db_connecL



1he funcLlon creaLes a new connecLlon sesslon Lo a daLabase

curSesslon 1he sesslon name (sLrlng)

connecLlon_sLrlng A connecLlon sLrlng

for example Lhe connecLlon_sLrlng can be uSnSCLServer_SourceuluSAWuabc123

******************************************************************************************

luncLlon db_connecL( by8ef curSesslon connecLlon_sLrlng)

dlm connecLlon

on error 8esume nexL

Cpenlng connecLlon

seL connecLlon CreaLeCb[ecL(AuCu8ConnecLlon)

lf Lrrnumber 0 Lhen

db_connecL Lrror # CSLr(Lrrnumber) LrruescrlpLlon

errclear

LxlL luncLlon

Lnd lf

connecLlonCpen connecLlon_sLrlng

lf Lrrnumber 0 Lhen

db_connecL Lrror # CSLr(Lrrnumber) LrruescrlpLlon

errclear

LxlL luncLlon

Lnd lf

seL curSesslonconnecLlon

db_connecL0

Lnd luncLlon

******************************************************************************************

db_dlsconnecL



1he funcLlon dlsconnecLs from Lhe daLabase and deleLes Lhe sesslon

curSesslon Lhe sesslon name (sLrlng)

******************************************************************************************

luncLlon db_dlsconnecL( by8ef curSesslon )

curSesslonclose

seL curSesslon noLhlng

Lnd luncLlon

******************************************************************************************

db_execuLe_query



1he funcLlon execuLes an SCL sLaLemenL

noLe LhaL a db_connecL for (arg1) musL be called before Lhls funcLlon

curSesslon 1he sesslon name (sLrlng)

SCL An SCL sLaLemenL

******************************************************************************************

luncLlon db_execuLe_query ( by8ef curSesslon SCL)

seL rs curSesslonLxecuLe( SCL )

seL db_execuLe_query rs

Lnd luncLlon

******************************************************************************************

db_geL_rows_counL



1he funcLlon reLurns Lhe number of rows ln Lhe record seL

cur8S varlable conLalnlng a record seL LhaL conLalns all values LhaL reLrleved from Lhe daLabase by query execuLlon

******************************************************************************************

luncLlon db_geL_rows_counL( by8ef cur8S )

dlm rows

rows 0

cur8SMovellrsL

uo unLll cur8SLCl

rows rows+1

cur8SMovenexL

Loop

db_geL_rows_counL rows

Lnd luncLlon

******************************************************************************************

db_geL_rows_counL_SCL



1he funcLlon reLurns Lhe number of rows LhaL are Lhe resulL of a glven SCL sLaLemenL

curSesslon 1he sesslon name (sLrlng)

CounLSCL SCL sLaLemenL

******************************************************************************************

luncLlon db_geL_rows_counL_SCL( by8ef curSesslon CounLSCL )

dlm cur_rs

seL cur_rs curSesslonLxecuLe( CounLSCL )

db_geL_rows_counL_SCL cur_rsflelds(0)value

Lnd luncLlon

******************************************************************************************

db_geL_fleld_value_SCL



curSesslon varlable LhaL denoLes Lhe currenL acLlve connecLlon

Lablename name of Lhe Lable from whlch Lhe value should be reLrleved

rowlndex 8ow number

colname 1he column name

******************************************************************************************

luncLlon db_geL_fleld_value_SCL( curSesslon Lablename rowlndex colname )

dlm rs

SCL selecL colname from Lablename

seL rs curSesslonLxecuLe( SCL )

rsmove rowlndex

db_geL_fleld_value_SCL rsflelds(colname)value

Lnd luncLlon

******************************************************************************************

db_geL_fleld_value



1he funcLlon reLurns Lhe value of a slngle lLem of an execuLed query

noLe LhaL a db_execuLe_query for (arg1) musL called before Lhls funcLlon

cur8ecordSeL varlable conLalnlng a record seL LhaL conLalns all values reLrleved from Lhe daLabase by query execuLlon

rowlndex 1he row lndex number (zerobased)

collndex 1he column lndex number (zerobased) or Lhe column name

reLurned values

1 8equesLed fleld lndex more Lhan exlsLs more Lhan once ln record seL

******************************************************************************************

luncLlon db_geL_fleld_value( cur8ecordSeL rowlndex collndex )

dlm cur8ow

cur8ecordSeLMovellrsL

counL_flelds cur8ecordSeLfleldscounL1

lf ( 1ypename(collndex) SLrlng ) and ( counL_flelds collndex ) Lhen

db_geL_fleld_value 1 requesLed fleld lndex exlsLs more Lhan once ln recordseL

Llse

cur8ecordSeLMove rowlndex

db_geL_fleld_value cur8ecordSeLflelds(collndex)value

Lnd lf

Lnd luncLlon

******************************************************************************************

db_seL_fleld_value



1he funcLlon changes Lhe value of a fleld accordlng Lo a search crlLerla

We search for a cerLaln row accordlng Lo a column name and Lhe deslred vale Lhen we change a value ln LhaL row accordlng

Lo a deslred columns

curConnecLlon 1he sesslon name (sLrlng)

Lablename name of Lhe Lable from whlch Lhe value should be reLrleved

colllnd 1he column whlch Lo search for Lhe crlLerla

colllndvalue 1he value for whlch Lo search ln Lhe column

colChange 1he column ln whlch we wanL Lo change Lhe value

colChangevalue 1he new value

reLurned values

1 8equesLed fleld lndex LhaL does noL exlsL ln Lhe recordseL

******************************************************************************************

luncLlon db_seL_fleld_value(curConnecLlon Lablename colllnd colllndvalue colChange colChangevalue)

dlm cur8ow

dlm updaLeSCL

dlm checkSCL

checkSCL selecL * from ueLalls

seL myrs1 db_execuLe_query( curConnecLlon SCL )

myrs1MovellrsL

counL_flelds myrs1fleldscounL

lf ( 1ypename(colllnd) SLrlng ) or ( 1ypename(colChange) SLrlng ) Lhen

db_seL_fleld_value 1 requesLed fleld lndex LhaL does noL exlsLs ln Lhe record seL

Llse

updaLeSCL uuA1L Lablename SL1 colChange colChangevalue WPL8L colllnd
colllndvalue

seL myrs1 db_execuLe_query( curConnecLlon updaLeSCL )

db_seL_fleld_value 1 operaLlon suceeded

Lnd lf

Lnd luncLlon

******************************************************************************************

db_add_row



1he funcLlon adds a new row Lo Lhe deslred Lable

curConnecLlon varlable conLalnlng a recordseL LhaL conLalns all Lhe values Lo be reLrleved from Lhe daLabase by query
execuLlon

Lablename name of Lhe Lable from whlch Lhe value should be reLrleved

values Array LhaL conLalns values Lo be enLered ln a new row Lo Lhe Lable

noLe 1he funcLlon musL recelve values for all Lhe columns ln Lhe Lable

reLurned value

1 1he number of values Lo be enLered Lo Lhe Lable does noL maLch Lhe number of columns

1 LxecuLlon of Lhe query succeed and Lhe daLa was enLered Lo Lhe Lable

******************************************************************************************

luncLlon db_add_row(curConnecLlon Lablename by8ef values)

dlm l

dlm updaLeSCL

dlm myrs1

updaLeSCL lnSL81 ln1C Lablename vALuLS (

arrLen u8ound (values) L8ound (values) + 1

seL myrs1db_execuLe_query( curConnecLlon SCL )

myrs1MovellrsL

counL_flelds myrs1fleldscounL

Check wheLher Lhe number of values maLch Lhe number of columns

lf arrLen counL_flelds Lhen

db_add_row 1

Llse

lor l 0 Lo arrLen1

updaLeSCL updaLeSCL values (l)

lf l arrLen1 Lhen

updaLeSCL updaLeSCL

Lnd lf

nexL

updaLeSCL updaLeSCL )

seL myrs1 db_execuLe_query( curConnecLlon updaLeSCL )

db_add_row 1

Lnd lf

Lnd luncLlon

******************************************************************************************

represenL_values_of_8ecordSeL



1he funcLlon reporLs all Lhe values of flelds ln a record seL

cur8S varlable conLalnlng Lhe recordseL LhaL conLalns all Lhe values LhaL were reLrleved from Lhe daLabase by Lhe query
execuLlon

******************************************************************************************

luncLlon represenL_values_of_8ecordSeL( myrs)

dlm cur8owSLrlng

myrsMovellrsL

reporLer8eporLLvenL 4llelds quanLlLy myrsfleldscounL

counL_flelds myrsfleldscounL1

cur8ow0

uo unLll myrsLCl

cur8owSLrlng

cur8ow cur8ow+1

lor ll0 Lo counL_flelds

cur8owSLrlng cur8owSLrlng lleld myrsflelds(ll)name value myrsflelds(ll)value
vbCrLf

nexL

myrsMovenexL

reporLer8eporLLvenL 4CurrenL row cur8ow cur8owSLrlng

Loop

Lnd luncLlon

Das könnte Ihnen auch gefallen