commandbox.system.modules_app.system-commands.commands

Class sql

lucee.Component
    extended by commandbox.system.modules_app.system-commands.commands.sql

SQL query command for filtering table like data. This command will automatically format any table like data into a query object that can be queried against JSON data can be passed in the first param or piped into the command: {code:bash} // (arrays or array of arrays, are given automatic column names) sql data=[[1,2],[3,4]] select=col_1 #extensionlist | sql select=id,name cat myfile.json | sql select=id,name where="name like '%sql%'" orderby=name limit=3 {code} . Example Select Statements {code:bash} sql select="*" sql select="id,name, version" sql select="max(name) as maxName" {code} . Example Where Statements {code:bash} sql where="a like "%top" sql where="a > 5" sql where="a <> 5" sql where="a <> 5 and b <> ''" {code} . Example Order By Statements {code:bash} sql orderby="a" sql orderby="a, b" sql orderby="a desc, b asc" {code} . Example Limit/Offset Statements {code:bash} sql limit=1 // offset 1 limit 5 sql limit=1,5 {code} . Advanced piping {code:bash} sql data=[{a:1,b:2},{a:3,b:4},{a:5,b:6}] where="a > 1" | printTable ╔═══╤═══╗ ║ a │ b ║ ╠═══╪═══╣ ║ 3 │ 4 ║ ╟───┼───╢ ║ 5 │ 6 ║ ╚═══╧═══╝ {code}

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any convert


    • access = public
    • returntype = any
    • inject = DataConverter
    true false
    Method Summary
    any run(string data, [string select=''], [string where=''], [string orderby=''], [string limit=''], [string headerNames=''])
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    convert

    property any convert

    Attributes:
    access - public
    required - false
    returntype - any
    inject - DataConverter
    serializable - true

    Method Detail

    run

    public any run(string data, [string select=''], [string where=''], [string orderby=''], [string limit=''], [string headerNames=''])

    Parameters:
    data - The text to process with table like data in it
    select - A SQL list of column names, eg. "name,version"
    where - A SQL where filter used in a query of queries, eg. "name like '%My%'"
    orderby - A SQL order by used in a query of queries, eg. "name asc,version desc"
    limit - A SQL limit/offset used in a query of queries, eg. "5 or 5,10 (eg. offset 5 limit 10)"
    headerNames - An list of column headers to use instead of the default