Lasso Soft Inc. > Home

[lp_inline_dataset]

Linklp_inline_dataset
AuthorBil Corry
CategoryDatabase
Version8.x
LicensePublic Domain
Posted21 Apr 2006
Updated17 May 2006
More by this author...

Description

Records abstraction type.  See example for usage.

In addition, the following member tags are available:

->records_array
->field_names
->error_msg
->error_code
->found_count
->shown_count
->shown_first
->shown_last
->page_count
->skiprecords_value
->maxrecords_value
->database_name
->table_name
->keyfield_name
->schema_name
->lasso_currentaction
->action_statement

[lp_inline_rowset] is also required and included.

Sample Usage

	var:'sql' = "
		SELECT
			firstname,
			lastname
		FROM
			contacts
		ORDER BY
			lastname,
			firstname
		LIMIT 10
		";

	inline: $connection_db,	-sql=$sql;
		var:'lp_inline_dataset' = lp_inline_dataset;
	/inline;

	lp_iterate: $lp_inline_dataset;
		'The contact\'s name is ' loop_item->firstname ' ' loop_item->lastname '
'; /lp_iterate; 'Error is ' $lp_inline_dataset->error_msg;

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[

define_type:'lp_inline_dataset',
	-description='Records abstraction type.',
	-prototype;

	// based on code from Greg Willits, James Harvard and Fletcher Sandbeck (TotW)

	local:'records_array' = array;
	local:'field_names' = array;
	local:'error_msg' = string;
	local:'error_code' = integer;
	local:'found_count' = integer;
	local:'shown_count' = integer;
	local:'shown_first' = integer;
	local:'shown_last' = integer;
	local:'page_count' = integer;
	local:'skiprecords_value' = integer;
	local:'maxrecords_value'  = integer;
	local:'database_name'  = string;
	local:'table_name'  = string;
	local:'keyfield_name'  = string;
	local:'schema_name'  = string;
	local:'lasso_currentaction'  = string;
	local:'action_statement'  = string;

	define_tag:'onCreate';
		self->'records_array' = @records_array;
		self->'field_names' = @field_names;
		self->'error_msg' = @error_msg;
		self->'error_code' = @error_code;
		self->'found_count' = @found_count;
		self->'shown_count' = @shown_count;
		self->'shown_first' = @shown_first;
		self->'shown_last' = @shown_last;
		self->'page_count' = (math_ceil:(found_count / (decimal:maxrecords_value)));
		self->'skiprecords_value' = @skiprecords_value;
		self->'maxrecords_value'  = @maxrecords_value;
		self->'database_name' = @database_name;
		self->'table_name' = @table_name;
		self->'keyfield_name' = @keyfield_name;
		self->'schema_name' = @schema_name;
		self->'lasso_currentaction' = @lasso_currentaction;
		self->'action_statement' = @action_statement;
	/define_tag;

	define_tag:'onConvert';
		return: @self->'records_array';
	/define_tag;
	
	define_tag:'size';
		return: @self->'records_array'->size;
	/define_tag;

	define_tag:'get',-optional='ptr';
		if: !local_defined:'ptr';
			#ptr = 1;
		/if;
		return: @(lp_inline_rowset: @self->'records_array'->(get: #ptr),@self->'field_names');
	/define_tag;
	
/define_type;

define_type:'lp_inline_rowset',
	-description='Row abstraction type.',
	-prototype;
	
	local:'row_array' = array;
	local:'field_names' = array;

	define_tag:'onCreate',-required='row_array',-required='field_names';
		self->'row_array' = @#row_array;
		self->'field_names' = @#field_names;
	/define_tag;
	
	define_tag:'onConvert';
		return: @self->'row_array';
	/define_tag;

	define_tag:'size';
		return: @self->'row_array'->size;
	/define_tag;
	
	define_tag:'get',-optional='ptr';
		if: !local_defined:'ptr';
			#ptr = 1;
		/if;
		return: @self->'row_array'->(get: #ptr);
	/define_tag;

	define_tag:'_unknowntag';
		local:'index' = self->'field_names'->(findindex: tag_name);
		if: #index->size == 0;
			return: null;
		else;
			return: @self->'row_array'->(get: (#index->(get:1)));
		/if;
	/define_tag;
		
/define_type;

]

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft