Documentation ¶
Index ¶
Constants ¶
View Source
const ( // StmtSelect is executed using sql.DB.Query. StmtSelect = "select" // StmtOther is executed using sql.DB.Exec. StmtOther = "other" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StmtType ¶
type StmtType string
StmtType is the type of SQL statement such as "select".
func SplitSQL ¶
func SplitSQL(input io.Reader, delim string, moreDelims ...string) (stmts []string, types []StmtType, err error)
SplitSQL splits SQL text into multiple statements, demarcated by delim (typically a semicolon) or additional delim values such as "GO" or "GO;" For example, this is useful for splitting up a .sql file containing multiple statements. Empty lines and comment lines are not returned, nor are the separator elements themselves.
This is a very rudimentary implementation. It currently only works if the delimiters are at the end of the line. Also, its ability to detect the correct statement type is limited.
Click to show internal directories.
Click to hide internal directories.