多个oracle查询问题 [英] Multiple oracle queries problem

查看:115
本文介绍了多个oracle查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从.NET页面运行查询,但是在进行多个查询时似乎遇到了一些问题.

I'm trying to run a query from a .NET page but I seem to having some problems with having multiple queries.

我的查询与此类似

SELECT * FROM table1; SELECT * from table2

但是,当我从.Net页面执行此操作时,似乎收到了无效的字符错误.它在SQL开发人员中运行良好,但只有在将其放在.NET页中时才会失败.

But i seem to get an invalid character error when executing this from a .Net page. It runs fine in SQL developer but only fails when i put it in my .NET page.

我已经在查询中添加了BEGINEND,因为某些网站建议您使用它来运行多个查询,但是随后出现以下错误

I've added the BEGIN and END to the query as some websites suggest you need this to run multiple queries but then I get the following error

ORA-06550:第1行,第7列: PLS-00428:此SELECT语句中应有一个INTO子句

ORA-06550: line 1, column 7: PLS-00428: an INTO clause is expected in this SELECT statement

任何人都可以阐明这一点吗?

Can anyone shed any light on this one?

提前谢谢!

编辑

这是一些代码

        query = conn.CreateCommand()

        query.CommandText = "SELECT * from table1; SELECT * FROM table2;"

        DataSet = New DataSet()
        DataAdapter = New DataAdapter(query)
        DataAdapter.Fill(DataSet)

        datagrid1.DataSource = DataSet.Tables(0)
        datagrid1.DataBind()

        lbl1.Text = DataSet.Tables(1).Rows(0).Item("column1").ToString()

推荐答案

如果要从2个表中提取数据并获取可以填充到DataAdapter中的数据集,则需要使用以下方法之一:

If you want to pull from 2 tables and get a DataSet that you can fill into a DataAdapter, then you need to use one of the following approaches:

  1. 将2个表连接在一起(根据您的表可能会或可能不会)
  2. 合并这两个表(这可能适用于您的方案,也可能不适用)
  3. 编写一个存储过程,该过程将创建所需的任何结果,并将其返回给ref游标.您可以在此处阅读有关该操作方法的信息.
  1. join the 2 tables together (may or may not be possible depending on your tables)
  2. union the 2 tables (this may or may not be applicable to your scenario)
  3. write a stored procedure which creates whatever result you need and returns it in a ref cursor. You can read about how to do that here.

您将无法仅运行2条这样的SQL语句并将任何有意义的结果输入到DataSet中.

You're not going to be able to just run 2 SQL statements like that and get any meaningful result into a DataSet.

这篇关于多个oracle查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆