Welcome to the CHICKEN Scheme pasting service

printing pasted by rien on Fri Nov 22 23:24:46 2013

#;21> (display "hey\nthere\n\n")
hey
there

#;22> (display (q:find-note "this,that" "the other"))
"SELECT distinct n.id, n.title\n                FROM notes n\n                LEFT JOIN notes_tags nt ON nt.note_id = n.id\n                LEFT JOIN tags t ON nt.tag_id = t.id\n                JOIN fulltext ft ON ft.docid = n.id\n                WHERE 1=1""AND t.name in (this,that)\n""AND ft.fulltext MATCH 'the other'\n"";"#;23>

no title pasted by anonymous on Fri Nov 22 23:27:50 2013


  (define (find-note tags words)
    ;; INPUTS: '(tags)
    (with-output-to-string
      (lambda ()
        (write "SELECT distinct n.id, n.title
                FROM notes n
                LEFT JOIN notes_tags nt ON nt.note_id = n.id
                LEFT JOIN tags t ON nt.tag_id = t.id
                JOIN fulltext ft ON ft.docid = n.id
                WHERE 1=1")
        (when (not (equal? "" tags))
              (write (string-append "AND t.name in (" tags ")\n")))
        (when (not (equal? "" words))
              (write (string-append "AND ft.fulltext MATCH '" words "'\n")))
        (write ";"))))

conc added by andyjpb on Fri Nov 22 23:35:21 2013

  (define (find-note tags words)
    ;; INPUTS: '(tags)
    (conc "SELECT distinct n.id, n.title
                FROM notes n
                LEFT JOIN notes_tags nt ON nt.note_id = n.id
                LEFT JOIN tags t ON nt.tag_id = t.id
                JOIN fulltext ft ON ft.docid = n.id
                WHERE 1=1")
        (if (not (equal? "" tags))
              (conc "AND t.name in (" tags ")\n")
              "")
        (if (not (equal? "" words))
              (conc "AND ft.fulltext MATCH '" words "'\n")
              "")
        ";"))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg provides `take-right'?
Visually impaired? Let me spell it for you (wav file) download WAV