How to use SQL in My Money

From MTHWiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
=[http://ybyfonojot.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
-
[[My_Money_2.0_Manual | '''My Money 2.0 Manual''']] | [[Password protect Money|Password protect Money<<Previous]] | [[Back up your Money file|Next>>Back up your Money file]]
+
[[My_Money_2.0_Manual | '''My Money 2.0 Manual''']] | [[Password protect Money|Password protect Money&lt;&lt;Previous]] | [[Back up your Money file|Next&gt;&gt;Back up your Money file]]
----
----
Line 9: Line 10:
== How to use My Money Shell ==
== How to use My Money Shell ==
-
My Money shell can be activated by selecting "View-Show console" or clicking on the shell icon:
+
My Money shell can be activated by selecting &quot;View-Show console&quot; or clicking on the shell icon:
[[Image:Console.png]]
[[Image:Console.png]]
Line 15: Line 16:
My Money shell is a general purpose Java shell based on a [http://www.beanshell.org BeanShell 2.0]. As such, it is perfectly capable of processing simple and complex commands in the Java language syntax.
My Money shell is a general purpose Java shell based on a [http://www.beanshell.org BeanShell 2.0]. As such, it is perfectly capable of processing simple and complex commands in the Java language syntax.
-
For example, to print a "Hello, World" line to the console use print command:
+
For example, to print a &quot;Hello, World&quot; line to the console use print command:
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
-
money.bsh% print("Hello World");
+
money.bsh% print(&quot;Hello World&quot;);
Hello World
Hello World
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
To print todays date, or to do a simple calculation:
To print todays date, or to do a simple calculation:
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
-
money.bsh% print ("Todays Date: " + new java.util.Date());
+
money.bsh% print (&quot;Todays Date: &quot; + new java.util.Date());
Todays Date: Wed Nov 21 12:32:49 EST 2007
Todays Date: Wed Nov 21 12:32:49 EST 2007
money.bsh%
money.bsh%
-
money.bsh% print ("Value: " + 100*52/100);
+
money.bsh% print (&quot;Value: &quot; + 100*52/100);
Value: 52
Value: 52
money.bsh%
money.bsh%
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
My Money is shipped with a full version of BeanShell and all of the BeanShell scripts. For example to get a directory listing for the current directory use dir() script:
My Money is shipped with a full version of BeanShell and all of the BeanShell scripts. For example to get a directory listing for the current directory use dir() script:
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
money.bsh% dir();
money.bsh% dir();
rw_ Nov 12 2438 .classpath
rw_ Nov 12 2438 .classpath
Line 56: Line 57:
rw_ Aug 16 0 testdata/
rw_ Aug 16 0 testdata/
money.bsh%
money.bsh%
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
Please refer to [http://www.beanshell.org/manual/contents.html BeanShell Manual] for a complete list and examples of shell commands
Please refer to [http://www.beanshell.org/manual/contents.html BeanShell Manual] for a complete list and examples of shell commands
Line 68: Line 69:
For example, to see the list of all accounts in the database:
For example, to see the list of all accounts in the database:
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
-
money.bsh% runsql("select ID, ANAME, ATYPE, OFXBANKID from mmy_account");
+
money.bsh% runsql(&quot;select ID, ANAME, ATYPE, OFXBANKID from mmy_account&quot;);
-
Executing>> select ID, ANAME, ATYPE, OFXBANKID from mmy_account
+
Executing&gt;&gt; select ID, ANAME, ATYPE, OFXBANKID from mmy_account
ID|ANAME|ATYPE|OFXBANKID
ID|ANAME|ATYPE|OFXBANKID
Line 81: Line 82:
done..
done..
money.bsh%
money.bsh%
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
To find out how many transactions are stored in the database:
To find out how many transactions are stored in the database:
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
-
money.bsh% runsql("select count(*) from mmy_transaction");
+
money.bsh% runsql(&quot;select count(*) from mmy_transaction&quot;);
-
Executing>> select count(*) from mmy_transaction
+
Executing&gt;&gt; select count(*) from mmy_transaction
1
1
Line 96: Line 97:
done..
done..
money.bsh%
money.bsh%
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
Find out how many transactions are on account named 'Test'
Find out how many transactions are on account named 'Test'
-
<code><pre>
+
&lt;code&gt;&lt;pre&gt;
-
money.bsh% runsql ("select count(*) from mmy_transaction, mmy_doubleentry, mmy_account
+
money.bsh% runsql (&quot;select count(*) from mmy_transaction, mmy_doubleentry, mmy_account
where mmy_account.aname='Test'
where mmy_account.aname='Test'
and mmy_account.id=mmy_doubleentry.leftaccntid
and mmy_account.id=mmy_doubleentry.leftaccntid
-
and mmy_transaction.id=mmy_doubleentry.lefttranid");
+
and mmy_transaction.id=mmy_doubleentry.lefttranid&quot;);
-
Executing>> select count(*) from mmy_transaction, mmy_doubleentry, mmy_account
+
Executing&gt;&gt; select count(*) from mmy_transaction, mmy_doubleentry, mmy_account
where mmy_account.aname='Test'
where mmy_account.aname='Test'
and mmy_account.id=mmy_doubleentry.leftaccntid
and mmy_account.id=mmy_doubleentry.leftaccntid
Line 118: Line 119:
done..
done..
money.bsh%
money.bsh%
-
</pre></code>
+
&lt;/pre&gt;&lt;/code&gt;
Line 130: Line 131:
----
----
-
[[My_Money_2.0_Manual | '''My Money 2.0 Manual''']] | [[Password protect Money|Password protect Money<<Previous]] | [[Back up your Money file|Next>>Back up your Money file]]
+
[[My_Money_2.0_Manual | '''My Money 2.0 Manual''']] | [[Password protect Money|Password protect Money&lt;&lt;Previous]] | [[Back up your Money file|Next&gt;&gt;Back up your Money file]]

Revision as of 03:55, 24 November 2010

Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page

My Money 2.0 Manual | Password protect Money<<Previous | Next>>Back up your Money file



How to use My Money Shell

My Money shell can be activated by selecting "View-Show console" or clicking on the shell icon:

Image:Console.png

My Money shell is a general purpose Java shell based on a BeanShell 2.0. As such, it is perfectly capable of processing simple and complex commands in the Java language syntax.

For example, to print a "Hello, World" line to the console use print command:

<code><pre> money.bsh% print("Hello World"); Hello World </pre></code>

To print todays date, or to do a simple calculation:

<code><pre> money.bsh% print ("Todays Date: " + new java.util.Date()); Todays Date: Wed Nov 21 12:32:49 EST 2007 money.bsh% money.bsh% print ("Value: " + 100*52/100); Value: 52 money.bsh% </pre></code>

My Money is shipped with a full version of BeanShell and all of the BeanShell scripts. For example to get a directory listing for the current directory use dir() script:

<code><pre> money.bsh% dir(); rw_ Nov 12 2438 .classpath rw_ Oct 3 44 .cvsignore rw_ Nov 6 503 .project rw_ Nov 6 0 .settings/ rw_ Nov 20 0 bootstrap/ rw_ Sep 12 0 build/ rw_ Nov 12 0 classes/ rw_ Jul 18 0 config/ rw_ Sep 13 0 deploy/ rw_ Nov 21 378 derby.log rw_ Nov 21 0 docs/ rw_ Sep 11 0 install/ rw_ Apr 23 5 latest_version.txt rw_ Oct 15 0 lib/ rw_ Aug 15 0 src/ rw_ Nov 1 0 style/ rw_ Nov 12 0 system/ rw_ Aug 16 0 testdata/ money.bsh% </pre></code>

Please refer to BeanShell Manual for a complete list and examples of shell commands

How to use SQL in My Money

My Money is shipped with a embedded shell that is capable of processing commands to database in a Structured Query Language (SQL) syntax. The default database in My Money installations is a Apache Derby RDBMS, which is compliant with a SQL-92 standard.

My Money allows you to query and update underlying database right from the shell. To query the database you can use 'runsql' script and to update data you can use 'runsqlupdate' script.

For example, to see the list of all accounts in the database:

<code><pre> money.bsh% runsql("select ID, ANAME, ATYPE, OFXBANKID from mmy_account"); Executing>> select ID, ANAME, ATYPE, OFXBANKID from mmy_account

ID|ANAME|ATYPE|OFXBANKID


1|Test|0|


2|test2|0|


done.. money.bsh% </pre></code>

To find out how many transactions are stored in the database:

<code><pre> money.bsh% runsql("select count(*) from mmy_transaction"); Executing>> select count(*) from mmy_transaction

1


9


done.. money.bsh% </pre></code>

Find out how many transactions are on account named 'Test'

<code><pre> money.bsh% runsql ("select count(*) from mmy_transaction, mmy_doubleentry, mmy_account where mmy_account.aname='Test' and mmy_account.id=mmy_doubleentry.leftaccntid and mmy_transaction.id=mmy_doubleentry.lefttranid");

Executing>> select count(*) from mmy_transaction, mmy_doubleentry, mmy_account where mmy_account.aname='Test' and mmy_account.id=mmy_doubleentry.leftaccntid and mmy_transaction.id=mmy_doubleentry.lefttranid

1


7


done.. money.bsh% </pre></code>


Please refer to the My Money Database Model for a complete list of My Modey data tables and relationships.

Latest Apache Derby manuals, including SQL syntax could be found at Derby Documentation web site.




My Money 2.0 Manual | Password protect Money<<Previous | Next>>Back up your Money file

Personal tools