cursor

Error when trying to access Cursor data

孤街浪徒 提交于 2019-12-05 06:23:07
问题 I have a populated Database in my app but I'm having trouble to access data through a returned cursor from the query method. Cursor query = getContentResolver().query(MoviesContract.MoviesEntry.CONTENT_URI, null, null, null, null); query.moveToFirst(); while (query.isAfterLast() == false){ Log.d("Test", query.getString(0)); query.moveToNext(); } I'm doing tests on this block of code. When I execute the Log.d line, this error is raised: java.lang.IllegalStateException: Couldn't read row 0, col

Python 操作MySQL 数据库

旧城冷巷雨未停 提交于 2019-12-05 06:08:54
Python 操作 MySQL 数据库 Python 标准数据库接口为 Python DB-API,Python DB-API为开发人员提供了数据库应用编程接口。 Python 数据库接口支持非常多的数据库,你可以选择适合你项目的数据库: GadFly mSQL MySQL PostgreSQL Microsoft SQL Server 2000 Informix Interbase Oracle Sybase 你可以访问 Python数据库接口及API 查看详细的支持数据库列表。 不同的数据库你需要下载不同的DB API模块,例如你需要访问Oracle数据库和Mysql数据,你需要下载Oracle和MySQL数据库模块。 DB-API 是一个规范. 它定义了一系列必须的对象和数据库存取方式, 以便为各种各样的底层数据库系统和多种多样的数据库接口程序提供一致的访问接口 。 Python的DB-API,为大多数的数据库实现了接口,使用它连接各数据库后,就可以用相同的方式操作各数据库。 Python DB-API使用流程: 引入 API 模块。 获取与数据库的连接。 执行SQL语句和存储过程。 关闭数据库连接。 什么是MySQLdb? MySQLdb 是用于Python链接Mysql数据库的接口,它实现了 Python 数据库 API 规范 V2.0,基于 MySQL C API

Using a Cursor returned from a LoaderManager in an AsyncTask

删除回忆录丶 提交于 2019-12-05 06:01:51
I have a cursor returned on an onLoadFinished callback (from LoaderManager.LoaderCallbacks ), and I want to do some (possibly costly) post-processing on this cursor. So, I'm firing off an AsyncTask that uses this Cursor. However, I'm getting intermittent crashes with this exception: android.database.StaleDataException: Attempted to access a cursor after it has been closed. My suspicion is that this is happening because the cursor (being managed by the Loader in the UI Thread) is being closed before the background thread is finished with it, since this is a managed cursor. Here is some

Vim: do something in a function based on character under a cursor?

三世轮回 提交于 2019-12-05 05:58:31
I'm writing a function that edits a certain environment in LaTeX. The environment basically looks like this: \begin{quicktikz} ...some stuff... \end{quicktikz} or like this: \begin*{quicktikz} ...some stuff... \end{quicktikz} I want to write a function that toggles between the two, when called from within the environment. Since my Vim knowledge ain't all that, I'm coming up with a simple solution: Get cursor position with let save_cursor=getpos(".") Backward search for \begin{quicktikz} using: ?\\begin{quicktikz}\|\\begin\*{quicktikz} Search for the { and move left using: normal 0f{h Check if

How to loop through a table using a cursor in MySQL?

ε祈祈猫儿з 提交于 2019-12-05 05:42:00
问题 I have following table in my database and I wrote following stored procedure to loop through the table. When I call this stored procedure, I get only one record. What could be the error I have done, and how can this be fixed? +--------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+--------------+------+-----+---------+-------+ | date | date | NO | | NULL | | | inQty | decimal(5,2) | NO | | 0.00 | | | outQty | varchar(45) | YES | | 0.0

Why cursorLoader didn't notify changes in source data?

女生的网名这么多〃 提交于 2019-12-05 05:17:40
I have a simple contentProvider, a layout with a ListView and a button for adding Items in content Provider and a CursorLoader. The http://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html#onLoadFinished(android.content.Loader , D) reference states that The Loader will monitor for changes to the data, and report them to you through new calls here. You should not monitor the data yourself. For example, if the data is a Cursor and you place it in a CursorAdapter, use the CursorAdapter(android.content.Context, android.database.Cursor, int) constructor without passing

How to Access Cursor Columns Without FETCH .. INTO

笑着哭i 提交于 2019-12-05 04:13:35
I'm using SQL Server to build stored procedures, and I'm using cursors to loop through a select statement I'm defining the cursor as follow: DECLARE @c_col1 varchar(max); DECLARE @c_col2 varchar(max); DECLARE c as CURSOR FOR SELECT col1, col2 FROM table; OPEN c; FETCH NEXT FROM c INTO @c_col1, @c_col2; SELECT @c_col1, @c_col2; Is there a way to access the columns of the cursor without a need to declare variables for each column and to use INTO in FETCH clause? In other words, is it possible to use: DECLARE c as CURSOR FOR SELECT col1, col2 FROM table; OPEN c; FETCH NEXT FROM c; SELECT c.col1,

StaleDataException: Attempted to access a cursor after it has been closed

喜欢而已 提交于 2019-12-05 02:46:31
问题 FATAL EXCEPTION: main Process: com.example.lenovo.phone, PID: 4885 android.database.StaleDataException: Attempted to access a cursor after it has been closed. at android.database.BulkCursorToCursorAdaptor.throwIfCursorIsClosed(BulkCursorToCursorAdaptor.java:64) at android.database.BulkCursorToCursorAdaptor.requery(BulkCursorToCursorAdaptor.java:133) at android.database.CursorWrapper.requery(CursorWrapper.java:186) at android.app.Activity.performRestart(Activity.java:5309) at android.app

Nested Cursors in PL/SQL

情到浓时终转凉″ 提交于 2019-12-05 02:26:06
问题 I am working with Oracle PL/SQL. I´m trying to define Nested Cursors, which means that the output from the first Cursor should be the input for the second. To be more specific: the first one should store tables with a specific prefix in it. The second one should store all values from an attribute from all the tables which are in the first one. Here is my code snippet. I hope it makes my problem a little more clear: DECLARE var_table_name VARCHAR2(30); var_dimension_key VARCHAR2(30); CURSOR

Hiding the mouse cursor when idle using JavaScript

倖福魔咒の 提交于 2019-12-05 02:13:19
Is it possible to use JavaScript to set the cursor attribute to the property none if the mouse is inactive for a certain amount of time (say, five seconds) and set it back to auto when it becomes active again? EDIT: I realize that none is not a valid value for the cursor property. Nonetheless, many web-browsers seem to support it. Furthermore, the primary user for this is myself, so there is little chance of confusion arising as a result. I've got two scripts that can do something similar: window.addEventListener("mousemove", function(){ document.querySelector("#editor").style.background = "