An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Saturday, February 28, 2009

Arrays in MySQL Stored Procedures

No comments :
Keywords: Arrays in MySQL Stored Procedures, Arrays in MySQL, MySQL Stored Procedures, Stored Procedures, MySQL, Arrays, MySQL Functions, MySQL Custom Functions, MySQL Libraries

Wonder how to arrays in MySQL? Everyone knows that there is no Arrays in MySQL & MySQL Stored Procedures, but we badly need arrays, isn't it?a

Here is the answer for your unique questions about Arrays in MySQL Stored Procedures, Functions.

There is MySQL 3rd party library which helps us acheiving the same. It is quiet good and structured too. It helps reducing more lines of your MySQL Program.

Note: The following functions shall only be called in select statements and stored procedures

Examples:

To create a new array from your MySQL stored procedure:-
mysql> call array_create('mysql_array_name',0);

To create an array from a list/string (with comma separated):-
mysql> call array_from_list('one,two,three', 'mysql_array_name');

To create an array from a list/string (with ":" separated):-
mysql> call array_from_list_complete('string1:string2:string3:string4', 'mysql_array_name', ':');

To set value into a mysql array using a key:-
mysql> array_set_value_by_key('mysql_array_name','index','value');

To retrieve value from a mysql array using a key:-
mysql> select array_get_value_by_key(('mysql_array_name','index' );

To set value into a mysql array using index:-
mysql> array_set_value_by_index('mysql_array_name','index','value');

To retrieve value from a mysql array using index:-
mysql> select array_get_value_by_index('mysql_array_name','index' );

To perform queue functions in mysql array:-
mysql> array_unshift('mysql_array_name', 'value'); --Inserts a value into mysql array
mysql> select array_shift('mysql_array_name'); --Deletes the last element in the mysql array

To perform stack functions in mysql array:-
mysql> array_push('mysql_array_name', 'value'); --Inserts a value into mysql array at the end/top
mysql> array_po('mysql_array_name'); --returns the top/last_inserted element from the mysql array (Last in First out)

To see the values in the mysql array:-
mysql> call array_show( 'mysql_array_name' );
mysql> call array_list(); --List of all arrays;
mysql> call array_full_list(); --List of all arrays;
For more information on MySQL Stored Procedure, Functions Library, Please visit:-

Detailed list of MySQL Array Functions:-
Keywords: Arrays in MySQL Stored Procedures, Arrays in MySQL, MySQL Stored Procedures, Stored Procedures, MySQL, Arrays, MySQL Functions, MySQL Custom Functions, MySQL Libraries

Featured Blog Topics:


No comments :