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)...

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

  • 相关阅读:
    树形目录生成器.bat
    Google 搜索截图
    Expo 2010 Japan Pavilion
    WinCE应用程序开发创建文件或文件夹
    Oracle 获取每月最后一天的函数
    Oracle的外连接符号(+)
    关于项目中找不到某个配置xml文件的问题
    通過反編譯跟蹤JSP頁面
    JSP 一些基本语法
    page request session application 范围
  • 原文地址:https://www.cnblogs.com/cb168/p/4361970.html
Copyright © 2011-2022 走看看