我使用游标来查看一些数据,但我需要根据参数声明不同的sql语句。问题似乎是我无法在该声明中使用 if statmets:
DECLARE
CURSOR c IS SELECT * FROM TRAFICO
IF TipoConsulta = 'mes' then
BEGIN
WHERE TO_CHAR(FECHA_BUSQUEDA, 'MM-YYYY') =To_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM-YYYY')
ELSE
WHERE FECHA_BUSQUEDA >= SYSDATE -7
END IF;
ORDER BY ID_TRAFICO;
begin
FOR r IN C LOOP
BEGIN
Utl_File.Put_Line(Arch, r.ID_TRAFICO );
i:=i+1;
END;
END LOOP;
END;
Run Code Online (Sandbox Code Playgroud)
我只需要使用 if 更改 sql 语句即可。
我该怎么做呢??
TNKS
我习惯了Ctrl DOWN许多编辑器中的键盘快捷键,它将插入符号(光标)跳转到代码中的下一个空白行。这允许快速导航代码。
也许我完全错过了它,但是“将插入符移动到下一个空白行”或类似的操作并不在编辑器的键盘映射列表中。
您知道是否有这样的选项,如果没有,您能推荐一种浏览代码的好方法吗?当我移动代码时,“将插入符移动到代码块开始”对我来说不是很直观,而且简单的向上翻页、向下翻页太粗糙了。
编辑:正如@CrazyCoder所说,此功能似乎不可用。我已在 YouTrack 上为其添加了一张票。如果您也对此功能感兴趣,请投票。
我正在尝试在 Cursor 上使用自定义图像,并使用这些代码做到了。
public static class cursorHelper
{
public static Cursor vertical = new Cursor(Application.GetResourceStream(getFromResource("PenCADwpf", "Images/cursors/Vertical.ico")).Stream);
public static Cursor horizontal = new Cursor(Application.GetResourceStream(getFromResource("PenCADwpf", "Images/cursors/Horizontal.ico")).Stream);
public static Uri getFromResource(string psAssemblyName, string psResourceName)
{
Uri oUri = new Uri("pack://application:,,,/" + psAssemblyName + ";component/" + psResourceName, UriKind.RelativeOrAbsolute);
return oUri;
}
public static ImageSource getImageSourceFromResource(string psAssemblyName, string psResourceName)
{
Uri oUri = getFromResource(psAssemblyName, psResourceName);
return BitmapFrame.Create(oUri);
}
}
Run Code Online (Sandbox Code Playgroud)
在代码中使用的是
private void btnVerticalMullion_Click(object sender, RoutedEventArgs e)
{
this.Cursor = cursorHelper.vertical;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是光标的热点是左下角。我需要将其更改为图像的 0,0(左上角)点。请问有人可以帮助我吗?提前致谢,
我有一个 .cur 文件路径 ( "%SystemRoot%\cursors\aero_arrow.cur"),我想在图像控件中显示。所以我需要将 Cursor 转换为 ImageSource。我尝试了 CursorConverter 和 ImageSourceConverter 但没有运气。我还尝试从光标创建图形,然后将其转换为位图,但这也不起作用。
该线程说:
直接将 Cursor 转换为 Icon 很复杂,因为 Cursor 不公开它使用的图像源。
和
如果您确实想将图像绑定到光标,您可能想尝试一种方法。
由于WindowForm能够绘制光标,因此我们可以使用WindowForm在位图上绘制光标。之后我们可以找到一种方法将该位图复制到 WPF 支持的位置。
现在有趣的是,我无法创建System.Windows.Forms.Cursor既没有文件路径也没有流的新实例,因为它抛出以下异常:
System.Runtime.InteropServices.COMException (0x800A01E1):
Exception from HRESULT: 0x800A01E1 (CTL_E_INVALIDPICTURE)
at System.Windows.Forms.UnsafeNativeMethods.IPersistStream.Load(IStream pstm)
at System.Windows.Forms.Cursor.LoadPicture(IStream stream)
Run Code Online (Sandbox Code Playgroud)
System.Windows.Input.Cursor那么有人可以告诉我转换为的最佳方法吗ImageSource?
.ani 光标又如何呢?如果我没记错的话System.Windows.Input.Cursor不支持动画光标,那么我该如何向用户显示它们呢?将它们转换为 gif 然后使用 3d party gif 库?
我知道在 SQL 中创建和使用游标既不安全也不高效,但有时它是唯一的选择。现在这是我唯一的选择。
我的问题不是如何避免使用游标,而是如果游标仅在存储过程中动态创建的临时表上运行,那么安全性如何以及会引发哪些性能问题。我知道游标的运行速度比设置操作慢,并且会在它们正在迭代的表上加锁。我的临时表是一个相对较小的表,仅包含一个 int 类型的字段和最多 50 条记录。
DECLARE @pD int
DECLARE CurDB CURSOR FOR
SELECT pD FROM #mD
open CurDB
fetch next from CurDB into @pD
etc...
Run Code Online (Sandbox Code Playgroud) MySQL 5.5
CREATE TABLE `card` (
`id` int,
`cardnumber` varchar(100),
`customer` varchar(100),
PRIMARY KEY (`id`)
);
INSERT INTO `card` VALUES (1, '5000', 'Google');
Run Code Online (Sandbox Code Playgroud)
DELIMITER //
CREATE PROCEDURE `test` ()
BEGIN
DECLARE finished INTEGER DEFAULT 0;
DECLARE cardnumber varchar(20) DEFAULT "";
DECLARE cursor1 CURSOR FOR SELECT cardnumber FROM card WHERE customer = 'Google';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN cursor1;
get_card: LOOP
FETCH cursor1 INTO cardnumber;
IF finished = 1 THEN
LEAVE get_card;
END IF;
END …Run Code Online (Sandbox Code Playgroud) 当然,这个问题以前已经被问过,但我找不到这个问题。
据我了解,在Python中(我使用的是3.3,但这对2.x和3.x来说是通用的)你不能在打开的文本文件上多次迭代,这是因为光标被移动到末尾并且不会返回到下一个可迭代循环的开头。因此它的行为不像一个更典型的可迭代对象。
我想知道如何将光标返回到开头,或者至少在要读取的打开文件上连续两个 for 循环。
谢谢。
对于 X 中的所有表,而 X 是
select table_name from all_tab_cols
where column_name = 'MY_COLUMN'
and owner='ADMIN'
Run Code Online (Sandbox Code Playgroud)
我需要检查列 MY_COLUMN 是否具有“Y”或“N”以外的其他值,如果有,则打印出表名称。
伪代码:
for table in X:
if MY_COLUMN !='Y' or MY_COLUMN !='N':
print table
Run Code Online (Sandbox Code Playgroud)
我想如何在 PL/SQL 中使用游标来实现它?
很高兴见到你。我在使用 wxpython 时遇到一些问题。那是我无法控制 TextCtrl 函数的光标。这是我的 wxpython 代码。
#!/usr/bin/python
import wx
def get_main_screen_text():
text = "\n [Anyfusion Monitoring System]\n\n"
return text
class Tom(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(400, 420))
panel = wx.Panel(self, -1)
vbox = wx.BoxSizer(wx.HORIZONTAL)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
self.message = get_main_screen_text()
self.write = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE, value=self.message)
System_Checkup = wx.Button(panel, 1, label='System_Checkup')
Open_the_Web = wx.Button(panel, 1, label=' Open_the_Web ')
Help_Desk = wx.Button(panel, 1, label=' Help_Desk ')
Exit = wx.Button(panel, 1, label=' …Run Code Online (Sandbox Code Playgroud) 我正在尝试向我的项目添加拖放功能,并为此使用slip.js。
为了装饰光标,我添加class="draggable"到每个可拖动的<tr>。这个类的 CSS 是:
.draggable:active {
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
Run Code Online (Sandbox Code Playgroud)
拖放工作正常,但在 Safari 中,当我拖动表格行时,光标看起来像cursor: text
在 Chrome 中,光标正常
有趣的是,当我只需单击并按住而不拖动光标时,在 Safari 中也可以