用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隐藏过滤条件
flash.data 

SQLStatement  - AS3

x

顶级
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

语言元素

全局常量
全局函数
运算符
语句、关键字和指令
特殊类型

附录

新增内容
编译器错误
编译器警告
运行时错误
迁移到 ActionScript 3
支持的字符集
仅适用于 MXML 的标签
Motion XML 元素
Timed Text 标记
不推荐使用的元素的列表
AccessibilityImplementation 常量
如何使用 ActionScript 示例
法律声明
flash.data
public class SQLStatement
继承SQLStatement Inheritance EventDispatcher Inheritance Object

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

SQLStatement 实例用于针对通过 SQLConnection 实例打开的本地 SQL 数据库执行 SQL 语句。

SQLStatement 实例通过将 SQLConnection 实例设置为 SQLStatement 实例的 sqlConnection 属性的值来链接到 SQLConnection 实例。text 属性用要执行的 SQL 语句的实际文本进行填充。如有必要,可以使用 parameters 属性指定 SQL 语句参数的值,并通过调用 execute() 方法执行该语句。

有关本地 SQL 数据库中支持的 SQL 术语的完整说明,请参阅附录本地数据库中的 SQL 支持

在异步执行模式中,execute()next() 方法在后台执行,并且当操作完成或失败时,运行时会对注册的事件侦听器或指定的 Responder 实例调度事件。在同步模式中,这些方法在主应用程序线程上执行,这意味着数据库操作完成之前不执行其他代码。另外,在同步模式中,如果方法失败,运行时将引发异常而不调度错误事件。

相关 API 元素



公共属性
 属性由以下参数定义
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
      executing : Boolean
[只读] 表示当前是否正在执行语句。
SQLStatement
      itemClass : Class
表示一个类(数据类型),用于由于执行语句而返回的每个行。
SQLStatement
      parameters : Object
[只读] 用作一个关联数组,将在其中添加 SQL 语句的 text 属性中指定的参数的值。
SQLStatement
      sqlConnection : SQLConnection
管理到执行语句的数据库的连接的 SQLConnection 对象。
SQLStatement
      text : String
语句的实际 SQL 文本。
SQLStatement
公共方法
 方法由以下参数定义
  
    SQLStatement()
创建 SQLStatement 实例。
SQLStatement
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
  
    cancel():void
取消执行此语句。
SQLStatement
  
清除所有当前参数设置。
SQLStatement
 Inherited
将事件调度到事件流中。
EventDispatcher
  
    execute(prefetch:int = -1, responder:Responder = null):void
针对连接到 sqlConnection 属性中的 SQLConnection 对象的数据库执行 text 属性中的 SQL。
SQLStatement
  
提供对包含语句执行结果的 SQLResult 对象的访问,其中包括 SELECT 语句的任何结果行以及有关执行的所有语句的语句执行情况的其他信息。
SQLStatement
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
  
    next(prefetch:int = -1, responder:Responder = null):void
检索 SELECT 语句的结果集的下一部分。
SQLStatement
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。
EventDispatcher
事件
 事件 摘要 由以下参数定义
 Inherited[广播事件] Flash Player 或 AIR 应用程序获得操作系统焦点并变为活动状态时将调度此事件。EventDispatcher
 Inherited[广播事件] Flash Player 或 AIR 应用程序失去操作系统焦点并变为非活动状态时将调度此事件。EventDispatcher
  
    error
在执行操作期间发生错误时调度。SQLStatement
  
    result
execute() 或 next() 方法调用操作成功完成时调度。SQLStatement
属性详细信息
    

executing

属性
executing:Boolean  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

表示当前是否正在执行语句。

如果已调用 execute() 且尚未返回数据库中的所有结果,则此属性为 true。



实现
    public function get executing():Boolean

相关 API 元素

    

itemClass

属性 
itemClass:Class

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

表示一个类(数据类型),用于由于执行语句而返回的每个行。

默认情况下,由 SELECT 语句返回的每个行都创建为 Object 实例,以结果集的列名作为该对象的属性名,每列的值作为其相关属性的值。

通过指定 itemClass 属性的类,由此 SQLStatement 实例执行的 SELECT 语句返回的每个行都创建为指定的类的实例。itemClass 实例的每个属性均赋予与该属性同名的列中的值。

分配给此属性的任何类必须具有不需要任何参数的构造函数。另外,对于由 SELECT 语句返回的每个列,该类必须具有一个单一的属性。如果 SELECT 列表中的列在 itemClass 类中没有相匹配的属性名称,系统会将其视为错误。



实现
    public function get itemClass():Class
    public function set itemClass(value:Class):void

相关 API 元素


示例  ( 如何使用本示例 )
下面的代码演示如何使用 itemClass 属性让运行时从 SQL SELECT 语句结果创建自定义类的实例。
// Employee class definition
package
{
    public class Employee
    {
        public var name:String;
        public var ssn:String;
        public var id:uint;
        public override function toString():String
        {
            return "id: "+ id.toString() + " name: " + name + " ssn: " + ssn;
        }
    }
}


// using the Employee class as SQLStatement.itemClass
var conn:SQLConnection;
var dbStatement:SQLStatement;

function init():void
{
    conn = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, connOpenHandler);
    
    dbStatement = new SQLStatement();
    dbStatement.sqlConnection = conn;
    dbStatement.text = "SELECT id, name, ssn FROM employees";
    dbStatement.itemClass = Employee;
    
    var dbFile:File = new File(File.separator + "employee.db");
    conn.open(dbFile);
}

function connOpenHandler(event:SQLEvent):void
{
    dbStatement.addEventListener(SQLEvent.RESULT, resultHandler);
    dbStatement.execute();
}

function resultHandler(event:SQLEvent):void
{
    var result:SQLResult = dbStatement.getResult();
    if (result != null)
    {
        var emp:Employee;
        var numRows:int = result.data.length;
        for (var i:int = 0; i < numRows; i++)
        {
            emp = result.data[i];
            trace(emp.toString());
        }
    }
}
    

parameters

属性 
parameters:Object  [只读]

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

用作一个关联数组,将在其中添加 SQL 语句的 text 属性中指定的参数的值。数组键是参数的名称。如果在语句文本中指定了未命名的参数,则其键是该参数的索引。

在 SQL 语句的文本内,参数由以下字符之一表示:“?”、“:”或“@”。

“:”和“@”标记表示命名的参数;标记后面的字符指定参数的名称。

例如,在下面的 SQL 语句中,使用“:”字符指定了一个名为 firstName 的参数:

SELECT FROM employees WHERE firstName = :firstName

“?”标记表示索引(编号)参数;系统根据参数在语句文本中的顺序自动为每个参数赋予一个索引。参数的索引值从零开始。也就是说,第一个参数的索引为 0。

参数用于允许对构造 SQL 语句时未知的值进行类型替代。使用参数是保证将值的存储类传递到数据库的唯一方式。不使用参数时,所有值都将根据相关联列的类型关系从其文本表示形式转换为存储类。有关存储类和列关系的详细信息,请参阅附录“本地数据库中的 SQL 支持”中的“数据类型支持”部分。

参数也可用作一种安全措施,防止恶意技术攻击(称为 SQL 注入攻击)。在 SQL 注入攻击中,用户在用户可访问的位置(例如数据输入字段)输入 SQL 代码。如果应用程序代码通过将用户输入直接连接到 SQL 文本来构造 SQL 语句,则将对数据库执行用户输入的 SQL 代码。下面的列表显示将用户输入连接到 SQL 文本的示例。不要使用此技术

     // assume the variables "username" and "password"
     // contain user-entered data
     var sql:String =
         "SELECT userId " +
         "FROM users " +
         "WHERE username = '" + username + "' " +
         "    AND password = '" + password + "'";
     var statement:SQLStatement = new SQLStatement();
     statement.text = sql;
     

使用语句参数而不将用户输入的值连接到语句的文本可防止 SQL 注入攻击,因为系统将参数值明确视为替代值,而不是作为字面语句文本的一部分。下面是对前面列表的建议替代方法:

     // assume the variables "username" and "password"
     // contain user-entered data
     var sql:String =
         "SELECT userId " +
         "FROM users " +
         "WHERE username = :username " +
         "    AND password = :password";
     var statement:SQLStatement = new SQLStatement();
     statement.text = sql;
     // set parameter values
     statement.parameters[":username"] = username;
     statement.parameters[":password"] = password;
     

执行语句之前必须设置所有参数值。在调用 execute() 方法时,将会绑定 parameters 数组中指定的参数值(即与语句文本合并)。一旦调用 execute() 后,对值进行的任何后续更改都不会应用于正在执行的语句。不过,后续的 execute() 调用将使用更改的值。如果语句文本包括的参数没有在 parameters 属性中指定的值,则会发生错误。

要清除 parameters 属性中的所有参数值,请使用 clearParameters() 方法。



实现
    public function get parameters():Object

相关 API 元素


示例  ( 如何使用本示例 )
下面的示例显示命名参数 :firstName 在 SQL 语句中的用法。
// employees is a SQLStatement instance
employees.text = "SELECT FROM employees WHERE first = :firstName";
employees.parameters[":firstName"] = "Sam";
employees.execute();
下面的示例显示未命名参数在 SQL 语句中的用法。
// employees is a SQLStatement instance
employees.text = "SELECT FROM employees WHERE first = ?";
employees.parameters[0] = "Sam";
employees.execute();
    

sqlConnection

属性 
sqlConnection:SQLConnection

运行时版本: AIR 1.0

管理到执行语句的数据库的连接的 SQLConnection 对象。



实现
    public function get sqlConnection():SQLConnection
    public function set sqlConnection(value:SQLConnection):void

引发
IllegalOperationError — 当该语句正在执行的同时尝试更改此属性的值时。
    

text

属性 
text:String

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

语句的实际 SQL 文本。

该文本可以是任何受支持的 SQL。有关本地 SQL 数据库中支持的 SQL 术语的完整说明,请参阅附录“本地数据库中的 SQL 支持”。



实现
    public function get text():String
    public function set text(value:String):void

引发
IllegalOperationError — 当该语句正在执行的同时尝试更改 text 属性时。
构造函数详细信息
    

SQLStatement

()构造函数
public function SQLStatement()

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

创建 SQLStatement 实例。


引发
SecurityError — 如果从主应用程序沙箱外的任意沙箱中调用构造函数。
方法详细信息

    cancel

()方法
public function cancel():void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

取消执行此语句。与 SQLConnection.cancel() 一样,此方法用于停止长时间运行的查询或取消尚未完成的查询。但是,与 SQLConnection.cancel() 不同,此方法只取消单个语句。如果当前未执行该语句,则调用此方法不起作用。

不会调度事件以直接响应 cancel() 操作的完成。但是,一旦 cancel() 操作完成并且取消语句执行后,SQLStatement 实例即会调度 error 事件,表示语句执行(execute()next() 调用)没有完成。或者,如果为 execute()next() 调用的 responder 参数指定了值,则会调用指定的错误处理函数方法。不管是哪种情况,传递给侦听器的 SQLError 实例将具有值为 3118(操作已终止)的 errorID 属性。

    clearParameters

()方法 
public function clearParameters():void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

清除所有当前参数设置。

相关 API 元素

    execute

()方法 
public function execute(prefetch:int = -1, responder:Responder = null):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

针对连接到 sqlConnection 属性中的 SQLConnection 对象的数据库执行 text 属性中的 SQL。

如果 responder 参数不为 null,则指定的 Responder 对象将指定用于处理操作结果而调用的方法。当 responder 参数为 null 时,如果操作成功,则在异步执行模式中调度 result 事件;如果操作失败,则调度 error 事件。

若要访问执行语句的结果,例如 SELECT 语句的结果行或 INSERT 语句的数据库生成的主键,则调用 getResult() 方法。在同步模式中执行此语句后,以及在异步模式中调度 result 事件后,会立即显示结果。

每个语句必须在准备好(编译)后才能执行。首次调用 SQLStatement 实例的 execute() 方法时,运行时将准备好该语句。语句准备好后,除非 text 属性发生更改,否则不需要重新准备该语句。设置一个或多个参数值不需要重新准备该语句。

参数

prefetch:int (default = -1) — 当该语句的 text 属性为 SELECT 语句时,此值表示该语句一次返回的行数。默认值为 -1,表示一次返回所有结果行。此参数与 next() 方法结合使用,可将大结果集拆分为较小的数据集。这样,通过更快地返回初始结果和划分结果处理操作,可以改善用户对应用程序性能的体验。

当 SQL 语句为 SELECT 查询并指定了大于零的 prefetch 参数时,该语句将被视为正在执行,直到返回整个结果集或者调用了 SQLStatement.cancel()SQLConnection.cancel() 方法。请注意,由于在执行时结果集中的行数是未知的,因此,数据库光标必须移动到结果集的最后一行以后,才会认为该语句完成。如果在 execute() 调用中指定了 prefetch 参数,则只有当所请求的行数至少比结果集中的总行数多一行(通过大于结果集中行数的 prefetch 值或通过对 next() 方法的后续调用)后,生成的 SQLResult 实例的 complete 属性才会为 true

 
responder:Responder (default = null) — 一个对象,指定操作成功或失败时要调用的方法。在异步执行模式中,如果 responder 参数为 null,则执行完成时将调度 resulterror 事件。


事件
result:SQLEvent — 语句成功执行时或指定了 prefetch 参数值且 SELECT 语句返回一行或多行数据时调度。
 
error:SQLErrorEvent — 在异步执行模式中操作失败时调度。

引发
IllegalOperationError — 如果 text 属性为 null 或包含空字符串("");如果未设置 sqlConnection 属性;如果未连接分配给 sqlConnection 属性的 SQLConnection 实例;或者该语句当前正在执行。
 
SQLError — 如果该操作在同步执行模式中失败。

相关 API 元素


示例  ( 如何使用本示例 )

下面的示例演示如何使用事件侦听器执行 SQLStatement,以确定语句的执行何时完成或失败。
var conn:SQLConnection;
var dbStatement:SQLStatement;

function init():void
{
    conn = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, connOpenHandler);
    
    dbStatement = new SQLStatement();
    dbStatement.sqlConnection = conn;
    dbStatement.text = "SELECT id, name, ssn FROM employees";
    
    var dbFile:File = new File(File.separator + "employee.db");
    conn.open(dbFile);
}

function connOpenHandler(event:SQLEvent):void
{
    dbStatement.addEventListener(SQLEvent.RESULT, resultHandler);
    dbStatement.addEventListener(SQLErrorEvent.ERROR, errorHandler);
    dbStatement.execute();
}

function resultHandler(event:SQLEvent):void
{
    var result:SQLResult = dbStatement.getResult();
    if (result != null)
    {
        var numRows:int = result.data.length;
        for (var i:int = 0; i < numRows; i++)
        {
            var row:Object = result.data[i];
            trace("id:", row.id, ", name:", row.name, ", ssn:", row.ssn);
        }
    }
}

function errorHandler(event:SQLErrorEvent):void
{
    trace("An error occured while executing the statement.");
}

下面的示例演示如何执行 SQLStatement,该示例使用 Responder 对象来表示语句执行完成或失败时所调用的函数。
var conn:SQLConnection;
var dbStatement:SQLStatement;
var employeeResponder:Responder;

function init():void
{
    conn = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, connOpenHandler);
    
    dbStatement = new SQLStatement();
    dbStatement.sqlConnection = conn;
    dbStatement.text = "SELECT id, name, ssn FROM employees";
    
    var dbFile:File = new File(File.separator + "employee.db");
    conn.open(dbFile);
}

function connOpenHandler(event:SQLEvent):void
{
    employeeResponder = new Responder(resultHandler, errorHandler);
    dbStatement.execute(-1, employeeResponder);
}

function resultHandler(result:SQLResult):void
{
    if (result != null)
    {
        var numRows:int = result.data.length;
        for (var i:int = 0; i < numRows; i++)
        {
            var row:Object = result.data[i];
            trace("id:", row.id, ", name:", row.name, ", ssn:", row.ssn);
        }
    }
}

function errorHandler(error:SQLError):void
{
    trace("An error occured while executing the statement.");
}

    getResult

()方法 
public function getResult():SQLResult

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

提供对包含语句执行结果的 SQLResult 对象的访问,其中包括 SELECT 语句的任何结果行以及有关执行的所有语句的语句执行情况的其他信息。在异步执行模式中,在调度 result 事件之前结果信息不可用。

执行 SELECT 语句时,如果所调用的 execute() 方法的默认 prefetch 参数为 -1,则返回的 SQLResult 对象包含整个查询结果集。

如果为 execute()next() 方法调用指定了 prefetch 参数,则 getResult() 方法的行为与先进先出结果队列相同。每次调度 result 事件时,即会向队列中添加一个新的 SQLResult 对象。每次调用 getResult() 方法时,即会返回最早的 SQLResult 对象(最先添加到队列中的对象)并从队列中删除该对象。当队列中不再有 SQLResult 对象时,getResult() 将返回 null

请注意,除非通过调用 getResult() 来删除 SQLResult 对象,否则这些对象会保留在队列中。例如,如果调用多次 execute() 方法而没有调用 getResult(),则与每个 execute() 调用相关联的 SQLResult 对象将保留在队列中。

返回
SQLResult — 一个 SQLResult 对象,其中包含对 execute()next() 方法调用的结果。

相关 API 元素

    next

()方法 
public function next(prefetch:int = -1, responder:Responder = null):void

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

检索 SELECT 语句的结果集的下一部分。如果结果集中不再有行,则调度 result 事件,但不再向 getResult() 队列中添加 SQLResult 对象。

在异步执行模式中,如果 responder 参数不为 null,则指定的 Responder 对象表示为处理操作结果而调用的方法。当 responder 参数为 null 时,如果操作成功,则调度 result 事件;如果操作失败,则调度 error 事件。

只能在该语句仍在执行时才能调用此方法。当语句为 SELECT 查询并指定了大于零的 prefetch 参数时,该语句将被视为正在执行,直到返回整个结果集或者调用了 SQLStatement.cancel()SQLConnection.cancel() 方法。

参数

prefetch:int (default = -1) — 当该语句的 text 属性为 SELECT 语句时,此值表示该语句一次返回的行数。默认值为 -1,表示一次返回所有结果行。这样,通过更快地返回初始结果和划分结果处理操作,可以改善用户对应用程序性能的体验。
 
responder:Responder (default = null) — 一个对象,指定操作成功或失败时要调用的方法。如果 responder 参数为 null,则执行完成时将调度 resulterror 事件。


事件
result:SQLEvent — 语句成功执行时或指定了 prefetch 参数值且 next() 调用返回一行或多行数据时调度。
 
error:SQLErrorEvent — 在异步执行模式中操作失败时调度。

引发
IllegalOperationError — 在该语句不是当前正在执行的语句时调用该方法的情况下(executing 属性为 false)。
 
SQLError — 如果该操作在同步执行模式中失败。

相关 API 元素


示例  ( 如何使用本示例 )

下面的示例演示如何执行 SQLStatement,明确表示第一次返回结果时仅返回结果集的前 10 行。代码检查 SQLResult 的 complete 属性,如果尚未检索所有行,则调用 next() 方法。
var conn:SQLConnection;
var dbStatement:SQLStatement;

function init():void
{
    conn = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, connOpenHandler);
    
    dbStatement = new SQLStatement();
    dbStatement.sqlConnection = conn;
    dbStatement.text = "SELECT id, name, ssn FROM employees";
    
    var dbFile:File = new File(File.separator + "employee.db");
    conn.open(dbFile);
}

function connOpenHandler(event:SQLEvent):void
{
    dbStatement.addEventListener(SQLEvent.RESULT, resultHandler);
    dbStatement.addEventListener(SQLErrorEvent.ERROR, errorHandler);
    dbStatement.execute(10);
}

function resultHandler(event:SQLEvent):void
{
    var result:SQLResult = dbStatement.getResult();
    if (result != null)
    {
        var numRows:int = result.data.length;
        for (var i:int = 0; i < numRows; i++)
        {
            var row:Object = result.data[i];
            trace("id:", row.id, ", name:", row.name, ", ssn:", row.ssn);
        }
        if (!result.complete)
        {
            dbStatement.next(10);
        }
    }
}

function errorHandler(event:SQLErrorEvent):void
{
    trace("An error occured while executing the statement.");
}
事件详细信息
    

error

事件
事件对象类型: flash.events.SQLErrorEvent
属性 SQLErrorEvent.type = flash.events.SQLErrorEvent.ERROR

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

在执行操作期间发生错误时调度。

SQLErrorEvent.ERROR 常量定义在 SQLConnection 方法调用或 SQLStatement 实例出错完成时调度的 error 事件的 type 属性值。error 事件具有以下属性:
属性
bubblesfalse
cancelablefalse;没有要取消的默认行为。
error一个 SQLError 对象,其中包含有关出现的错误的类型和导致该错误的操作的信息。
currentTarget当前正在使用某个事件侦听器处理 Event 对象的对象。
target报告错误的 SQLConnection 或 SQLStatement 对象。

相关 API 元素

    

result

事件  
事件对象类型: flash.events.SQLEvent
属性 SQLEvent.type = flash.events.SQLEvent.RESULT

语言版本: ActionScript 3.0
运行时版本: AIR 1.0

execute()next() 方法调用操作成功完成时调度。一旦调度 result 事件后,即可以调用 getResult() 方法以检索语句结果。

SQLEvent.RESULT 常量定义 result 事件对象的 type 属性值。在 SQLStatement.execute() 方法或 SQLStatement.next() 方法成功完成时调度。调度 SQLEvent.RESULT 事件之后,即可调用 SQLStatement.getResult() 方法来访问结果数据。result 事件具有以下属性:
属性
bubblesfalse
cancelablefalse;没有要取消的默认行为。
currentTarget当前正在使用某个事件侦听器处理 Event 对象的对象。
target执行操作的 SQLStatement 对象。

相关 API 元素





[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。