Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL as script interpreter #2176

Closed
lvca opened this issue Mar 31, 2014 · 0 comments
Closed

SQL as script interpreter #2176

lvca opened this issue Mar 31, 2014 · 0 comments
Assignees
Labels
Milestone

Comments

@lvca
Copy link
Member

@lvca lvca commented Mar 31, 2014

We already have the OCommandScript class that execute a script at the server side. Now we could use this feature to specify "SQL" as scripting language with few, simple and powerful features taken from issue #2056.

If you execute a OCommandScript request passing SQL as language, all the SQL is supported and these commands more:

  • begin -> begins a transaction
  • rollback -> rollbacks an active transaction
  • commit -> commits an active transaction
  • let = -> executes a command and assign it in the context as . That variable can be used in further commands by prefixing it with $
  • return -> returns the variable result instead of last command result
    Example:
    database.open("admin", "admin");

    String cmd = "";
    cmd += "begin";
    cmd += "\nlet a = create vertex set script = true";
    cmd += "\nlet b = select from v limit 1";
    cmd += "\ncreate edge from $a to $b retry 100";
    cmd += "\ncommit";
    cmd += "\nreturn $a";

    Object result = database.command(new OCommandScript("sql", cmd)).execute();

This is very useful to manipulate the graph at the server side with just one network call.

@lvca lvca added this to the 1.7 milestone Mar 31, 2014
@lvca lvca self-assigned this Mar 31, 2014
lvca added a commit that referenced this issue Mar 31, 2014
@lvca lvca closed this Mar 31, 2014
@lvca lvca added 3 - Done and removed In progress labels Mar 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.