in reply to Unable to run SQL query

Your problem is that you are trying to use double quotes within a double quoted string. Try here-documents, which are explained in perlop, section "Quote and Quote-like Operators".
Perl 6 - links to (nearly) everything that is Perl 6.