zoukankan      html  css  js  c++  java
  • FDQuery sqlserver 临时表

    用FDQuery执行创建临时表,查不到临时表,用ADOQuery和BDEQuery均正常,比较发现用ADOQuery执行的时候只有SQL没有调用sql的系统存储过程sp_prepexec.

    是fdquery哪里设置的问题吗,用FDConnection->ExecSQL("sql");是可以查到临时表不调用系统存储过程sp_prepexec但是不能获得影响的行数,

    set @p1=NULL 改为NULL创建的临时表可以查到,但是如何才能设置到NULL。

    declare @p1 int
    set @p1=1
    exec sp_prepexec @p1 output,NULL,N'select top 50 *  into #ls from  myTable'
    select @p1
    go

    --------------------
    exec sp_unprepare 1 go exec [adb].[sys].sp_pkeys N'#ls',N'dbo',N'adb' go declare @p1 int set @p1=NULL exec sp_prepexec @p1 output,NULL,N'select top 50 * from #ls ' select @p1 go

    FDConnection.ResourceOptions.DirectExecute := True;

    或者

    dm->FDConnection1->ExecSQL(sql);

     这样就解决了!!

    qry->ResourceOptions->DirectExecute=true;

    http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic&frmfile=uADCompClient_TADRdbmsDataSet_ResourceOptions.html

    对sql server有啥执行效果的区别,没有说明

    Description

    Use DirectExecute property to specify should FireDAC prepare SQL statement before execution (False) or execute it directly (True). The default value is False. 

    This property was introduced at first for MS SQL Server support. Where prepared and direct execution may have different effects. Or even prepared execution may fail. If you will get "strange" errors, then try to set DirectExecute to True.

     

     

    还有一个办法,

    exec sp_executesql N'select * into #ls from mytable'

    select * from #ls

    这样是访问不到临时表的,可以在命令前先create talbe #ls(a int)...

    这个就是先创建临时表,得知道有哪些字段。

  • 相关阅读:
    android 本地通知
    android qq开合表
    android 获取经纬度
    android读取通讯录和使用系统通讯录
    android Dialog官方demo
    android Listview分页
    android 瀑布流
    2020-08-16:数据任务是怎么优化的?(数据倾斜,参数相关调节)
    2020-08-15:什么情况下数据任务需要优化?
    2020-08-14:数据任务的执行引擎用的哪些?
  • 原文地址:https://www.cnblogs.com/cb168/p/4361970.html
Copyright © 2011-2022 走看看