Extending SQL a bit
Kim Schulz <[email protected]> Thu, 24 Feb 2005 11:28:52 +0100
| Newsgroups | gmane.comp.db.mckoi |
|---|---|
| Organization | Aalborg University |
| Message-ID | <[email protected]> |
Hi
I'm working on an experimental project where I need to extend the SQL
language with an expiry time for inserts.
Bacically I want to do the Following:
INSERT INTO table SET (a=1,b=2,c=3) EXPIRES=NOW()+1000;
the EXPIRES part is actually an "alias" for doing somthing like
INSERT INTO table SET (a=1,b=2,c=3,expTime=NOW()+1000);
expTime is a hidden column I have in all tables (for now) .
I'm trying to get the SQL.jj file to recognize this, but I'm used to
SableCC so the syntax is quite different for me.
I have added
|<EXPIRES: "expires"> to the tokens and changed the Statement Tree for
Insert to be:
StatementTree Insert() :
{
StatementTree cmd =
newStatementTree("com.mckoi.database.interpret.Insert");
String table_name;
ArrayList col_list = new ArrayList();
ArrayList data_list = new ArrayList(); // ( Array of Expression[] )
StatementTree select = null;
ArrayList assignments = new ArrayList();
String type;
}
{
( <INSERT> [ <INTO> ] table_name = TableName()
( [ "(" BasicColumnList(col_list) ")" ]
( <VALUES> InsertDataList(data_list) { type =
"from_values"; } | select = Select() {
type = "from_select"; } )
| <SET> AssignmentList(assignments) { type = "from_set"; }
)
| <EXPIRES> <ASSIGNMENT> ExpireTime(exp_time) {expires =
"expires";}
)
{ cmd.putObject("table_name", table_name);
cmd.putObject("col_list", col_list);
cmd.putObject("data_list", data_list);
cmd.putObject("select", select);
cmd.putObject("assignments", assignments);
cmd.putObject("exp_time",exp_time);
cmd.putObject("expires",expires);
cmd.putObject("type", type);
return cmd; }
}
I want the RHS of the assignment to be evaluated completly (like the
NOW()+1000 part) and then saved in the tree (to be added to the table
later). But this is where I'm stuck at the moment. I'm not sure how to
create this method. Can anyone help me out with this?
--
Kim Schulz | Keen of Fundanemt? Want to share experieces with
Geek by nature | other users? join The Fundanemt User Group NOW!
schulz.dk | http://www.fundausers.org
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]