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

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

  • 相关阅读:
    DEDECMS之五 单页
    DEDECMS之六 网站地图、RSS地图
    DEDECMS之四 栏目调用
    DEDECMS之三 首页、列表页怎么调用文章内容
    DEDECMS之七 如何实现文章推荐排行榜
    centos6下安装dedecms
    C# 自动部署之附加数据库
    产品经理技能之BRD的笔记之菜鸟入门
    产品经理技能之MRD的笔记之一
    产品需求文档(PRD)的写作方法之笔记一
  • 原文地址:https://www.cnblogs.com/cb168/p/4361970.html
Copyright © 2011-2022 走看看