Class CODBDEPOSITORY

Name

CODBDEPOSITORY  --  The essence this CODB class is storehouse of stored objects - objects whouse structure descript into dictionary.

Synopsis

 coDepositioryNew(<sDictID>, <sUser>, <sPasswd>) --> CODBDEPOSITORY object
 coDepository:New(<sDictID>, <sUser>, <sPasswd>)  --> CODBDEPOSITORY object

Description

The essence this CODB class is storehouse of stored objects - objects whouse structure descript into dictionary.

Attributes

<ClassName> CODBDEPOSITORY
<Error> String, the error description what araised within running last operation.

Methods

APPEND Append object to storehouse.
CHECKBODY Checks object a valid class.
CLOSE Close opened files.
CREATE Create empty depository.
DELETE Delete object from storehouse.
GETVALUE Get object from storehouse.
ID4PRIMARYKEY Returns object identifier.
IDLIST Returns object of class IDLIST.
NEW Initiation new CODBDEPOSITORY object.
OPEN Open all necessary files.
PADRBODY Makes data representation.
SELECT Returns identifier list of selected objects.
UPDATE Update object into storehouse.

Method CODBDEPOSITORY:APPEND()

 Append(<oData>, <sClassID>) 	--> <sDataID>

Append() appends new object <oData> to storehouse as object of class <sClassID> and returns objects identifier <sDataID>.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:CHECKBODY()

 CheckBody(<oData>, <sClassID>) 	--> <oData>

CheckBody() checks object <oData> a valid class <sClassID>. If object is a valid, CheckBody() fills <oData> properties the default values if necessary.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:CLOSE()

 Close() 	--> TRUE || FALSE

Close() is close files or connection with SQL server.

Method CODBDEPOSITORY:CREATE()

 Create() 	--> TRUE || FALSE

Create() returns TRUE if new empty depository created. Usualy, this method do not needy to direct invitation. It's call automaticaly when new depository appending to CODBDICTIONARY.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:DELETE()

 Delete(<sDataID>) 	--> TRUE || FALSE

Delete() deletes object with identifier <sDataID> from depository.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:GETVALUE()

 GetValue(<sDataID>) 	--> <oData>

GetValue() gets form depository and returns object <oData> with identifier <sDataID>.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:ID4PRIMARYKEY()

 Id4PrimaryKey(<sClassName>, <sKeyName>, <KeyValue>) 	--> <sDataID>

Id4ProperyKey() returns <sDataID> - identifier of founded object whouse properties with name <sKeyName> is equal <KeyValue>.

Method CODBDEPOSITORY:IDLIST()

 IdList(<sClassID>[, <nOrder>][, <sName>][, <sWhere>]) 	--> <oIDList>

IdList() returns <oIDList> - object of class CODBIDLIST.

Method CODBDEPOSITORY:NEW()

 New(<sDepID>, <sUser>, <sPasswd>) --> CODBDEPOSITORY object

New() inits new CODBDEPOSITORY object and returns it.

If object <sDepID> already exist, New() openes and returns this ddepository.

Method CODBDEPOSITORY:OPEN()

 Open() 	--> TRUE || FALSE

Open() openes all necessary files or openes connection with SQL server.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:PADRBODY()

 PadrBody(<oData>, <sClassID>) 	--> <oData>

PadrBody() makes data representation for <oData> to class <sClassID>.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:SELECT()

 Select(<sClassID>[, <nOrder>][, <sName>][, <sWhere>]) 	--> <aIdent>

Select() returns for class <sClassID> identifier list <aIdent> selected objects in order <nOrder> whose attribute <Name> == <sName> and attributes equal <sWhere>.

<::Error> contain error descriptions if araised.

Method CODBDEPOSITORY:UPDATE()

 Update(<oData>) 	--> TRUE || FALSE

Update() updates object <oData> into storehouse. If depositoy have not object with identifier <oData:ID>, Update() returns FALSE.

<::Error> contain error descriptions if araised.

Example:

 * open first depository from MY001
 oDep:=coDepository():new("MY00101")
 oDep:open()
 oDict:=oDep:dictionary()
 * get currency metadata
 currBody:=oDict:classBodyByName("currency")
 if empty(currBody)
 ? "Class 'currency' not found in dictionary"
 quit
 endif
 *this data may be load from txt or dbf source file
 data:={;
 {"USD","USA dollar"},;
 {"UUU","UUU dollar"},;
 {"RUR","Russian rubl"},;
 {"RUA","Ukraina rubl :)"};
 }
 * add currency objects
 for i=1 to len(data)
 obj:=map()
 obj:code := data[i][1]
 obj:name := data[i][2]
 obj_id := oDep:id4primaryKey("currency","code",obj:code)
 if empty(obj_id)
 oDep:append(obj,currBody:id)
 else
 /* object exist in depository */
 obj:id := obj_id
 oDep:update(obj)
 endif
 if !empty(oDep:error)
 ? "Error:",oDep:error
 else
 ? "currency object '"+obj:code+"' added to depository"
 endif
 next
 ? "To depository added ",len(data)," objects"
 c_list:=oDep:select(currBody:id,,,'code="U"')
 ? "Select currency objects with code='U':",c_list
 c_list:=oDep:select(currBody:id)
 ? "Select all currency objects:",c_list
 ? "Loading objects body:"
 for i=1 to len(c_list)
 obj:=oDep:getValue(c_list[i])
 ? "code=",obj:code, "name=",obj:name
 next
 

See also

CODBLIST

Platforms

No dependies of platform.