Hi,
The Query-capabilities to databases are very nice. I would like to use those in a fetch-command as well. I have tried a few alternatives that don't work (and I have read the query-part in the manual, and the fetch-command in Command-reference).
Yes, I realize I can do a loop checking @ifirst of every series and deleting/keeping based on that, but I thought it would be very nice to using the query-part of Eviews in stead.
I use Eviews 7.2.
Thanks in advance,
Dagfinn
Database query during a "fetch"
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
dagfinnrime
- Posts: 54
- Joined: Sat Oct 11, 2008 9:37 am
- Location: Oslo
- Contact:
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Database query during a "fetch"
Use the (not yet documented) @wquery function.
Code: Select all
@wquery can be used to obtain a list of all objects inside a database that meet one or more search criteria.
The function format is
string @wquery(dbname[, where_expression [, field_list]])
where all three arguments are strings. The return argument is also a string which uses space delimiters to separate items (which is compatible with the EViews for loop and other @wxxx functions).
The arguments are as follows:
- dbpath is the alias/filename/path of the database
- where_expression is a string containing the criteria to search for where the string is in the same format as specified in the Advanced Queries section of the database documentation. If the where expression is omitted, all objects in the database are considered to match the criteria.
- field_list is a comma delimited list of the fields to return for each object that matches the ‘where’ expression. The list of possible fields is documented in the Advanced Queries section of the database documentation. If field_list is omitted, the name of each object that satisfies the ‘where’ expression is returned.
EXAMPLES:
%matnames = @wquery(“mydb”, “type=matrix”)
Set %matnames equal to a space delimited list of the names of all matrix objects in the database ‘mydb’
string s =@wquery(“mydb”, “freq=q and start<1950”)
set s equal to a space delimited list of the names of all objects in the database ‘mydb’ which have a quarterly frequency and have data starting before 1950
%freqs = @wunique(@wquery(“mydb”, “”, “freq”))
set %freqs equal to a space delimited list containing a list of the frequencies used in the database ‘mydb’
%end = @wquery(“mydb”, “name=myseries”, end”) returns the end date of the series myseries in the database “mydb”
-
dagfinnrime
- Posts: 54
- Joined: Sat Oct 11, 2008 9:37 am
- Location: Oslo
- Contact:
Re: Database query during a "fetch"
Thanks,
I like to do the following:
But it doesn't work. The following work:
The "name matches "ofd2* or vold2*" and start<1/1/2004" part work in the advanced query box of the database.
Thanks in advance,
Dagfinn
I like to do the following:
Code: Select all
%db_list=@wquery("db_daily",""name matches "of* or vol*" and start<1/1/2004"")
Code: Select all
string teststr =@wquery("db_daily","name matches of* and start<1/1/2004")
Thanks in advance,
Dagfinn
-
dagfinnrime
- Posts: 54
- Joined: Sat Oct 11, 2008 9:37 am
- Location: Oslo
- Contact:
Re: Database query during a "fetch"
The following works:
Code: Select all
%db_list=@wquery("db_daily","name matches of* or name matches vol* and start<1/1/2004")
fetch(d=DB_daily) {%db_list}
Who is online
Users browsing this forum: No registered users and 2 guests
