odbc, odbc-docs: fix indentation, remove trailing whitespace

char-rename
Alexander Iljin 2016-10-30 00:43:22 +03:00 committed by John Benediktsson
parent ca0fa560da
commit c78afe8c53
2 changed files with 202 additions and 170 deletions

View File

@ -13,7 +13,11 @@ HELP: odbc-init
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-connect HELP: odbc-connect
{ $values { "env" "an ODBC environment handle" } { "dsn" "a string" } { "dbc" "an ODBC database connection handle" } } { $values
{ "env" "an ODBC environment handle" }
{ "dsn" "a string" }
{ "dbc" "an ODBC database connection handle" }
}
{ $description { $description
"Connects to the database identified by the ODBC data source name (DSN). " "Connects to the database identified by the ODBC data source name (DSN). "
"The environment handle is usually obtained by a call to " { $link odbc-init } ". The result is the ODBC connection handle which can be used in other ODBC calls. When finished with the connection handle " { $link odbc-disconnect } " must be called on it." "The environment handle is usually obtained by a call to " { $link odbc-init } ". The result is the ODBC connection handle which can be used in other ODBC calls. When finished with the connection handle " { $link odbc-disconnect } " must be called on it."
@ -29,7 +33,11 @@ HELP: odbc-disconnect
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-prepare HELP: odbc-prepare
{ $values { "dbc" "an ODBC database connection handle" } { "string" "a string containing SQL" } { "statement" "an ODBC statement handle" } } { $values
{ "dbc" "an ODBC database connection handle" }
{ "string" "a string containing SQL" }
{ "statement" "an ODBC statement handle" }
}
{ $description { $description
"Prepares (precompiles) the given SQL string, ready for execution with " { $link odbc-execute } ". When finished with the statement " { $link odbc-free-statement } " must be called on it." "Prepares (precompiles) the given SQL string, ready for execution with " { $link odbc-execute } ". When finished with the statement " { $link odbc-free-statement } " must be called on it."
} }
@ -50,7 +58,10 @@ HELP: odbc-execute
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-next-row HELP: odbc-next-row
{ $values { "statement" "an ODBC statement handle" } { "bool" "a boolean indicating success or failure" } } { $values
{ "statement" "an ODBC statement handle" }
{ "bool" "a boolean indicating success or failure" }
}
{ $description { $description
"Retrieves the next available row from the database. If no next row is available then " { $link f } " is returned. Once the row is retrieved " { $link odbc-number-of-columns } ", " { $link odbc-describe-column } ", " { $link odbc-get-field } " and " { $link odbc-get-row-fields } " can be used to query the data retrieved." "Retrieves the next available row from the database. If no next row is available then " { $link f } " is returned. Once the row is retrieved " { $link odbc-number-of-columns } ", " { $link odbc-describe-column } ", " { $link odbc-get-field } " and " { $link odbc-get-row-fields } " can be used to query the data retrieved."
} }
@ -64,14 +75,22 @@ HELP: odbc-number-of-columns
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-describe-column HELP: odbc-describe-column
{ $values { "statement" "an ODBC statement handle" } { "n" "a column number starting from one" } { "column" "a column object" } } { $values
{ "statement" "an ODBC statement handle" }
{ "n" "a column number starting from one" }
{ "column" "a column object" }
}
{ $description { $description
"Retrieves column information for the given column number from the statement. The column number must be one or greater. The " { $link <column> } " object returned provides data type, name, etc." "Retrieves column information for the given column number from the statement. The column number must be one or greater. The " { $link <column> } " object returned provides data type, name, etc."
} }
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-get-field HELP: odbc-get-field
{ $values { "statement" "an ODBC statement handle" } { "column" "a column number starting from one or a <column> object" } { "field" "a <field> object" } } { $values
{ "statement" "an ODBC statement handle" }
{ "column" "a column number starting from one or a <column> object" }
{ "field" "a <field> object" }
}
{ $description { $description
"Returns a field object which contains the data for the field in the given column in the current row. The column can be identified by a number or a <column> object. The datatype of the contents of the field depends on the type of the column itself. Note that this word can only be safely called once on each column in a given row with most ODBC drivers. Subsequent calls on the same row for the same column can fail." "Returns a field object which contains the data for the field in the given column in the current row. The column can be identified by a number or a <column> object. The datatype of the contents of the field depends on the type of the column itself. Note that this word can only be safely called once on each column in a given row with most ODBC drivers. Subsequent calls on the same row for the same column can fail."
} }
@ -92,7 +111,11 @@ HELP: odbc-get-all-rows
{ $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ; { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
HELP: odbc-query HELP: odbc-query
{ $values { "string" "a string containing SQL" } { "dsn" "a DSN string" } { "result" "a sequence" } } { $values
{ "string" "a string containing SQL" }
{ "dsn" "a DSN string" }
{ "result" "a sequence" }
}
{ $description { $description
"This word initializes odbc, connects to the database with the given DSN, executes the query string and returns the result as a sequence. It cleans up all resources it uses. It is an inefficient way of running multiple queries but is useful for the occasional query, testing at the REPL, or as an example of how to do it." "This word initializes odbc, connects to the database with the given DSN, executes the query string and returns the result as a sequence. It cleans up all resources it uses. It is an inefficient way of running multiple queries but is useful for the occasional query, testing at the REPL, or as an example of how to do it."
} }

View File

@ -166,17 +166,19 @@ PRIVATE>
: odbc-connect ( env dsn -- dbc ) : odbc-connect ( env dsn -- dbc )
[ alloc-dbc-handle dup ] dip [ alloc-dbc-handle dup ] dip
f swap dup length 1024 temp-string 0 short <ref> SQL-DRIVER-NOPROMPT f swap dup length 1024 temp-string 0 short <ref> SQL-DRIVER-NOPROMPT SQLDriverConnect
SQLDriverConnect succeeded? [ "odbc-connect failed" throw ] unless ; succeeded? [ "odbc-connect failed" throw ] unless ;
: odbc-disconnect ( dbc -- ) : odbc-disconnect ( dbc -- )
SQLDisconnect succeeded? [ "odbc-disconnect failed" throw ] unless ; SQLDisconnect succeeded? [ "odbc-disconnect failed" throw ] unless ;
: odbc-prepare ( dbc string -- statement ) : odbc-prepare ( dbc string -- statement )
[ alloc-stmt-handle dup ] dip dup length SQLPrepare succeeded? [ "odbc-prepare failed" throw ] unless ; [ alloc-stmt-handle dup ] dip dup length SQLPrepare
succeeded? [ "odbc-prepare failed" throw ] unless ;
: odbc-free-statement ( statement -- ) : odbc-free-statement ( statement -- )
SQL-HANDLE-STMT swap SQLFreeHandle succeeded? [ "odbc-free-statement failed" throw ] unless ; SQL-HANDLE-STMT swap SQLFreeHandle
succeeded? [ "odbc-free-statement failed" throw ] unless ;
: odbc-execute ( statement -- ) : odbc-execute ( statement -- )
SQLExecute succeeded? [ "odbc-execute failed" throw ] unless ; SQLExecute succeeded? [ "odbc-execute failed" throw ] unless ;
@ -239,11 +241,14 @@ TUPLE: field value column ;
C: <field> field C: <field> field
:: odbc-get-field ( statement column! -- field ) :: odbc-get-field ( statement column! -- field )
column column? [ statement column odbc-describe-column column! ] unless column column? [
statement column odbc-describe-column column!
] unless
8192 :> bufferLen 8192 :> bufferLen
bufferLen alien-space-str :> targetValuePtr bufferLen alien-space-str :> targetValuePtr
statement column number>> SQL-C-DEFAULT statement column number>> SQL-C-DEFAULT
targetValuePtr bufferLen f SQLGetData succeeded? [ targetValuePtr bufferLen f SQLGetData
succeeded? [
targetValuePtr column [ dereference-type-pointer ] keep <field> targetValuePtr column [ dereference-type-pointer ] keep <field>
] [ ] [
column [ column [
@ -261,7 +266,11 @@ C: <field> field
] { } make ; ] { } make ;
: (odbc-get-all-rows) ( statement -- ) : (odbc-get-all-rows) ( statement -- )
dup odbc-next-row [ dup odbc-get-row-fields , yield (odbc-get-all-rows) ] [ drop ] if ; dup odbc-next-row [
dup odbc-get-row-fields , yield (odbc-get-all-rows)
] [
drop
] if ;
: odbc-get-all-rows ( statement -- seq ) : odbc-get-all-rows ( statement -- seq )
[ (odbc-get-all-rows) ] { } make ; [ (odbc-get-all-rows) ] { } make ;