In Lasso we use [Inline] tags to interact with the database and usually read all the records by looping through the found set using [Records]….[/Records] tag. Instead of looping through the [Records] tag one can use [Records_Array] or [Records_Map] to fetch the database records from the [Inline] tag and store them in an Array or Map variable respectively.
Reading the records inside the [Records]….[/Records] tag will keep the database connection open as long as all the records in the found set are fetched and processed. This may return an error, “Maximum number of database sessions exceeded” to other users accessing the database at same time when when the database server has limited user access. This mainly occurs when the found set is large or if there are a lot of lasso codes to be processed for each record.
It’s better to fetch all the records at one step and store them in an Array or Map and close the database connection immediately after storing all the data in Array or Map.
Later in the program we can loop through the Array/Map to get the field values in each record process each record. This way it will not open/hold the database connection for a long period of time and other users can have access to the same database at the same time as well.
Var(´recordSet') = (Map);
Inline( -Database=$DBName, -Table=$tableName, $findParameters, -MaxRecords=all); //Database connection opened
If( Found_Count > 0 );
$recordSet = (Records_Map); //Get all the field name/value pairs for all the records in a map
/Inline; //Database connection closed
$recordSet->Get(Loop_Count)->Second->Find('<Field Name>'); //Get the field value of the specified <Field Name>