1 // Copyright (c) 1999-2018 David Muse 2 // See the file COPYING for more information 3 4 using System; 5 using System.ComponentModel; 6 using System.Runtime.InteropServices; 7 using SQLRClient; 8 9 namespace SQLRClient 10 { 11 12 public class SQLRCursor : IDisposable 13 { 14 15 /** Creates a cursor to run queries and fetch 16 * result sets using connection "conn" */ SQLRCursor(SQLRConnection conn)17 public SQLRCursor(SQLRConnection conn) 18 { 19 sqlrcurref = sqlrcur_alloc_copyrefs(conn.getInternalConnectionStructure(), 1); 20 } 21 SQLRCursor(IntPtr sqlrcurref)22 private SQLRCursor(IntPtr sqlrcurref) 23 { 24 this.sqlrcurref = sqlrcurref; 25 } 26 27 /** Dispose framework */ 28 private Boolean disposed = false; Dispose()29 public void Dispose() 30 { 31 Dispose(true); 32 GC.SuppressFinalize(this); 33 } Dispose(Boolean disposing)34 protected virtual void Dispose(Boolean disposing) 35 { 36 if (!disposed) 37 { 38 sqlrcur_free(sqlrcurref); 39 disposed = true; 40 } 41 } 42 43 /** Destroys the cursor and cleans up all associated result set data. */ ~SQLRCursor()44 ~SQLRCursor() 45 { 46 Dispose(false); 47 } 48 49 50 51 /** Sets the number of rows of the result set to buffer at a time. 52 * 0 (the default) means buffer the entire result set. */ setResultSetBufferSize(UInt64 rows)53 public void setResultSetBufferSize(UInt64 rows) 54 { 55 sqlrcur_setResultSetBufferSize(sqlrcurref, rows); 56 } 57 58 /** Returns the number of result set rows that will be buffered at a time or 59 * 0 for the entire result set. */ getResultSetBufferSize()60 public UInt64 getResultSetBufferSize() 61 { 62 return sqlrcur_getResultSetBufferSize(sqlrcurref); 63 } 64 65 66 67 /** Tells the server not to send any column info (names, types, sizes). If 68 * you don't need that info, you should call this function to improve 69 * performance. */ dontGetColumnInfo()70 public void dontGetColumnInfo() 71 { 72 sqlrcur_dontGetColumnInfo(sqlrcurref); 73 } 74 75 /** Tells the server to send column info. */ getColumnInfo()76 public void getColumnInfo() 77 { 78 sqlrcur_getColumnInfo(sqlrcurref); 79 } 80 81 82 83 /** Columns names are returned in the same case as they are defined in the 84 * database. This is the default. */ mixedCaseColumnNames()85 public void mixedCaseColumnNames() 86 { 87 sqlrcur_mixedCaseColumnNames(sqlrcurref); 88 } 89 90 /** Columns names are converted to upper case. */ upperCaseColumnNames()91 public void upperCaseColumnNames() 92 { 93 sqlrcur_upperCaseColumnNames(sqlrcurref); 94 } 95 96 /** Columns names are converted to lower case. */ lowerCaseColumnNames()97 public void lowerCaseColumnNames() 98 { 99 sqlrcur_lowerCaseColumnNames(sqlrcurref); 100 } 101 102 103 104 105 /** Sets query caching on. Future queries will be cached to the 106 * file "filename". 107 * 108 * A default time-to-live of 10 minutes is also set. 109 * 110 * Note that once sqlrcur_cacheToFile() is called, the result sets of all 111 * future queries will be cached to that file until another call to 112 * sqlrcur_cacheToFile() changes which file to cache to or a call to 113 * sqlrcur_cacheOff() turns off caching. */ cacheToFile(String filename)114 public void cacheToFile(String filename) 115 { 116 sqlrcur_cacheToFile(sqlrcurref, filename); 117 } 118 119 /** Sets the time-to-live for cached result sets. The sqlr-cachemanger will 120 * remove each cached result set "ttl" seconds after it's created, provided 121 * it's scanning the directory containing the cache files. */ setCacheTtl(UInt32 ttl)122 public void setCacheTtl(UInt32 ttl) 123 { 124 sqlrcur_setCacheTtl(sqlrcurref, ttl); 125 } 126 127 /** Returns the name of the file containing 128 * the most recently cached result set. */ getCacheFileName()129 public String getCacheFileName() 130 { 131 return Marshal.PtrToStringAnsi(sqlrcur_getCacheFileName(sqlrcurref)); 132 } 133 134 /** Sets query caching off. */ cacheOff()135 public void cacheOff() 136 { 137 sqlrcur_cacheOff(sqlrcurref); 138 } 139 140 141 142 /** Sends a query that returns a list of databases/schemas matching "wild". 143 * If wild is empty or NULL then a list of all databases/schemas will be 144 * returned. */ getDatabaseList(String wild)145 public Boolean getDatabaseList(String wild) 146 { 147 return sqlrcur_getDatabaseList(sqlrcurref, wild) != 0; 148 } 149 150 /** Sends a query that returns a list of tables matching "wild". If wild is 151 * empty or NULL then a list of all tables will be returned. */ getTableList(String wild)152 public Boolean getTableList(String wild) 153 { 154 return sqlrcur_getTableList(sqlrcurref, wild) != 0; 155 } 156 157 /** Sends a query that returns a list of columns in the table specified by 158 * the "table" parameter matching "wild". If wild is empty or NULL then a 159 * list of all columns will be returned. */ getColumnList(String table, String wild)160 public Boolean getColumnList(String table, String wild) 161 { 162 return sqlrcur_getColumnList(sqlrcurref, table, wild) != 0; 163 } 164 165 166 167 /** Sends "query" directly and gets a result set. */ sendQuery(String query)168 public Boolean sendQuery(String query) 169 { 170 return sqlrcur_sendQueryWithLength(sqlrcurref, query, (uint)System.Text.Encoding.Default.GetByteCount(query)) != 0; 171 } 172 173 /** Sends "query" with length "length" directly and gets a result set. This 174 * function must be used if the query contains binary data. */ sendQuery(String query, UInt32 length)175 public Boolean sendQuery(String query, UInt32 length) 176 { 177 return sqlrcur_sendQueryWithLength(sqlrcurref, query, length) != 0; 178 } 179 180 /** Sends the query in file "path"/"filename" and gets a result set. */ sendFileQuery(String path, String filename)181 public Boolean sendFileQuery(String path, String filename) 182 { 183 return sqlrcur_sendFileQuery(sqlrcurref, path, filename) != 0; 184 } 185 186 187 188 /** Prepare to execute "query". */ prepareQuery(String query)189 public void prepareQuery(String query) 190 { 191 sqlrcur_prepareQueryWithLength(sqlrcurref, query, (uint)System.Text.Encoding.Default.GetByteCount(query)); 192 } 193 194 /** Prepare to execute "query" with length "length". This function must be 195 * used if the query contains binary data. */ prepareQuery(String query, UInt32 length)196 public void prepareQuery(String query, UInt32 length) 197 { 198 sqlrcur_prepareQueryWithLength(sqlrcurref, query, length); 199 } 200 201 /** Prepare to execute the contents of "path"/"filename". */ prepareFileQuery(String path, String filename)202 public void prepareFileQuery(String path, String filename) 203 { 204 sqlrcur_prepareFileQuery(sqlrcurref, path, filename); 205 } 206 207 208 209 /** Defines a String substitution variable. */ substitution(String variable, String val)210 public void substitution(String variable, String val) 211 { 212 sqlrcur_subString(sqlrcurref, variable, val); 213 } 214 215 /** Defines a integer substitution variable. */ substitution(String variable, Int64 val)216 public void substitution(String variable, Int64 val) 217 { 218 sqlrcur_subLong(sqlrcurref, variable, val); 219 } 220 221 /** Defines a decimal substitution variable. */ substitution(String variable, Double val, UInt32 precision, UInt32 scale)222 public void substitution(String variable, Double val, UInt32 precision, UInt32 scale) 223 { 224 sqlrcur_subDouble(sqlrcurref, variable, val, precision, scale); 225 } 226 227 /** Defines an array of String substitution variable. */ substitutions(String[] variables, String[] vals)228 public void substitutions(String[] variables, String[] vals) 229 { 230 for (Int32 i = 0; i < variables.Length; i++) 231 { 232 sqlrcur_subString(sqlrcurref, variables[i], vals[i]); 233 } 234 } 235 236 /** Defines an array of integer substitution variable. */ substitution(String[] variables, Int64[] vals)237 public void substitution(String[] variables, Int64[] vals) 238 { 239 for (Int32 i = 0; i < variables.Length; i++) 240 { 241 sqlrcur_subLong(sqlrcurref, variables[i], vals[i]); 242 } 243 } 244 245 /** Defines an array of decimal substitution variable. */ substitution(String[] variables, Double[] vals, UInt32[] precisions, UInt32[] scales)246 public void substitution(String[] variables, Double[] vals, UInt32[] precisions, UInt32[] scales) 247 { 248 for (Int32 i = 0; i < variables.Length; i++) 249 { 250 sqlrcur_subDouble(sqlrcurref, variables[i], vals[i], precisions[i], scales[i]); 251 } 252 } 253 254 255 256 /** Defines a String input bind variable. */ inputBind(String variable, String val)257 public void inputBind(String variable, String val) 258 { 259 sqlrcur_inputBindStringWithLength(sqlrcurref, variable, val, (val != null) ? (uint)System.Text.Encoding.Default.GetByteCount(val) : 0); 260 } 261 262 /** Defines a String input bind variable. */ inputBind(String variable, String val, UInt32 vallength)263 public void inputBind(String variable, String val, UInt32 vallength) 264 { 265 sqlrcur_inputBindStringWithLength(sqlrcurref, variable, val, vallength); 266 } 267 268 /** Defines a integer input bind variable. */ inputBind(String variable, Int64 val)269 public void inputBind(String variable, Int64 val) 270 { 271 sqlrcur_inputBindLong(sqlrcurref, variable, val); 272 } 273 274 /** Defines a decimal input bind variable. 275 * (If you don't have the precision and scale then set 276 * them both to 0. However in that case you may get 277 * unexpected rounding behavior if the server is faking 278 * binds.) */ inputBind(String variable, Double val, UInt32 precision, UInt32 scale)279 public void inputBind(String variable, Double val, UInt32 precision, UInt32 scale) 280 { 281 sqlrcur_inputBindDouble(sqlrcurref, variable, val, precision, scale); 282 } 283 284 /** Defines an array of String input bind variables. */ inputBind(String[] variables, String[] vals)285 public void inputBind(String[] variables, String[] vals) 286 { 287 for (UInt32 i = 0; i < variables.Length; i++) 288 { 289 sqlrcur_inputBindString(sqlrcurref, variables[i], vals[i]); 290 } 291 } 292 293 /** Defines an array of integer input bind variables. */ inputBind(String[] variables, Int64[] vals)294 public void inputBind(String[] variables, Int64[] vals) 295 { 296 for (UInt32 i = 0; i < variables.Length; i++) 297 { 298 sqlrcur_inputBindLong(sqlrcurref, variables[i], vals[i]); 299 } 300 } 301 302 /** Defines an array of decimal input bind variables. 303 * (If you don't have the precision and scale then set 304 * them both to 0. However in that case you may get 305 * unexpected rounding behavior if the server is faking 306 * binds.) */ inputBinds(String[] variables, Double[] vals, UInt32[] precisions, UInt32[] scales)307 public void inputBinds(String[] variables, Double[] vals, UInt32[] precisions, UInt32[] scales) 308 { 309 for (UInt32 i = 0; i < variables.Length; i++) 310 { 311 sqlrcur_inputBindDouble(sqlrcurref, variables[i], vals[i], precisions[i], scales[i]); 312 } 313 } 314 315 /** Defines a date input bind variable. "day" should be 316 * 1-31 and "month" should be 1-12. "tz" may be left NULL. 317 * Most databases ignore "tz". */ inputBind(String variable, Int16 year, Int16 month, Int16 day, Int16 hour, Int16 minute, Int16 second, Int32 microsecond, String tz, Boolean isnegative)318 public void inputBind(String variable, Int16 year, Int16 month, Int16 day, Int16 hour, Int16 minute, Int16 second, Int32 microsecond, String tz, Boolean isnegative) 319 { 320 sqlrcur_inputBindDate(sqlrcurref, variable, year, month, day, hour, minute, second, microsecond, tz, (isnegative) ? 1 : 0); 321 } 322 323 /** Defines a binary lob input bind variable. */ inputBindBlob(String variable, Byte[] val, UInt32 size)324 public void inputBindBlob(String variable, Byte[] val, UInt32 size) 325 { 326 sqlrcur_inputBindBlob(sqlrcurref, variable, val, size); 327 } 328 329 /** Defines a character lob input bind variable. */ inputBindClob(String variable, String val, UInt32 size)330 public void inputBindClob(String variable, String val, UInt32 size) 331 { 332 sqlrcur_inputBindClob(sqlrcurref, variable, val, size); 333 } 334 335 336 337 /** Defines a String output bind variable. 338 * "length" Bytes will be reserved to store the value. */ defineOutputBindString(String variable, UInt32 length)339 public void defineOutputBindString(String variable, UInt32 length) 340 { 341 sqlrcur_defineOutputBindString(sqlrcurref, variable, length); 342 } 343 344 /** Defines an integer output bind variable. */ defineOutputBindInteger(String variable)345 public void defineOutputBindInteger(String variable) 346 { 347 sqlrcur_defineOutputBindInteger(sqlrcurref, variable); 348 } 349 350 /** Defines an decimal output bind variable. */ defineOutputBindDouble(String variable)351 public void defineOutputBindDouble(String variable) 352 { 353 sqlrcur_defineOutputBindDouble(sqlrcurref, variable); 354 } 355 356 /** Defines an date output bind variable. */ defineOutputBindDate(String variable)357 public void defineOutputBindDate(String variable) 358 { 359 sqlrcur_defineOutputBindDate(sqlrcurref, variable); 360 } 361 362 /** Defines a binary lob output bind variable */ defineOutputBindBlob(String variable)363 public void defineOutputBindBlob(String variable) 364 { 365 sqlrcur_defineOutputBindBlob(sqlrcurref, variable); 366 } 367 368 /** Defines a character lob output bind variable */ defineOutputBindClob(String variable)369 public void defineOutputBindClob(String variable) 370 { 371 sqlrcur_defineOutputBindClob(sqlrcurref, variable); 372 } 373 374 /** Defines a cursor output bind variable */ defineOutputBindCursor(String variable)375 public void defineOutputBindCursor(String variable) 376 { 377 sqlrcur_defineOutputBindCursor(sqlrcurref, variable); 378 } 379 380 381 382 /** Clears all bind variables. */ clearBinds()383 public void clearBinds() 384 { 385 sqlrcur_clearBinds(sqlrcurref); 386 } 387 388 /** Parses the previously prepared query, counts the number of bind 389 * variables defined in it and returns that number. */ countBindVariables()390 public UInt16 countBindVariables() 391 { 392 return sqlrcur_countBindVariables(sqlrcurref); 393 } 394 395 /** If you are binding to any variables that might not actually be in your 396 * query, call this to ensure that the database won't try to bind them 397 * unless they really are in the query. There is a performance penalty 398 * for calling this function */ validateBinds()399 public void validateBinds() 400 { 401 sqlrcur_validateBinds(sqlrcurref); 402 } 403 404 /** Returns true if "variable" was a valid bind variable of the query. */ validBind(String variable)405 public Boolean validBind(String variable) 406 { 407 return sqlrcur_validBind(sqlrcurref, variable) != 0; 408 } 409 410 411 412 /** Execute the query that was previously prepared and bound. */ executeQuery()413 public Boolean executeQuery() 414 { 415 return sqlrcur_executeQuery(sqlrcurref) != 0; 416 } 417 418 /** Fetch from a cursor that was returned as an output bind variable. */ fetchFromBindCursor()419 public Boolean fetchFromBindCursor() 420 { 421 return sqlrcur_fetchFromBindCursor(sqlrcurref) != 0; 422 } 423 424 425 426 /** Get the value stored in a previously defined 427 * String output bind variable. */ getOutputBindString(String variable)428 public String getOutputBindString(String variable) 429 { 430 return Marshal.PtrToStringAnsi(sqlrcur_getOutputBindString(sqlrcurref, variable)); 431 } 432 433 /** Get the value stored in a previously defined 434 * integer output bind variable. */ getOutputBindInteger(String variable)435 public Int64 getOutputBindInteger(String variable) 436 { 437 return sqlrcur_getOutputBindInteger(sqlrcurref, variable); 438 } 439 440 /** Get the value stored in a previously defined 441 * decimal output bind variable. */ getOutputBindDouble(String variable)442 public double getOutputBindDouble(String variable) 443 { 444 return sqlrcur_getOutputBindDouble(sqlrcurref, variable); 445 } 446 447 /** Get the value stored in a previously defined 448 * decimal output bind variable. */ getOutputBindDate(String variable, out Int16 year, out Int16 month, out Int16 day, out Int16 hour, out Int16 minute, out Int16 second, out Int32 microsecond, out String tz, out Boolean isnegative)449 public Boolean getOutputBindDate(String variable, out Int16 year, out Int16 month, out Int16 day, out Int16 hour, out Int16 minute, out Int16 second, out Int32 microsecond, out String tz, out Boolean isnegative) 450 { 451 year = -1; 452 month = -1; 453 day = -1; 454 hour = -1; 455 minute = -1; 456 second = -1; 457 microsecond = -1; 458 tz = ""; 459 isnegative = false; 460 IntPtr tzptr = (IntPtr)0; 461 Int32 isneg = 0; 462 sqlrcur_getOutputBindDate(sqlrcurref, variable, ref year, ref month, ref day, ref hour, ref minute, ref second, ref microsecond, ref tzptr, ref isneg); 463 tz = Marshal.PtrToStringAnsi(tzptr); 464 isnegative = (isneg!=0); 465 return false; 466 } 467 468 /** Get the value stored in a previously defined 469 * binary lob output bind variable. */ getOutputBindBlob(String variable)470 public Byte[] getOutputBindBlob(String variable) 471 { 472 Int32 size = (Int32)sqlrcur_getOutputBindLength(sqlrcurref, variable); 473 if (size == 0) 474 { 475 return null; 476 } 477 Byte[] retval = new Byte[size]; 478 Marshal.Copy(sqlrcur_getOutputBindBlob(sqlrcurref, variable), retval, 0, size); 479 return retval; 480 } 481 482 /** Get the value stored in a previously defined 483 * character lob output bind variable. */ getOutputBindClob(String variable)484 public String getOutputBindClob(String variable) 485 { 486 return Marshal.PtrToStringAnsi(sqlrcur_getOutputBindClob(sqlrcurref, variable)); 487 } 488 489 /** Get the length of the value stored in a previously 490 * defined output bind variable. */ getOutputBindLength(String variable)491 public UInt32 getOutputBindLength(String variable) 492 { 493 return sqlrcur_getOutputBindLength(sqlrcurref, variable); 494 } 495 496 /** Get the cursor associated with a previously defined output bind 497 * variable. */ getOutputBindCursor(String variable)498 public SQLRCursor getOutputBindCursor(String variable) 499 { 500 return new SQLRCursor(sqlrcur_getOutputBindCursor_copyrefs(sqlrcurref, variable, 1)); 501 } 502 503 504 505 /** Opens a cached result set. Returns true on success and 506 * false on failure. */ openCachedResultSet(String filename)507 public Boolean openCachedResultSet(String filename) 508 { 509 return sqlrcur_openCachedResultSet(sqlrcurref, filename)!=0; 510 } 511 512 513 514 /** Returns the number of columns in the current result set. */ colCount()515 public UInt32 colCount() 516 { 517 return sqlrcur_colCount(sqlrcurref); 518 } 519 520 /** Returns the number of rows in the current result set. */ rowCount()521 public UInt64 rowCount() 522 { 523 return sqlrcur_rowCount(sqlrcurref); 524 } 525 526 /** Returns the total number of rows that will be returned in the result 527 * set. Not all databases support this call. Don't use it for 528 * applications which are designed to be portable across databases. -1 529 * is returned by databases which don't support this option. */ totalRows()530 public UInt64 totalRows() 531 { 532 return sqlrcur_totalRows(sqlrcurref); 533 } 534 535 /** Returns the number of rows that were updated, inserted or deleted by 536 * the query. Not all databases support this call. Don't use it for 537 * applications which are designed to be portable across databases. -1 538 * is returned by databases which don't support this option. */ affectedRows()539 public UInt64 affectedRows() 540 { 541 return sqlrcur_affectedRows(sqlrcurref); 542 } 543 544 /** Returns the index of the first buffered row. This is useful when 545 * buffering only part of the result set at a time. */ firstRowIndex()546 public UInt64 firstRowIndex() 547 { 548 return sqlrcur_firstRowIndex(sqlrcurref); 549 } 550 551 /** Returns false if part of the result set is still pending on the server 552 * and true if not. This function can only return false if 553 * setResultSetBufferSize() has been called with a parameter other than 554 * 0. */ endOfResultSet()555 public Boolean endOfResultSet() 556 { 557 return sqlrcur_endOfResultSet(sqlrcurref)!=0; 558 } 559 560 561 562 /** If a query failed and generated an error, the error message is available 563 * here. If the query succeeded then this function returns a NULL. */ errorMessage()564 public String errorMessage() 565 { 566 return Marshal.PtrToStringAnsi(sqlrcur_errorMessage(sqlrcurref)); 567 } 568 569 /** If a query failed and generated an error, the error number is available 570 * here. If there is no error then this method returns 0. */ errorNumber()571 public Int64 errorNumber() 572 { 573 return sqlrcur_errorNumber(sqlrcurref); 574 } 575 576 577 /** Tells the connection to return NULL fields and output bind variables as 578 * empty strings. This is the default. */ getNullsAsEmptyStrings()579 public void getNullsAsEmptyStrings() 580 { 581 sqlrcur_getNullsAsEmptyStrings(sqlrcurref); 582 } 583 584 /** Tells the connection to return NULL fields 585 * and output bind variables as NULL's. */ getNullsAsNulls()586 public void getNullsAsNulls() 587 { 588 sqlrcur_getNullsAsNulls(sqlrcurref); 589 } 590 591 592 593 /** Returns the specified field as a string. */ getField(UInt64 row, UInt32 col)594 public String getField(UInt64 row, UInt32 col) 595 { 596 // if we're getting nulls as nulls or we've run off the end of the result set, 597 // return a null for a null field 598 if (sqlrcur_getFieldByIndex(sqlrcurref, row, col) == IntPtr.Zero) 599 { 600 return null; 601 } 602 603 // if we're getting nulls as empty strings, return an empty string for a null field 604 Byte[] field = getFieldAsByteArray(row,col); 605 if (field == null) 606 { 607 return ""; 608 } 609 610 // if we didn't get a null field, return an actual string 611 return System.Text.Encoding.Default.GetString(field); 612 } 613 614 /** Returns the specified field as a string. */ getField(UInt64 row, String col)615 public String getField(UInt64 row, String col) 616 { 617 // if we're getting nulls as nulls or we've run off the end of the result set, 618 // return a null for a null field 619 if (sqlrcur_getFieldByName(sqlrcurref, row, col) == IntPtr.Zero) 620 { 621 return null; 622 } 623 624 // if we're getting nulls as empty strings, return an empty string for a null field 625 Byte[] field = getFieldAsByteArray(row, col); 626 if (field == null) 627 { 628 return ""; 629 } 630 631 // if we didn't get a null field, return an actual string 632 return System.Text.Encoding.Default.GetString(field); 633 } 634 635 /** Returns the specified field as an integer. */ getFieldAsInteger(UInt64 row, UInt32 col)636 public Int64 getFieldAsInteger(UInt64 row, UInt32 col) 637 { 638 return sqlrcur_getFieldAsIntegerByIndex(sqlrcurref, row, col); 639 } 640 641 /** Returns the specified field as an integer. */ getFieldAsInteger(UInt64 row, String col)642 public Int64 getFieldAsInteger(UInt64 row, String col) 643 { 644 return sqlrcur_getFieldAsIntegerByName(sqlrcurref, row, col); 645 } 646 647 /** Returns the specified field as an decimal. */ getFieldAsDouble(UInt64 row, UInt32 col)648 public Double getFieldAsDouble(UInt64 row, UInt32 col) 649 { 650 return sqlrcur_getFieldAsDoubleByIndex(sqlrcurref, row, col); 651 } 652 653 /** Returns the specified field as an decimal. */ getFieldAsDouble(UInt64 row, String col)654 public Double getFieldAsDouble(UInt64 row, String col) 655 { 656 return sqlrcur_getFieldAsDoubleByName(sqlrcurref, row, col); 657 } 658 659 /** Returns the specified field as a string. */ getFieldAsByteArray(UInt64 row, UInt32 col)660 public Byte[] getFieldAsByteArray(UInt64 row, UInt32 col) 661 { 662 Int32 size = (Int32)sqlrcur_getFieldLengthByIndex(sqlrcurref, row, col); 663 if (size == 0) 664 { 665 return null; 666 } 667 Byte[] retval = new Byte[size]; 668 Marshal.Copy(sqlrcur_getFieldByIndex(sqlrcurref, row, col), retval, 0, size); 669 return retval; 670 } 671 672 /** Returns the specified field as a string. */ getFieldAsByteArray(UInt64 row, String col)673 public Byte[] getFieldAsByteArray(UInt64 row, String col) 674 { 675 Int32 size = (Int32)sqlrcur_getFieldLengthByName(sqlrcurref, row, col); 676 if (size == 0) 677 { 678 return null; 679 } 680 Byte[] retval = new Byte[size]; 681 Marshal.Copy(sqlrcur_getFieldByName(sqlrcurref, row, col), retval, 0, size); 682 return retval; 683 } 684 685 686 687 /** Returns the length of the specified row and column. */ getFieldLength(UInt64 row, UInt32 col)688 public UInt32 getFieldLength(UInt64 row, UInt32 col) 689 { 690 return sqlrcur_getFieldLengthByIndex(sqlrcurref, row, col); 691 } 692 693 /** Returns the length of the specified row and column. */ getFieldLength(UInt64 row, String col)694 public UInt32 getFieldLength(UInt64 row, String col) 695 { 696 return sqlrcur_getFieldLengthByName(sqlrcurref, row, col); 697 } 698 699 /** Returns an array of the values of the fields in the 700 * specified row. */ getRow(UInt64 row)701 public String[] getRow(UInt64 row) 702 { 703 UInt32 colcount = sqlrcur_colCount(sqlrcurref); 704 String[] retval = new String[colcount]; 705 for (UInt32 i = 0; i < colcount; i++) 706 { 707 retval[i] = getField(row, i); 708 } 709 return retval; 710 } 711 712 /** Returns an array of the lengths of the fields in the 713 * specified row. */ getRowLengths(UInt64 row)714 public UInt32[] getRowLengths(UInt64 row) 715 { 716 UInt32 colcount = sqlrcur_colCount(sqlrcurref); 717 UInt32[] retval = new UInt32[colcount]; 718 for (UInt32 i = 0; i < colcount; i++) 719 { 720 retval[i] = getFieldLength(row, i); 721 } 722 return retval; 723 } 724 725 /** Returns the name of the specified column. */ getColumnName(UInt32 col)726 public String getColumnName(UInt32 col) 727 { 728 return Marshal.PtrToStringAnsi(sqlrcur_getColumnName(sqlrcurref, col)); 729 } 730 731 /** Returns the type of the specified column. */ getColumnType(UInt32 col)732 public String getColumnType(UInt32 col) 733 { 734 return Marshal.PtrToStringAnsi(sqlrcur_getColumnTypeByIndex(sqlrcurref, col)); 735 } 736 737 /** Returns the type of the specified column. */ getColumnType(String col)738 public String getColumnType(String col) 739 { 740 return Marshal.PtrToStringAnsi(sqlrcur_getColumnTypeByName(sqlrcurref, col)); 741 } 742 743 /** Returns the length of the specified column. */ getColumnLength(UInt32 col)744 public UInt32 getColumnLength(UInt32 col) 745 { 746 return sqlrcur_getColumnLengthByIndex(sqlrcurref, col); 747 } 748 749 /** Returns the length of the specified column. */ getColumnLength(String col)750 public UInt32 getColumnLength(String col) 751 { 752 return sqlrcur_getColumnLengthByName(sqlrcurref, col); 753 } 754 755 /** Returns the precision of the specified column. Precision is the total 756 * number of digits in a number. eg: 123.45 has a precision of 5. For 757 * non-numeric types, it's the number of characters in the string. */ getColumnPrecision(UInt32 col)758 public UInt32 getColumnPrecision(UInt32 col) 759 { 760 return sqlrcur_getColumnPrecisionByIndex(sqlrcurref, col); 761 } 762 763 /** Returns the precision of the specified column. Precision is the total 764 * number of digits in a number. eg: 123.45 has a precision of 5. For 765 * non-numeric types, it's the number of characters in the string. */ getColumnPrecision(String col)766 public UInt32 getColumnPrecision(String col) 767 { 768 return sqlrcur_getColumnPrecisionByName(sqlrcurref, col); 769 } 770 771 /** Returns the scale of the specified column. Scale is the total number of 772 * digits to the right of the decimal poInt32 in a number. eg: 123.45 has a 773 * scale of 2. */ getColumnScale(UInt32 col)774 public UInt32 getColumnScale(UInt32 col) 775 { 776 return sqlrcur_getColumnScaleByIndex(sqlrcurref, col); 777 } 778 779 /** Returns the scale of the specified column. Scale is the total number of 780 * digits to the right of the decimal poInt32 in a number. eg: 123.45 has a 781 * scale of 2. */ getColumnScale(String col)782 public UInt32 getColumnScale(String col) 783 { 784 return sqlrcur_getColumnScaleByName(sqlrcurref, col); 785 } 786 787 /** Returns true if the specified column can contain 788 * nulls and false otherwise. */ getColumnIsNullable(UInt32 col)789 public Boolean getColumnIsNullable(UInt32 col) 790 { 791 return sqlrcur_getColumnIsNullableByIndex(sqlrcurref, col)!=0; 792 } 793 794 /** Returns true if the specified column can contain 795 * nulls and false otherwise. */ getColumnIsNullable(String col)796 public Boolean getColumnIsNullable(String col) 797 { 798 return sqlrcur_getColumnIsNullableByName(sqlrcurref, col)!=0; 799 } 800 801 /** Returns true if the specified column is a 802 * primary key and false otherwise. */ getColumnIsPrimaryKey(UInt32 col)803 public Boolean getColumnIsPrimaryKey(UInt32 col) 804 { 805 return sqlrcur_getColumnIsPrimaryKeyByIndex(sqlrcurref, col)!=0; 806 } 807 808 /** Returns true if the specified column is a 809 * primary key and false otherwise. */ getColumnIsPrimaryKey(String col)810 public Boolean getColumnIsPrimaryKey(String col) 811 { 812 return sqlrcur_getColumnIsPrimaryKeyByName(sqlrcurref, col)!=0; 813 } 814 815 /** Returns true if the specified column is unique and false otherwise. */ getColumnIsUnique(UInt32 col)816 public Boolean getColumnIsUnique(UInt32 col) 817 { 818 return sqlrcur_getColumnIsUniqueByIndex(sqlrcurref, col)!=0; 819 } 820 821 /** Returns true if the specified column is unique and false otherwise. */ getColumnIsUnique(String col)822 public Boolean getColumnIsUnique(String col) 823 { 824 return sqlrcur_getColumnIsUniqueByName(sqlrcurref, col)!=0; 825 } 826 827 /** Returns true if the specified column is part of a composite key and 828 * false otherwise. */ getColumnIsPartOfKey(UInt32 col)829 public Boolean getColumnIsPartOfKey(UInt32 col) 830 { 831 return sqlrcur_getColumnIsPartOfKeyByIndex(sqlrcurref, col)!=0; 832 } 833 834 /** Returns true if the specified column is part of a composite key and 835 * false otherwise. */ getColumnIsPartOfKey(String col)836 public Boolean getColumnIsPartOfKey(String col) 837 { 838 return sqlrcur_getColumnIsPartOfKeyByName(sqlrcurref, col)!=0; 839 } 840 841 /** Returns true if the specified column is an unsigned number and false 842 * otherwise. */ getColumnIsUnsigned(UInt32 col)843 public Boolean getColumnIsUnsigned(UInt32 col) 844 { 845 return sqlrcur_getColumnIsUnsignedByIndex(sqlrcurref, col)!=0; 846 } 847 848 /** Returns true if the specified column is an unsigned number and false 849 * otherwise. */ getColumnIsUnsigned(String col)850 public Boolean getColumnIsUnsigned(String col) 851 { 852 return sqlrcur_getColumnIsUnsignedByName(sqlrcurref, col)!=0; 853 } 854 855 /** Returns true if the specified column was created 856 * with the zero-fill flag and false otherwise. */ getColumnIsZeroFilled(UInt32 col)857 public Boolean getColumnIsZeroFilled(UInt32 col) 858 { 859 return sqlrcur_getColumnIsZeroFilledByIndex(sqlrcurref, col)!=0; 860 } 861 862 /** Returns true if the specified column was created 863 * with the zero-fill flag and false otherwise. */ getColumnIsZeroFilled(String col)864 public Boolean getColumnIsZeroFilled(String col) 865 { 866 return sqlrcur_getColumnIsZeroFilledByName(sqlrcurref, col)!=0; 867 } 868 869 /** Returns true if the specified column contains binary data and false 870 * otherwise. */ getColumnIsBinary(UInt32 col)871 public Boolean getColumnIsBinary(UInt32 col) 872 { 873 return sqlrcur_getColumnIsBinaryByIndex(sqlrcurref, col)!=0; 874 } 875 876 /** Returns true if the specified column contains binary data and false 877 * otherwise. */ getColumnIsBinary(String col)878 public Boolean getColumnIsBinary(String col) 879 { 880 return sqlrcur_getColumnIsBinaryByName(sqlrcurref, col)!=0; 881 } 882 883 /** Returns true if the specified column auto-increments 884 * and false otherwise. */ getColumnIsAutoIncrement(UInt32 col)885 public Boolean getColumnIsAutoIncrement(UInt32 col) 886 { 887 return sqlrcur_getColumnIsAutoIncrementByIndex(sqlrcurref, col)!=0; 888 } 889 890 /** Returns true if the specified column auto-increments 891 * and false otherwise. */ getColumnIsAutoIncrement(String col)892 public Boolean getColumnIsAutoIncrement(String col) 893 { 894 return sqlrcur_getColumnIsAutoIncrementByName(sqlrcurref, col)!=0; 895 } 896 897 /** Returns the length of the longest field in the specified column. */ getLongest(UInt32 col)898 public UInt32 getLongest(UInt32 col) 899 { 900 return sqlrcur_getLongestByIndex(sqlrcurref, col); 901 } 902 903 /** Returns the length of the longest field in the specified column. */ getLongest(String col)904 public UInt32 getLongest(String col) 905 { 906 return sqlrcur_getLongestByName(sqlrcurref, col); 907 } 908 909 910 911 /** Tells the server to leave this result set open when the connection calls 912 * suspendSession() so that another connection can connect to it using 913 * resumeResultSet() after it calls resumeSession(). */ suspendResultSet()914 public void suspendResultSet() 915 { 916 sqlrcur_suspendResultSet(sqlrcurref); 917 } 918 919 /** Returns the internal ID of this result set. This parameter may be 920 * passed to another statement for use in the resumeResultSet() function. 921 * Note: The value this function returns is only valid after a call to 922 * suspendResultSet().*/ getResultSetId()923 public UInt16 getResultSetId() 924 { 925 return sqlrcur_getResultSetId(sqlrcurref); 926 } 927 928 /** Resumes a result set previously left open using suspendSession(). 929 * Returns true on success and false on failure. */ resumeResultSet(UInt16 id)930 public Boolean resumeResultSet(UInt16 id) 931 { 932 return sqlrcur_resumeResultSet(sqlrcurref, id)!=0; 933 } 934 935 /** Resumes a result set previously left open using suspendSession() and 936 * continues caching the result set to "filename". Returns true on success 937 * and false on failure. */ resumeCachedResultSet(UInt16 id, String filename)938 public Boolean resumeCachedResultSet(UInt16 id, String filename) 939 { 940 return sqlrcur_resumeCachedResultSet(sqlrcurref, id, filename)!=0; 941 } 942 943 /** Closes the current result set, if one is open. Data 944 * that has been fetched already is still available but 945 * no more data may be fetched. Server side resources 946 * for the result set are freed as well. */ closeResultSet()947 public void closeResultSet() 948 { 949 sqlrcur_closeResultSet(sqlrcurref); 950 } 951 952 private IntPtr sqlrcurref; 953 954 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_alloc_copyrefs(IntPtr sqlrconref, Int32 copyrefs)955 private static extern IntPtr sqlrcur_alloc_copyrefs(IntPtr sqlrconref, Int32 copyrefs); 956 957 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_free(IntPtr sqlrcurref)958 private static extern void sqlrcur_free(IntPtr sqlrcurref); 959 960 961 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_setResultSetBufferSize(IntPtr sqlrcurref, UInt64 rows)962 private static extern void sqlrcur_setResultSetBufferSize(IntPtr sqlrcurref, UInt64 rows); 963 964 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getResultSetBufferSize(IntPtr sqlrcurref)965 private static extern UInt64 sqlrcur_getResultSetBufferSize(IntPtr sqlrcurref); 966 967 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_dontGetColumnInfo(IntPtr sqlrcurref)968 private static extern void sqlrcur_dontGetColumnInfo(IntPtr sqlrcurref); 969 970 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnInfo(IntPtr sqlrcurref)971 private static extern void sqlrcur_getColumnInfo(IntPtr sqlrcurref); 972 973 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_mixedCaseColumnNames(IntPtr sqlrcurref)974 private static extern void sqlrcur_mixedCaseColumnNames(IntPtr sqlrcurref); 975 976 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_upperCaseColumnNames(IntPtr sqlrcurref)977 private static extern void sqlrcur_upperCaseColumnNames(IntPtr sqlrcurref); 978 979 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_lowerCaseColumnNames(IntPtr sqlrcurref)980 private static extern void sqlrcur_lowerCaseColumnNames(IntPtr sqlrcurref); 981 982 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_cacheToFile(IntPtr sqlrcurref, String filename)983 private static extern void sqlrcur_cacheToFile(IntPtr sqlrcurref, String filename); 984 985 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_setCacheTtl(IntPtr sqlrcurref, UInt32 ttl)986 private static extern void sqlrcur_setCacheTtl(IntPtr sqlrcurref, UInt32 ttl); 987 988 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getCacheFileName(IntPtr sqlrcurref)989 private static extern IntPtr sqlrcur_getCacheFileName(IntPtr sqlrcurref); 990 991 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_cacheOff(IntPtr sqlrcurref)992 private static extern void sqlrcur_cacheOff(IntPtr sqlrcurref); 993 994 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getDatabaseList(IntPtr sqlrcurref, String wild)995 private static extern Int32 sqlrcur_getDatabaseList(IntPtr sqlrcurref, String wild); 996 997 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getTableList(IntPtr sqlrcurref, String wild)998 private static extern Int32 sqlrcur_getTableList(IntPtr sqlrcurref, String wild); 999 1000 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnList(IntPtr sqlrcurref, String table, String wild)1001 private static extern Int32 sqlrcur_getColumnList(IntPtr sqlrcurref, String table, String wild); 1002 1003 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_sendQuery(IntPtr sqlrcurref, String query)1004 private static extern Int32 sqlrcur_sendQuery(IntPtr sqlrcurref, String query); 1005 1006 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_sendQueryWithLength(IntPtr sqlrcurref, String query, UInt32 length)1007 private static extern Int32 sqlrcur_sendQueryWithLength(IntPtr sqlrcurref, String query, UInt32 length); 1008 1009 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_sendFileQuery(IntPtr sqlrcurref, String path, String filename)1010 private static extern Int32 sqlrcur_sendFileQuery(IntPtr sqlrcurref, String path, String filename); 1011 1012 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_prepareQuery(IntPtr sqlrcurref, String query)1013 private static extern void sqlrcur_prepareQuery(IntPtr sqlrcurref, String query); 1014 1015 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_prepareQueryWithLength(IntPtr sqlrcurref, String query, UInt32 length)1016 private static extern void sqlrcur_prepareQueryWithLength(IntPtr sqlrcurref, String query, UInt32 length); 1017 1018 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_prepareFileQuery(IntPtr sqlrcurref, String path, String filename)1019 private static extern void sqlrcur_prepareFileQuery(IntPtr sqlrcurref, String path, String filename); 1020 1021 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_subString(IntPtr sqlrcurref, String variable, String val)1022 private static extern void sqlrcur_subString(IntPtr sqlrcurref, String variable, String val); 1023 1024 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_subLong(IntPtr sqlrcurref, String variable, Int64 val)1025 private static extern void sqlrcur_subLong(IntPtr sqlrcurref, String variable, Int64 val); 1026 1027 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_subDouble(IntPtr sqlrcurref, String variable, Double val, UInt32 precision, UInt32 scale)1028 private static extern void sqlrcur_subDouble(IntPtr sqlrcurref, String variable, Double val, UInt32 precision, UInt32 scale); 1029 1030 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindString(IntPtr sqlrcurref, String variable, String val)1031 private static extern void sqlrcur_inputBindString(IntPtr sqlrcurref, String variable, String val); 1032 1033 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindStringWithLength(IntPtr sqlrcurref, String variable, String val, UInt32 vallength)1034 private static extern void sqlrcur_inputBindStringWithLength(IntPtr sqlrcurref, String variable, String val, UInt32 vallength); 1035 1036 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindLong(IntPtr sqlrcurref, String variable, Int64 val)1037 private static extern void sqlrcur_inputBindLong(IntPtr sqlrcurref, String variable, Int64 val); 1038 1039 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindDouble(IntPtr sqlrcurref, String variable, Double val, UInt32 precision, UInt32 scale)1040 private static extern void sqlrcur_inputBindDouble(IntPtr sqlrcurref, String variable, Double val, UInt32 precision, UInt32 scale); 1041 1042 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindDate(IntPtr sqlrcurref, String variable, Int16 year, Int16 month, Int16 day, Int16 hour, Int16 minute, Int16 second, Int32 microsecond, String tz, Int32 isnegative)1043 private static extern void sqlrcur_inputBindDate(IntPtr sqlrcurref, String variable, Int16 year, Int16 month, Int16 day, Int16 hour, Int16 minute, Int16 second, Int32 microsecond, String tz, Int32 isnegative); 1044 1045 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindBlob(IntPtr sqlrcurref, String variable, Byte[] val, UInt32 size)1046 private static extern void sqlrcur_inputBindBlob(IntPtr sqlrcurref, String variable, Byte[] val, UInt32 size); 1047 1048 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_inputBindClob(IntPtr sqlrcurref, String variable, String val, UInt32 size)1049 private static extern void sqlrcur_inputBindClob(IntPtr sqlrcurref, String variable, String val, UInt32 size); 1050 1051 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindString(IntPtr sqlrcurref, String variable, UInt32 length)1052 private static extern void sqlrcur_defineOutputBindString(IntPtr sqlrcurref, String variable, UInt32 length); 1053 1054 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindInteger(IntPtr sqlrcurref, String variable)1055 private static extern void sqlrcur_defineOutputBindInteger(IntPtr sqlrcurref, String variable); 1056 1057 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindDouble(IntPtr sqlrcurref, String variable)1058 private static extern void sqlrcur_defineOutputBindDouble(IntPtr sqlrcurref, String variable); 1059 1060 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindDate(IntPtr sqlrcurref, String variable)1061 private static extern void sqlrcur_defineOutputBindDate(IntPtr sqlrcurref, String variable); 1062 1063 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindBlob(IntPtr sqlrcurref, String variable)1064 private static extern void sqlrcur_defineOutputBindBlob(IntPtr sqlrcurref, String variable); 1065 1066 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindClob(IntPtr sqlrcurref, String variable)1067 private static extern void sqlrcur_defineOutputBindClob(IntPtr sqlrcurref, String variable); 1068 1069 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_defineOutputBindCursor(IntPtr sqlrcurref, String variable)1070 private static extern void sqlrcur_defineOutputBindCursor(IntPtr sqlrcurref, String variable); 1071 1072 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_clearBinds(IntPtr sqlrcurref)1073 private static extern void sqlrcur_clearBinds(IntPtr sqlrcurref); 1074 1075 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_countBindVariables(IntPtr sqlrcurref)1076 private static extern UInt16 sqlrcur_countBindVariables(IntPtr sqlrcurref); 1077 1078 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_validateBinds(IntPtr sqlrcurref)1079 private static extern void sqlrcur_validateBinds(IntPtr sqlrcurref); 1080 1081 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_validBind(IntPtr sqlrcurref, String variable)1082 private static extern Int32 sqlrcur_validBind(IntPtr sqlrcurref, String variable); 1083 1084 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_executeQuery(IntPtr sqlrcurref)1085 private static extern Int32 sqlrcur_executeQuery(IntPtr sqlrcurref); 1086 1087 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_fetchFromBindCursor(IntPtr sqlrcurref)1088 private static extern Int32 sqlrcur_fetchFromBindCursor(IntPtr sqlrcurref); 1089 1090 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindString(IntPtr sqlrcurref, String variable)1091 private static extern IntPtr sqlrcur_getOutputBindString(IntPtr sqlrcurref, String variable); 1092 1093 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindInteger(IntPtr sqlrcurref, String variable)1094 private static extern Int64 sqlrcur_getOutputBindInteger(IntPtr sqlrcurref, String variable); 1095 1096 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindDouble(IntPtr sqlrcurref, String variable)1097 private static extern Double sqlrcur_getOutputBindDouble(IntPtr sqlrcurref, String variable); 1098 1099 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindDate(IntPtr sqlrcurref, String variable, ref Int16 year, ref Int16 month, ref Int16 day, ref Int16 hour, ref Int16 minute, ref Int16 second, ref Int32 microsecond, ref IntPtr tz, ref Int32 isnegative)1100 private static extern Int32 sqlrcur_getOutputBindDate(IntPtr sqlrcurref, String variable, ref Int16 year, ref Int16 month, ref Int16 day, ref Int16 hour, ref Int16 minute, ref Int16 second, ref Int32 microsecond, ref IntPtr tz, ref Int32 isnegative); 1101 1102 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindBlob(IntPtr sqlrcurref, String variable)1103 private static extern IntPtr sqlrcur_getOutputBindBlob(IntPtr sqlrcurref, String variable); 1104 1105 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindClob(IntPtr sqlrcurref, String variable)1106 private static extern IntPtr sqlrcur_getOutputBindClob(IntPtr sqlrcurref, String variable); 1107 1108 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindLength(IntPtr sqlrcurref, String variable)1109 private static extern UInt32 sqlrcur_getOutputBindLength(IntPtr sqlrcurref, String variable); 1110 1111 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getOutputBindCursor_copyrefs(IntPtr sqlrcurref, String variable, Int32 copyrefs)1112 private static extern IntPtr sqlrcur_getOutputBindCursor_copyrefs(IntPtr sqlrcurref, String variable, Int32 copyrefs); 1113 1114 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_openCachedResultSet(IntPtr sqlrcurref, String filename)1115 private static extern Int32 sqlrcur_openCachedResultSet(IntPtr sqlrcurref, String filename); 1116 1117 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_colCount(IntPtr sqlrcurref)1118 private static extern UInt32 sqlrcur_colCount(IntPtr sqlrcurref); 1119 1120 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_rowCount(IntPtr sqlrcurref)1121 private static extern UInt64 sqlrcur_rowCount(IntPtr sqlrcurref); 1122 1123 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_totalRows(IntPtr sqlrcurref)1124 private static extern UInt64 sqlrcur_totalRows(IntPtr sqlrcurref); 1125 1126 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_affectedRows(IntPtr sqlrcurref)1127 private static extern UInt64 sqlrcur_affectedRows(IntPtr sqlrcurref); 1128 1129 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_firstRowIndex(IntPtr sqlrcurref)1130 private static extern UInt64 sqlrcur_firstRowIndex(IntPtr sqlrcurref); 1131 1132 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_endOfResultSet(IntPtr sqlrcurref)1133 private static extern Int32 sqlrcur_endOfResultSet(IntPtr sqlrcurref); 1134 1135 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_errorMessage(IntPtr sqlrcurref)1136 private static extern IntPtr sqlrcur_errorMessage(IntPtr sqlrcurref); 1137 1138 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_errorNumber(IntPtr sqlrcurref)1139 private static extern Int64 sqlrcur_errorNumber(IntPtr sqlrcurref); 1140 1141 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getNullsAsEmptyStrings(IntPtr sqlrcurref)1142 private static extern void sqlrcur_getNullsAsEmptyStrings(IntPtr sqlrcurref); 1143 1144 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getNullsAsNulls(IntPtr sqlrcurref)1145 private static extern void sqlrcur_getNullsAsNulls(IntPtr sqlrcurref); 1146 1147 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col)1148 private static extern IntPtr sqlrcur_getFieldByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col); 1149 1150 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldByName(IntPtr sqlrcurref, UInt64 row, String col)1151 private static extern IntPtr sqlrcur_getFieldByName(IntPtr sqlrcurref, UInt64 row, String col); 1152 1153 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldAsIntegerByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col)1154 private static extern Int64 sqlrcur_getFieldAsIntegerByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col); 1155 1156 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldAsIntegerByName(IntPtr sqlrcurref, UInt64 row, String col)1157 private static extern Int64 sqlrcur_getFieldAsIntegerByName(IntPtr sqlrcurref, UInt64 row, String col); 1158 1159 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldAsDoubleByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col)1160 private static extern Double sqlrcur_getFieldAsDoubleByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col); 1161 1162 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldAsDoubleByName(IntPtr sqlrcurref, UInt64 row, String col)1163 private static extern Double sqlrcur_getFieldAsDoubleByName(IntPtr sqlrcurref, UInt64 row, String col); 1164 1165 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldLengthByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col)1166 private static extern UInt32 sqlrcur_getFieldLengthByIndex(IntPtr sqlrcurref, UInt64 row, UInt32 col); 1167 1168 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getFieldLengthByName(IntPtr sqlrcurref, UInt64 row, String col)1169 private static extern UInt32 sqlrcur_getFieldLengthByName(IntPtr sqlrcurref, UInt64 row, String col); 1170 1171 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnName(IntPtr sqlrcurref, UInt32 col)1172 private static extern IntPtr sqlrcur_getColumnName(IntPtr sqlrcurref, UInt32 col); 1173 1174 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnTypeByIndex(IntPtr sqlrcurref, UInt32 col)1175 private static extern IntPtr sqlrcur_getColumnTypeByIndex(IntPtr sqlrcurref, UInt32 col); 1176 1177 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnTypeByName(IntPtr sqlrcurref, String col)1178 private static extern IntPtr sqlrcur_getColumnTypeByName(IntPtr sqlrcurref, String col); 1179 1180 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnLengthByIndex(IntPtr sqlrcurref, UInt32 col)1181 private static extern UInt32 sqlrcur_getColumnLengthByIndex(IntPtr sqlrcurref, UInt32 col); 1182 1183 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnLengthByName(IntPtr sqlrcurref, String col)1184 private static extern UInt32 sqlrcur_getColumnLengthByName(IntPtr sqlrcurref, String col); 1185 1186 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnPrecisionByIndex(IntPtr sqlrcurref, UInt32 col)1187 private static extern UInt32 sqlrcur_getColumnPrecisionByIndex(IntPtr sqlrcurref, UInt32 col); 1188 1189 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnPrecisionByName(IntPtr sqlrcurref, String col)1190 private static extern UInt32 sqlrcur_getColumnPrecisionByName(IntPtr sqlrcurref, String col); 1191 1192 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnScaleByIndex(IntPtr sqlrcurref, UInt32 col)1193 private static extern UInt32 sqlrcur_getColumnScaleByIndex(IntPtr sqlrcurref, UInt32 col); 1194 1195 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnScaleByName(IntPtr sqlrcurref, String col)1196 private static extern UInt32 sqlrcur_getColumnScaleByName(IntPtr sqlrcurref, String col); 1197 1198 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsNullableByIndex(IntPtr sqlrcurref, UInt32 col)1199 private static extern Int32 sqlrcur_getColumnIsNullableByIndex(IntPtr sqlrcurref, UInt32 col); 1200 1201 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsNullableByName(IntPtr sqlrcurref, String col)1202 private static extern Int32 sqlrcur_getColumnIsNullableByName(IntPtr sqlrcurref, String col); 1203 1204 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsPrimaryKeyByIndex(IntPtr sqlrcurref, UInt32 col)1205 private static extern Int32 sqlrcur_getColumnIsPrimaryKeyByIndex(IntPtr sqlrcurref, UInt32 col); 1206 1207 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsPrimaryKeyByName(IntPtr sqlrcurref, String col)1208 private static extern Int32 sqlrcur_getColumnIsPrimaryKeyByName(IntPtr sqlrcurref, String col); 1209 1210 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsUniqueByIndex(IntPtr sqlrcurref, UInt32 col)1211 private static extern Int32 sqlrcur_getColumnIsUniqueByIndex(IntPtr sqlrcurref, UInt32 col); 1212 1213 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsUniqueByName(IntPtr sqlrcurref, String col)1214 private static extern Int32 sqlrcur_getColumnIsUniqueByName(IntPtr sqlrcurref, String col); 1215 1216 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsPartOfKeyByIndex(IntPtr sqlrcurref, UInt32 col)1217 private static extern Int32 sqlrcur_getColumnIsPartOfKeyByIndex(IntPtr sqlrcurref, UInt32 col); 1218 1219 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsPartOfKeyByName(IntPtr sqlrcurref, String col)1220 private static extern Int32 sqlrcur_getColumnIsPartOfKeyByName(IntPtr sqlrcurref, String col); 1221 1222 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsUnsignedByIndex(IntPtr sqlrcurref, UInt32 col)1223 private static extern Int32 sqlrcur_getColumnIsUnsignedByIndex(IntPtr sqlrcurref, UInt32 col); 1224 1225 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsUnsignedByName(IntPtr sqlrcurref, String col)1226 private static extern Int32 sqlrcur_getColumnIsUnsignedByName(IntPtr sqlrcurref, String col); 1227 1228 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsZeroFilledByIndex(IntPtr sqlrcurref, UInt32 col)1229 private static extern Int32 sqlrcur_getColumnIsZeroFilledByIndex(IntPtr sqlrcurref, UInt32 col); 1230 1231 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsZeroFilledByName(IntPtr sqlrcurref, String col)1232 private static extern Int32 sqlrcur_getColumnIsZeroFilledByName(IntPtr sqlrcurref, String col); 1233 1234 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsBinaryByIndex(IntPtr sqlrcurref, UInt32 col)1235 private static extern Int32 sqlrcur_getColumnIsBinaryByIndex(IntPtr sqlrcurref, UInt32 col); 1236 1237 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsBinaryByName(IntPtr sqlrcurref, String col)1238 private static extern Int32 sqlrcur_getColumnIsBinaryByName(IntPtr sqlrcurref, String col); 1239 1240 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsAutoIncrementByIndex(IntPtr sqlrcurref, UInt32 col)1241 private static extern Int32 sqlrcur_getColumnIsAutoIncrementByIndex(IntPtr sqlrcurref, UInt32 col); 1242 1243 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getColumnIsAutoIncrementByName(IntPtr sqlrcurref, String col)1244 private static extern Int32 sqlrcur_getColumnIsAutoIncrementByName(IntPtr sqlrcurref, String col); 1245 1246 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getLongestByIndex(IntPtr sqlrcurref, UInt32 col)1247 private static extern UInt32 sqlrcur_getLongestByIndex(IntPtr sqlrcurref, UInt32 col); 1248 1249 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getLongestByName(IntPtr sqlrcurref, String col)1250 private static extern UInt32 sqlrcur_getLongestByName(IntPtr sqlrcurref, String col); 1251 1252 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_suspendResultSet(IntPtr sqlrcurref)1253 private static extern void sqlrcur_suspendResultSet(IntPtr sqlrcurref); 1254 1255 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_getResultSetId(IntPtr sqlrcurref)1256 private static extern UInt16 sqlrcur_getResultSetId(IntPtr sqlrcurref); 1257 1258 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_resumeResultSet(IntPtr sqlrcurref, UInt16 id)1259 private static extern Int32 sqlrcur_resumeResultSet(IntPtr sqlrcurref, UInt16 id); 1260 1261 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_resumeCachedResultSet(IntPtr sqlrcurref, UInt16 id, String filename)1262 private static extern Int32 sqlrcur_resumeCachedResultSet(IntPtr sqlrcurref, UInt16 id, String filename); 1263 1264 [DllImport("libsqlrclientwrapper.dll", CallingConvention = CallingConvention.Cdecl)] sqlrcur_closeResultSet(IntPtr sqlrcurref)1265 private static extern void sqlrcur_closeResultSet(IntPtr sqlrcurref); 1266 } 1267 1268 } 1269