dirty mnesia function

Francesco Cesarini francesco@REDACTED
Tue Sep 24 01:03:59 CEST 2002


Hi Roberto,

you are running your match_object function from the shell. That means 
that the shell will format the result for you as it sees fit. Thus, as 
is happening in your second example, if there are many records, instead 
of printing them all out, it prints out the leading elements and 
replaces all the others with |...

Try binding your result to a variable and print it out. For example

 > RecordList = mnesia:dirty_match_object(piuTable, 
{piuTable,'_','_','_','_','_','_','_','_','_','_','_','_','_'}).
 > io:format("~p~n",[RecordList]).

Because you are using the tuple representation or records, I am assuming 
your retrieving the list of records from the shell is for pure test 
reasons. In that case, as mnesia tables are built on ets tables, you can 
instead use
 > RecordList = ets:tab2list(piuTable).

 You have to still assign it to a variable and print it out using 
io:format, but avoiding the underscores,  are not using the tuple 
representation of records, with less chances of making mistakes.

Good Luck (More like good night over here :-),
Francesco
--
http://www.erlang-consulting.com

Roberto Portugal (CEC) wrote:

> Hi,
>
> We are trying to get all records from a mnesia's table.
> "dirty_match_object" function is used to this purpose:
>
>    mnesia:dirty_match_object(piuTable, 
> {piuTable,'_','_','_','_','_','_','_','_','_','_','_','_','_'}).
>
> However some records are not valid when content is returned.
> The following is a valid record returned:
>
>         {piuTable,{1,2,2,1},
>           2,
>           "SC",
>           1,
>           5,
>           2,
>           "ROJ_238_007/1",
>           "R7A/B",
>           "T220089350",
>           "SCB_20G",
>           2,
>           2,
>           [1]}.
>        
> But in the next case, record information is not valid:
>
>         {piuTable,{1,19,19,2},
>           5,
>           "CP-IO",
>           1,
>           5,
>           2,
>           "ROJ_237_051/1",
>           "R9A",
>           "T220110020"|...}.
>
> some fields are replaced with "|...".
>
> How we can to get all records in a rigth form througth this function?
>
> Thanks in advanced.
>
> Roberto
>
>
> Roberto Portugal
> System Integrator
>
> Regional Competence Center
> Ericsson Chile, S.A.
> Av. Vitacura 2808, Las Condes, Santiago, Chile
> Telf.: +56 2 372 53 95
> Fax:  +56 2 372 50 57
> E-mail: roberto.portugal@REDACTED
> http://www.ericsson.com
>





More information about the erlang-questions mailing list