haskelldb-2.2.4: A library of combinators for generating and executing SQL statements.

Copyright | Daan Leijen (c) 1999, daan@cs.uu.nl HWT Group (c) 2003, haskelldb-users@lists.sourceforge.net
License | BSD-style
Maintainer | haskelldb-users@lists.sourceforge.net
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell98

Database.HaskellDB.Sql

Description

A data type for SQL.

Synopsis

- type SqlTable = String
- type SqlColumn = String
- type SqlName = String
- data SqlOrder
  - = SqlAsc
  - | SqlDesc
- data SqlType
  - = SqlType String
  - | SqlType1 String Int
  - | SqlType2 String Int Int
- data SqlSelect
  - = SqlSelect {
    - options :: [String]
    - attrs :: [(SqlColumn, SqlExpr)]
    - tables :: [(SqlTable, SqlSelect)]
    - criteria :: [SqlExpr]
    - groupby :: Maybe Mark
    - orderby :: [(SqlExpr, SqlOrder)]
    - extra :: [String]
    }
  - | SqlBin String SqlSelect SqlSelect
  - | SqlTable SqlTable
  - | SqlEmpty
- data SqlUpdate = SqlUpdate SqlTable [(SqlColumn, SqlExpr)] [SqlExpr]
- data SqlDelete = SqlDelete SqlTable [SqlExpr]
- data SqlInsert
  - = SqlInsert SqlTable [SqlColumn] [SqlExpr]
  - | SqlInsertQuery SqlTable [SqlColumn] SqlSelect
- data SqlCreate
  - = SqlCreateDB String
  - | SqlCreateTable SqlTable [(SqlColumn, (SqlType, Bool))]
- data SqlDrop
  - = SqlDropDB String
  - | SqlDropTable SqlTable
- data SqlExpr
  - = ColumnSqlExpr SqlColumn
  - | BinSqlExpr String SqlExpr SqlExpr
  - | PrefixSqlExpr String SqlExpr
  - | PostfixSqlExpr String SqlExpr
  - | FunSqlExpr String [SqlExpr]
  - | AggrFunSqlExpr String [SqlExpr]
  - | ConstSqlExpr String
  - | CaseSqlExpr [(SqlExpr, SqlExpr)] SqlExpr
  - | ListSqlExpr [SqlExpr]
  - | ExistsSqlExpr SqlSelect
  - | ParamSqlExpr (Maybe SqlName) SqlExpr
  - | PlaceHolderSqlExpr
  - | ParensSqlExpr SqlExpr
  - | CastSqlExpr String SqlExpr
- data Mark
  - = All
  - | Columns [(SqlColumn, SqlExpr)]
- newSelect :: SqlSelect
- foldSqlExpr :: (SqlColumn -> t, String -> t -> t -> t, String -> t -> t, String -> t -> t, String -> [t] -> t, String -> [t] -> t, String -> t, [(t, t)] -> t -> t, [t] -> t, SqlSelect -> t, Maybe SqlName -> t -> t, t, t -> t, String -> t -> t) -> SqlExpr -> t
- foldSqlSelect :: ([String] -> [(SqlColumn, SqlExpr)] -> [(SqlTable, t)] -> [SqlExpr] -> Maybe Mark -> [(SqlExpr, SqlOrder)] -> [String] -> t, String -> t -> t -> t, SqlTable -> t, t) -> SqlSelect -> t

# Documentation

type SqlTable = String Source

type SqlColumn = String Source

type SqlName = String Source

A valid SQL name for a parameter.

data SqlOrder Source

Constructors

SqlAsc |
SqlDesc |

Instances

Show SqlOrder Source |

data SqlType Source

Constructors

SqlType String |
SqlType1 String Int |
SqlType2 String Int Int |

Instances

Show SqlType Source |

data SqlSelect Source

Data type for SQL SELECT statements.

Constructors

SqlSelect |

Fields

options :: [String]

  DISTINCT, ALL etc.

attrs :: [(SqlColumn, SqlExpr)]

  result

tables :: [(SqlTable, SqlSelect)]

  FROM

criteria :: [SqlExpr]

  WHERE

groupby :: Maybe Mark

  GROUP BY

orderby :: [(SqlExpr, SqlOrder)]

  ORDER BY

extra :: [String]

  TOP n, etc.

SqlBin String SqlSelect SqlSelect | Binary relational operator
SqlTable SqlTable | Select a whole table.
SqlEmpty | Empty select.

Instances

Show SqlSelect Source |

data SqlUpdate Source

Data type for SQL UPDATE statements.

Constructors

SqlUpdate SqlTable [(SqlColumn, SqlExpr)] [SqlExpr] |

data SqlDelete Source

Data type for SQL DELETE statements.

Constructors

SqlDelete SqlTable [SqlExpr] |

data SqlInsert Source

Data type for SQL INSERT statements.

Constructors

SqlInsert SqlTable [SqlColumn] [SqlExpr] |
SqlInsertQuery SqlTable [SqlColumn] SqlSelect |

data SqlCreate Source

Data type for SQL CREATE statements.

Constructors

SqlCreateDB String | Create a database
SqlCreateTable SqlTable [(SqlColumn, (SqlType, Bool))] | Create a table.

data SqlDrop Source

Data type representing the SQL DROP statement.

Constructors

SqlDropDB String | Delete a database
SqlDropTable SqlTable | Delete a table named SqlTable

data SqlExpr Source

Expressions in SQL statements.

Constructors

ColumnSqlExpr SqlColumn |
BinSqlExpr String SqlExpr SqlExpr |
PrefixSqlExpr String SqlExpr |
PostfixSqlExpr String SqlExpr |
FunSqlExpr String [SqlExpr] |
AggrFunSqlExpr String [SqlExpr] | Aggregate functions separate from normal functions.
ConstSqlExpr String |
CaseSqlExpr [(SqlExpr, SqlExpr)] SqlExpr |
ListSqlExpr [SqlExpr] |
ExistsSqlExpr SqlSelect |
ParamSqlExpr (Maybe SqlName) SqlExpr |
PlaceHolderSqlExpr |
ParensSqlExpr SqlExpr |
CastSqlExpr String SqlExpr |

Instances

Show SqlExpr Source |

data Mark Source

Constructors

All |
Columns [(SqlColumn, SqlExpr)] |

Instances

Show Mark Source |

newSelect :: SqlSelect Source

foldSqlExpr :: (SqlColumn -> t, String -> t -> t -> t, String -> t -> t, String -> t -> t, String -> [t] -> t, String -> [t] -> t, String -> t, [(t, t)] -> t -> t, [t] -> t, SqlSelect -> t, Maybe SqlName -> t -> t, t, t -> t, String -> t -> t) -> SqlExpr -> t Source

Transform a SqlExpr value.

foldSqlSelect :: ([String] -> [(SqlColumn, SqlExpr)] -> [(SqlTable, t)] -> [SqlExpr] -> Maybe Mark -> [(SqlExpr, SqlOrder)] -> [String] -> t, String -> t -> t -> t, SqlTable -> t, t) -> SqlSelect -> t Source

Transform a SqlSelect value.