日期:2014-05-16  浏览次数:20918 次

请问SQL如何转成Oracle的语法
请问一下...以下的SQL语法可以转成Oracle吗??
我要怎么写?
且要输出时要是表格的唷!!

declare @a varchar(8)
declare @b varchar(8)

select @a = instance_id from dsh_ora
select @b = server_id from dsh_ora

select @a,@b

------最佳解决方案--------------------

select instance_id,server_id  from dsh_ora;

------其他解决方案--------------------
declare @a varchar(8) declare @b varchar(8)   
select instance_id into @a   from dsh_ora ;
select server_id into @b  from dsh_ora   ;
select @a,@b from dual;

------其他解决方案--------------------
BenChiM888 大大:
Sorry!!我那是要從不同的資料表查出來的...
所以不能這樣用...且我需要大概十幾個以上的table串出我要的表...
所以也不能一直用join的下去...

taiguang 大大:
Oracle不能用"@"吧!!
我打了你的語法出現以下錯誤!!
PLS-00103: Encountered the symbol "@" when expecting one of the following:

請各位大大再幫幫忙吧!!
------其他解决方案--------------------
不好意思...忘了改字型!!
BenChiM888 大大:
Sorry!!我那是要从不同的资料表查出来的...
所以不能这样用...且我需要大概十几个以上的table串出我要的表...
所以也不能一直用join的下去...

taiguang 大大:
Oracle不能用"@"吧!!
我打了你的语法出现以下错误!!
PLS-00103: Encountered the symbol "@" when expecting one of the following:

请各位大大再帮帮忙吧!!
------其他解决方案--------------------
我做到我想到的了...做法来自于下面的网页...感谢各位大大...
http://msdn.microsoft.com/zh-tw/library/cydxhzhz(v=vs.80).aspx

// CreateTempLob
   public static OracleLob CreateTempLob(
     OracleCommand cmd, OracleType lobtype)
   {
      //Oracle server syntax to obtain a temporary LOB.
      cmd.CommandText = "DECLARE A " + lobtype + "; "+
                     "BEGIN "+
                        "DBMS_LOB.CREATETEMPORARY(A, FALSE); "+
                        ":LOC := A; "+
                     "END;";
      
      //Bind the LOB as an output parameter.
      OracleParameter p = cmd.Parameters.Add("LOC", lobtype);
      p.Direction = ParameterDirection.Output;

      //Execute (to receive the output temporary LOB).
      cmd.ExecuteNonQuery();

      //Return the temporary LOB.
      return (OracleLob)p.Value;
   }