Dev C++ Get Data From Function
Pass your strings by reference and that will allow the called function to change them so the variables in the calling function will have the assigned values. The way you have it passing by value now, you are just sending a copy of the variables so the new values are lost when Input returns. As in C each function can return only one variable so here we need to have the getters equal to number of the data members so that each getter returns the value of one data member. The code below in this tutorial will have getters which will make things more clearer.
Conformance
Version Introduced: ODBC 1.0 Standards Compliance: ISO 92
Summary
SQLGetData retrieves data for a single column in the result set or for a single parameter after SQLParamData returns SQL_PARAM_DATA_AVAILABLE. It can be called multiple times to retrieve variable-length data in parts.
Syntax
Arguments
StatementHandle
[Input] Statement handle.
Col_or_Param_Num
[Input] For retrieving column data, it is the number of the column for which to return data. Result set columns are numbered in increasing column order starting at 1. The bookmark column is column number 0; this can be specified only if bookmarks are enabled.
Jul 21, 2016 A Guide to the Best Traktor Controllers. Need help finding the best Traktor controller for your needs? This is a comprehensive guide for Traktor Kontrol: a line of hardware for DJs by Native Instruments designed to integrate perfectly with Traktor software. Best controller for traktor pro 2. DJ Controller TRAKTOR has kept dancefloors moving for almost 20 years. Our DJ controllers are designed to help you create powerful DJ mixes with TRAKTOR PRO 3 software. From DJ controllers designed for the club, to portable DJ controllers you can fit in a backpack, there's a way for everybody to share the music and mixes they love. TRAKTOR controllers are designed and engineered in-house just a few steps away from TRAKTOR PRO 3. Native Instruments is the industry’s leading manufacturer for integrated hardware.
For retrieving parameter data, it is the ordinal of the parameter, which starts at 1.
TargetType
[Input] The type identifier of the C data type of the *TargetValuePtr buffer. For a list of valid C data types and type identifiers, see the C Data Types section in Appendix D: Data Types. Voice auto tune free download.
If TargetType is SQL_ARD_TYPE, the driver uses the type identifier specified in the SQL_DESC_CONCISE_TYPE field of the ARD. If TargetType is SQL_APD_TYPE, SQLGetData will use the same C data type that was specified in SQLBindParameter. Otherwise, the C data type specified in SQLGetData overrides the C data type specified in SQLBindParameter. If it is SQL_C_DEFAULT, the driver selects the default C data type based on the SQL data type of the source.
You can also specify an extended C data type. For more information, see C Data Types in ODBC.
TargetValuePtr
[Output] Pointer to the buffer in which to return the data.
TargetValuePtr cannot be NULL.
BufferLength
[Input] Length of the *TargetValuePtr buffer in bytes.
The driver uses BufferLength to avoid writing past the end of the *TargetValuePtr buffer when returning variable-length data, such as character or binary data. Note that the driver counts the null-termination character when returning character data to *TargetValuePtr. *TargetValuePtr must therefore contain space for the null-termination character, or the driver will truncate the data.
When the driver returns fixed-length data, such as an integer or a date structure, the driver ignores BufferLength and assumes the buffer is large enough to hold the data. It is therefore important for the application to allocate a large enough buffer for fixed-length data or the driver will write past the end of the buffer.
SQLGetData returns SQLSTATE HY090 (Invalid string or buffer length) when BufferLength is less than 0 but not when BufferLength is 0.
StrLen_or_IndPtr
[Output] Pointer to the buffer in which to return the length or indicator value. If this is a null pointer, no length or indicator value is returned. This returns an error when the data being fetched is NULL.
SQLGetData can return the following values in the length/indicator buffer:
The length of the data available to return
SQL_NO_TOTAL
SQL_NULL_DATA
For more information, see Using Length/Indicator Values and 'Comments' in this topic.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
Diagnostics
When SQLGetData returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by SQLGetData and explains each one in the context of this function; the notation '(DM)' precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.
SQLSTATE | Error | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
01000 | General warning | Driver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.) | ||||||||||||||||||||
01004 | String data, right truncated | Not all of the data for the specified column, Col_or_Param_Num, could be retrieved in a single call to the function. SQL_NO_TOTAL or the length of the data remaining in the specified column prior to the current call to SQLGetData is returned in *StrLen_or_IndPtr. (Function returns SQL_SUCCESS_WITH_INFO.) For more information on using multiple calls to SQLGetData for a single column, see 'Comments.' | ||||||||||||||||||||
01S07 | Fractional truncation | The data returned for one or more columns was truncated. For numeric data types, the fractional part of the number was truncated. For time, timestamp, and interval data types containing a time component, the fractional portion of the time was truncated. (Function returns SQL_SUCCESS_WITH_INFO.) | ||||||||||||||||||||
07006 | Restricted data type attribute violation | The data value of a column in the result set cannot be converted to the C data type specified by the argument TargetType. | ||||||||||||||||||||
07009 | Invalid descriptor index | The value specified for the argument Col_or_Param_Num was 0, and the SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF. The value specified for the argument Col_or_Param_Num was greater than the number of columns in the result set. The Col_or_Param_Num value was not equal to the ordinal of the parameter that is available. (DM) The specified column was bound. This description does not apply to drivers that return the SQL_GD_BOUND bitmask for the SQL_GETDATA_EXTENSIONS option in SQLGetInfo. (DM) The number of the specified column was less than or equal to the number of the highest bound column. This description does not apply to drivers that return the SQL_GD_ANY_COLUMN bitmask for the SQL_GETDATA_EXTENSIONS option in SQLGetInfo. (DM) The application has already called SQLGetData for the current row; the number of the column specified in the current call was less than the number of the column specified in the preceding call; and the driver does not return the SQL_GD_ANY_ORDER bitmask for the SQL_GETDATA_EXTENSIONS option in SQLGetInfo. (DM) The TargetType argument was SQL_ARD_TYPE, and the Col_or_Param_Num descriptor record in the ARD failed the consistency check. (DM) The TargetType argument was SQL_ARD_TYPE, and the value in the SQL_DESC_COUNT field of the ARD was less than the Col_or_Param_Num argument. | ||||||||||||||||||||
08S01 | Communication link failure | The communication link between the driver and the data source to which the driver was connected failed before the function completed processing. | ||||||||||||||||||||
22002 | Indicator variable required but not supplied | StrLen_or_IndPtr was a null pointer and NULL data was retrieved. | ||||||||||||||||||||
22003 | Numeric value out of range | Returning the numeric value (as numeric or string) for the column would have caused the whole (as opposed to fractional) part of the number to be truncated. For more information, see Appendix D: Data Types. | ||||||||||||||||||||
22007 | Invalid datetime format | The character column in the result set was bound to a C date, time, or timestamp structure, and the value in the column was an invalid date, time, or timestamp, respectively. For more information, see Appendix D: Data Types. | ||||||||||||||||||||
22012 | Division by zero | A value from an arithmetic expression that resulted in division by zero was returned. | ||||||||||||||||||||
22015 | Interval field overflow | Assigning from an exact numeric or interval SQL type to an interval C type caused a loss of significant digits in the leading field. When returning data to an interval C type, there was no representation of the value of the SQL type in the interval C type. | ||||||||||||||||||||
22018 | Invalid character value for cast specification | A character column in the result set was returned to a character C buffer, and the column contained a character for which there was no representation in the character set of the buffer. The C type was an exact or approximate numeric, a datetime, or an interval data type; the SQL type of the column was a character data type; and the value in the column was not a valid literal of the bound C type. | ||||||||||||||||||||
24000 | Invalid cursor state | (DM) The function was called without first calling SQLFetch or SQLFetchScroll to position the cursor on the row of data required. (DM) The StatementHandle was in an executed state, but no result set was associated with the StatementHandle. A cursor was open on the StatementHandle and SQLFetch or SQLFetchScroll had been called, but the cursor was positioned before the start of the result set or after the end of the result set. | ||||||||||||||||||||
HY000 | General error | An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the MessageText buffer describes the error and its cause. | ||||||||||||||||||||
HY001 | Memory allocation error | The driver was unable to allocate memory required to support execution or completion of the function. | ||||||||||||||||||||
HY003 | Program type out of range | (DM) The argument TargetType was not a valid data type, SQL_C_DEFAULT, SQL_ARD_TYPE (in case of retrieving column data), or SQL_APD_TYPE (in case of retrieving parameter data). (DM) The argument Col_or_Param_Num was 0, and the argument TargetType was not SQL_C_BOOKMARK for a fixed-length bookmark or SQL_C_VARBOOKMARK for a variable-length bookmark. | ||||||||||||||||||||
HY008 | Operation canceled | Asynchronous processing was enabled for the StatementHandle. The function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle, and then the function was called again on the StatementHandle. The function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application, and then the function was called again on the StatementHandle. | ||||||||||||||||||||
HY009 | Invalid use of null pointer | (DM) The argument TargetValuePtr was a null pointer. | ||||||||||||||||||||
HY010 | Function sequence error | (DM) The specified StatementHandle was not in an executed state. The function was called without first calling SQLExecDirect, SQLExecute or a catalog function. (DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. This asynchronous function was still executing when the SQLGetData function was called. (DM) An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called. (DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all Variable-length bookmarks can be returned in parts by SQLGetData. As with other data, a call to SQLGetData to return variable-length bookmarks in parts will return SQLSTATE 01004 (String data, right truncated) and SQL_SUCCESS_WITH_INFO when there is more data to be returned. This is different than the case when a variable-length bookmark is truncated by a call to SQLFetch or SQLFetchScroll, which returns SQL_ERROR and SQLSTATE 22001 (String data, right truncated). SQLGetData cannot be used to return fixed-length data in parts. If SQLGetData is called more than one time in a row for a column containing fixed-length data, it returns SQL_NO_DATA for all calls after the first. Retrieving Streamed Output ParametersIf a driver supports streamed output parameters, an application can call SQLGetData with a small buffer many times to retrieve a large parameter value. For more information about streamed output parameter, see Retrieving Output Parameters Using SQLGetData. Retrieving Data with SQLGetDataTo return data for the specified column, SQLGetData performs the following sequence of steps:
The contents of the bound data buffer (if SQLGetData is called on a bound column) and the length/indicator buffer are undefined if SQLGetData does not return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO. Successive calls to SQLGetData will retrieve data from the last column requested; prior offsets become invalid. For example, when the following sequence is performed: the second call to SQLGetData(icol=n) retrieves data from the start of the n column. Any offset in the data due to earlier calls to SQLGetData for the column is no longer valid. Descriptors and SQLGetDataSQLGetData does not interact directly with any descriptor fields. If TargetType is SQL_ARD_TYPE, the data type in the SQL_DESC_CONCISE_TYPE field of the ARD is used. If TargetType is either SQL_ARD_TYPE or SQL_C_DEFAULT, the data is given the precision and scale in the SQL_DESC_DATETIME_INTERVAL_PRECISION, SQL_DESC_PRECISION, and SQL_DESC_SCALE fields of the ARD, depending on the data type in the SQL_DESC_CONCISE_TYPE field. Code ExampleIn the following example, an application executes a SELECT statement to return a result set of the customer IDs, names, and phone numbers sorted by name, ID, and phone number. For each row of data, it calls SQLFetch to position the cursor to the next row. It calls SQLGetData to retrieve the fetched data; the buffers for the data and the returned number of bytes are specified in the call to SQLGetData. Finally, it prints each employee's name, ID, and phone number. Related Functions
See AlsoODBC API Reference |
Hi,
Dev C++ Programs
I have a txt file that contain certain data inside it.
Example of the txt file:
Name=John Age=20 Address=c-34, Newyork
Name=Martin Age=23 Address=123, New Delhi
..
..
and so on...
Now I have to process the each line get from the file and put the values into arrays.
arr_name, arr_age, arr_add will be filled from the file.
I have to read 1 line at a time, pass the values of arr_name, arr_age, arr_add to the other function to process it. Again back to the file processing function and read the second line, pass it to the function and similarly for other lines of the file.
How can I complete this task.
Thanks in advance.
Parvez
Dev C++ Get Data From Function Calculator
- 2 Contributors
- forum 5 Replies
- 4,072 Views
- 2 Days Discussion Span
- commentLatest Postby Ancient DragonLatest Post
Ancient Dragon5,243
There are several ways to do it, but one way is: in a loop call getline() to read each line, then for each line read use stringstream object to split it into individual tokens. Post the code you have attempted and we can help you some more.