首页 \ 问答 \ 带有字段名称的Oracle存储过程返回记录集(Oracle Stored Procedure Return Recordset with Field Names)

带有字段名称的Oracle存储过程返回记录集(Oracle Stored Procedure Return Recordset with Field Names)

我是Oracle和存储过程的新手。 我只想知道它是否可能(如在SQL Server中)将具有字段名称的记录集返回给外部程序。 我读了一些文件,但我不确定我是否走在正确的轨道上。 当我使用Sys_Refcursor时,我只能返回一个Field而不是我想要的那个。

我需要返回多个字段名称,我有一个输入参数。

在该程序的文档中,我有一个SQL Server的示例,我希望我的Oracle存储过程具有相同的:

Use
Go
Set Ansi_Nulls ON
Go
Alter Procedure
   @InputLocation Varchar(255)
As
Begin
   Set Nocount On;
   select FirstName as '@FirstName', Company as '@Company' from dbo.company where Location = @InputLocation
End

有什么建议我怎么做? 如果您需要一些额外的信息,请告诉我。 谢谢。

/编辑:

我的示例代码(在第一步中不使用输入参数,仅用于生成输出以查看它是否有效):

create or replace 
PROCEDURE TEST_PROZEDUR1 (
  Input_Location IN Varchar2, 
  First_Name OUT SYS_Refcursor, 
  Company OUT Sys_Refcursor) IS 
BEGIN
  open First_Name For Select FirstName from dbo.company;
  open Company For Select Company from dbo.company;
END TEST_PROZEDUR1;

I am new to Oracle and Stored Procedures. I just would like to know if its possible, like in SQL Server, to return a recordset with Field Names to an extern program. I read some documentations but I'm not sure if I'm on the right track. When I use Sys_Refcursor I can only return one Field and not as many as I would like to.

I need to return multiple Field Names and I have one input parameter.

In the documentation of the program, i have an example for SQL Server and I would like to have the same for my Oracle Stored Procedure:

Use
Go
Set Ansi_Nulls ON
Go
Alter Procedure
   @InputLocation Varchar(255)
As
Begin
   Set Nocount On;
   select FirstName as '@FirstName', Company as '@Company' from dbo.company where Location = @InputLocation
End

Are there any suggestions how I can do that? If you need some additional informations just let me know. Thanks.

/edit:

My sample Code (without using the Input Parameter in the first step, just for generating Output to see if it works):

create or replace 
PROCEDURE TEST_PROZEDUR1 (
  Input_Location IN Varchar2, 
  First_Name OUT SYS_Refcursor, 
  Company OUT Sys_Refcursor) IS 
BEGIN
  open First_Name For Select FirstName from dbo.company;
  open Company For Select Company from dbo.company;
END TEST_PROZEDUR1;

原文:https://stackoverflow.com/questions/27704675
更新时间:2024-04-17 16:04

最满意答案

  1. 我会使用VBA是的,但那就是我的工作
  2. 您正在寻找的房产是

ActiveSheet.Charts("Chart 1").Axes(xlCategory).AxisTitle.Text

  1. 要确保宏在所有工作表中都可用,请创建一个addin文件并要求将来的用户安装它。 您没有提到您正在使用的Excel版本,但Addins上的Excel 2010参考是http://msdn.microsoft.com/en-us/library/office/gg597509%28v=office.14%29。 ASPX

编辑:重读你的帖子我想你可能想问一下数据标签而不是X轴标题。 在这种情况下,您将要使用:

ActiveSheet.Charts("Chart 1").SeriesCollection(1).Points(1).DataLabel.Text

现在有了这个和上面的内容,你需要确保标题/数据标签首先存在,例如:

If ActiveSheet.Charts("Chart 1").SeriesCollection(1).Points(1).HasDataLabel Then...

如果您需要这方面的帮助,或循环浏览图表/点,最好先寻找答案,如果找不到则另外提出问题。

干杯!


  1. I would use VBA yes, but then that's just what I work with
  2. The property you're looking for is

ActiveSheet.Charts("Chart 1").Axes(xlCategory).AxisTitle.Text

  1. To make sure the macro is available in all worksheets, create an addin file and ask future users to install it. You didn't mention what version of Excel you're using, but the Excel 2010 reference on Addins is http://msdn.microsoft.com/en-us/library/office/gg597509%28v=office.14%29.aspx

EDIT: rereading your post I think you may have meant to ask about Data Labels rather than the X-Axis Title. In which case you'll want to use:

ActiveSheet.Charts("Chart 1").SeriesCollection(1).Points(1).DataLabel.Text

Now with this and the above, you'll want to make sure the Title/Data Label exists first, for example with :

If ActiveSheet.Charts("Chart 1").SeriesCollection(1).Points(1).HasDataLabel Then...

If you need help with this, or with looping through the charts /points, it's probably best to look for the answer first and ask a separate question if you can't find.

Cheers!

相关问答

更多
  • 您试图在系列中添加点之前更改点的颜色。 将下面的块移出while循环,并在尝试按索引访问之前检查是否有足够的点存在, chart.Series["series1"].Points[0].Color = Color.Green; chart.Series["series1"].Points[1].Color = Color.Red; chart.Series["series1"].Points[2].Color = Color.PowderBlue; chart.Series["series1 ...
  • 在x轴上设置'gridLineWidth'和'gridLineColor'。 xAxis: { categories: ['Label', 'Label', 'Label', 'Label', 'Label', 'Label', 'Label', 'Label', 'Label', 'Label', 'Label'], title: { text: null }, ...
  • 我会使用VBA是的,但那就是我的工作 您正在寻找的房产是 ActiveSheet.Charts("Chart 1").Axes(xlCategory).AxisTitle.Text 要确保宏在所有工作表中都可用,请创建一个addin文件并要求将来的用户安装它。 您没有提到您正在使用的Excel版本,但Addins上的Excel 2010参考是http://msdn.microsoft.com/en-us/library/office/gg597509%28v=office.14%29。 ASPX 编辑:重读 ...
  • 您需要xlabel属性: ax.set_xlabel("") 。 You need the xlabel attribute: ax.set_xlabel("").
  • 使用OnChartValueSelectedListener : @Override public void onValueSelected(Entry e, Highlight h) { final String x = chart.getXAxis().getValueFormatter().getFormattedValue(e.getX(), chart.getXAxis()); } Highlight对象包含有关所选位置的附加信息 ,例如dataSetIndex,所选值的x和y位置(以像 ...
  • 如何获取有关org.openxmlformats.schemas.drawingml.x2006对象的信息: 所有Office Open XML文件( *.xlsx , *.docx , *.pptx )都是ZIP压缩文件。 所以我们可以将它们解压缩并查看内部。 因此,创建一个带有条形图的*.xlsx文件,并对轴和网格线进行着色并对轴字体进行格式化。 然后解压缩*.xlsx文件并查看xl/charts/chart1.xml 。 在那里你会发现像这样的东西: ...
  • 如果您正在使用chart.js 2,那么您可以使用此处记录的工具提示回调方法,如此内部选项,以便自定义您的工具提示 tooltips: { callbacks: { label: function(tooltipItem, data) { //TODO return what you want using value of tooltipItem and data } } } If y ...
  • 所以我终于明白了。 如果使用'plotarea'键,则可以指定边距。 例如: "plotarea":{ "margin":"40px 20px 50px 100px" } 更新后的示例: ZingChart