Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Sql Developer在脚本中查看刚刚修改的表_Sql_Oracle_Select_Plsql_Oracle Sqldeveloper - Fatal编程技术网

如何使用Sql Developer在脚本中查看刚刚修改的表

如何使用Sql Developer在脚本中查看刚刚修改的表,sql,oracle,select,plsql,oracle-sqldeveloper,Sql,Oracle,Select,Plsql,Oracle Sqldeveloper,我在sql developer中看到了此块: begin delete from temp; insert into temp values (1); dbms_output.put_line('Done'); end; 如果我点击F5,脚本运行正常。该表更新为值1,“脚本输出”选项卡显示“完成” 但是,我希望在执行块后,在“结果”选项卡中自动可视化刚刚修改的表。可能吗?怎样 感谢您的帮助。谢谢。不需要任何匿名PL/SQL块。只需将SQL语句作为脚本运行 delete from temp

我在sql developer中看到了此块:

begin
 delete from temp;
 insert into temp values (1);
 dbms_output.put_line('Done');
end;
如果我点击F5,脚本运行正常。该表更新为值1,“脚本输出”选项卡显示“完成”

但是,我希望在执行块后,在“结果”选项卡中自动可视化刚刚修改的表。可能吗?怎样
感谢您的帮助。谢谢。

不需要任何匿名PL/SQL块。只需将SQL语句作为脚本运行

delete from temp;
insert into temp values (1);
select * from temp;
将上述三条语句放在SQL Developer工作表中,然后按F5作为脚本运行,请参见脚本输出选项卡中的输出。最后,您必须提交,以使表更改永久化

不能在PL/SQL中执行
select*from表
,因为它是纯SQL语句。PL/SQL需要一个INTO子句。如果可以在纯SQL中执行同样的操作,则永远不要在PL/SQL中执行

但是,如果您确实想在
BEGIN-END
块中执行此操作,则将SELECT语句放在PL/SQL块之外。不要合并PL/SQL和SQL

begin
 delete from temp;
 insert into temp values (1);
 dbms_output.put_line('Done');
end;
/
select * from table;

不需要任何匿名PL/SQL块。只需将SQL语句作为脚本运行

delete from temp;
insert into temp values (1);
select * from temp;
将上述三条语句放在SQL Developer工作表中,然后按F5作为脚本运行,请参见脚本输出选项卡中的输出。最后,您必须提交,以使表更改永久化

不能在PL/SQL中执行
select*from表
,因为它是纯SQL语句。PL/SQL需要一个INTO子句。如果可以在纯SQL中执行同样的操作,则永远不要在PL/SQL中执行

但是,如果您确实想在
BEGIN-END
块中执行此操作,则将SELECT语句放在PL/SQL块之外。不要合并PL/SQL和SQL

begin
 delete from temp;
 insert into temp values (1);
 dbms_output.put_line('Done');
end;
/
select * from table;
您可以使用光标:

declare 
a temp.id%type; --name column in your table
cursor c1 is
select id from temp;
begin
  delete from temp;
  insert into temp values (1);
  open c1;
  loop 
  fetch c1 into a;
  dbms_output.put_line (a);
  exit when c1%notfound;
  end loop;
  CLOSE C1;
end;
您可以使用光标:

declare 
a temp.id%type; --name column in your table
cursor c1 is
select id from temp;
begin
  delete from temp;
  insert into temp values (1);
  open c1;
  loop 
  fetch c1 into a;
  dbms_output.put_line (a);
  exit when c1%notfound;
  end loop;
  CLOSE C1;
end;

当表格已填充且您不使用delete时,以下操作也将起作用

declare 
    a temp.id%type; --name column in your table
begin
    -- delete from temp;
    insert into temp values (1)
    returning id into a;
    dbms_output.put_line (a);
    dbms_output.put_line('Done');
end;

当表格已填充且您不使用delete时,以下操作也将起作用

declare 
    a temp.id%type; --name column in your table
begin
    -- delete from temp;
    insert into temp values (1)
    returning id into a;
    dbms_output.put_line (a);
    dbms_output.put_line('Done');
end;

谢谢它起作用了。我只是对dbms_输出前的代码做了一点修改,以避免打印一行什么也找不到。@starko CLOSE C1;代码中缺少语句。是的,没错。谢谢,谢谢!它起作用了。我只是对dbms_输出前的代码做了一点修改,以避免打印一行什么也找不到。@starko CLOSE C1;代码中缺少语句。是的,没错。谢谢