Well, to start off - template is simple code substitution. You can't just 
return a "proc" from a template if you didn't actually made a proc. Second of 
all - if you want a template to generate a proc, it needs to have a name.

I really think that you can achieve what you want the simpler way - by using 
static[string], like here: 
    
    
    import db_sqlite
    
    proc checkDoubleEdge(db: DbConn, table: static[string], s, t: int): bool =
      const query = "SELECT source FROM " & table & " WHERE source=? AND 
target=?;"
      result = (db.getValue(sql(query), s, t)).len == 0
    
    var db = open(":memory:","","","")
    
    echo db.checkDoubleEdge("myedge", 1, 2)
    
    
    Run

By marking an argument in a proc as `static`, you tell to the compiler that 
this argument should only accept arguments known at compile-time (like string 
literals)

Reply via email to