Hi. This may be a noble question.

I`d like to generate proc (OR func?) with different **constant** variable 
inside it, because the proc will be called frequently, avoiding to concatenate 
string on every call.

e. g) 
    
    
    import db_sqlite
    
    template checkDoubleEdge(db:typed, table: string, s,t: typed): 
proc(db:DbConn, s,t: int): bool =
      const query = "SELECT source FROM " & table & " WHERE source=? AND 
target=?;"
      (db.getValue(sql(query), s, t)).len == 0
    
    var db = open(":memory:","","","")
    
    echo db.checkDoubleEdge("myedge",1,2)
    
    
    Run

This code result **Error: type mismatch: got <bool> but expected 'template (db: 
DbConn, s: int, t: int): bool{.closure.}'**

How can I fix it? or, What`s wrong with my understanding template.

Reply via email to