Anonymous block with Variable and SELECT
Hi guys,.I'm fighting to connect the material that I am learning. I read on the anonymous blocks and variable so I want to write a
Nice and neat select with all the fancy stuff (variables, exceptions) to get it right and what I read in the book.
DECLARE
MYSTRING AS VARCHAR (10);
MYSTIRNG: = 'X '.
BEGIN
SELECT * FROM DUAL WHERE DUMMY = MYSTRING
END;
but... This causes an error after another. I get the wrong concept here or is this a syntax error?
PL/SQL, you will need to use SELECT... IN...
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/sqloperations.htm#sthref1348
SQL> declare
2 mystring varchar(10) := 'X';
3 myvar varchar(10);
4 begin
5 select dummy into myvar
6 from dual
7 where dummy = mystring;
8 dbms_output.put_line(myvar);
9 end;
10 /
X
PL/SQL procedure successfully completed.
Tags: Database
Similar Questions
-
I want to add a new application to the list right click on file-> open with
and also reorder the list so my search app is first / top of the list.
I know that I can use open with-> other and select any application, but it takes too long I should use my intended application in this way several times a day.
Basically, I'm looking for a configurable way configure open with, something more to send to Windows.
Thank you very much for all the advice offered.
The operating system, not you, not control that open with the menu command.
-
Why Microsoft Virtual PC comes with Reboot and select proper boot device?
Hello
When that I start Microsoft Virtual PC 2007 it comes up with the following error message:
Reboot and select proper boot device
or insertion of the in the selected boot device bootable media
How can I fix it?
I am running Windows 7 Professional 32 - bit.
Any help?
You have installed an operating system on the virtual device?
You have created a virtual machine. When you start it, it will try to start.
There is nothing on the virtual drive so that the system asks to find a bootable floppy
disk or CD/DVD.If you still need help, you can post in the Microsoft Virtualization forum listed below:
http://social.technet.Microsoft.com/forums/en-us/w7itprovirt/threadsSincerely,
-
Problems with harvest and select Quick - HELP!
Well, I'm frustrated. When I try to use the quick select tool or a photo in Photoshop CC, the screen keeps cycling between showing my image and a black screen. For this reason, I don't see what I do to select anything or to crop the picture correctly. This isn't always as that, so I'm puzzled to understand how to fix it. It continues to Flash between the two, spend more time on the black screen of the photo.
Hi mamaliciousbaby,
This was a known problem with Windows 8 graphics processor unit (GPU) pilots. They work with sellers of GPU and Microsoft to reach a solution.
At the same time, changing your GPU mode to 'Basic' in drawing preferences should get rid of the flicker of the screen black.
To do this, first go to preferences--> Performance.
A dialog box appears, locate the "Graphics Processing" box:
Click Advanced settings and change the drawing in "Basic" Mode
Click OK and you should be able to continue without more questions.
This problem can also be resolved by upgrading your hardware, here are some useful forum threads which can also answer many of your questions:
Why Photoshop Blink? (Windows 8) and Black flickering screen (for Mac).
I hope this helps!
Clarice
-
Working with layers and selections.
I have 3 layers. The top layer has a choice I want to return, but when I try to reverse all the layers flip, even if only the top layer is slecected. Any help would be grateful.
You want to invert the selection or just the layer itself?
Do not use a command like "Rotate" under the icon and commercial that assumes that you want to transform the whole of the project. Tap the transformation (5th icon from the right upper-right) and then click the appropriate command. (for example, if you want to return either horizontally or vertically, these icons are on the left in the dialog box.)
If you want to transform a selection, these tools are available via the icon selection in the upper left corner options (4th icon from the left > "Transform").
-
using vsize() with variables and fields
Hello
I have a trigger that generates timestamps. I need to how long (in bytes) are the values that the trigger generates debug output. So here's what I'm trying to do:
I guess it's obvious what to do. How can I write this code exactly?create or replace trigger my_table_bu before update on my_table for each row declare l_size number; begin :new.my_timestamp := localtimestamp; l_size = vsize(:new.my_timestamp); dbms.ouput.put_line(to_char(l_size)); end my_table_bu;
Thank you!If you need to...
and to be academically correct, you would probably do better
declare s timestamp (6) := localtimestamp; v varchar2(20); begin select vsize (s) into v from dual; dbms_output.put_line ('PL/SQL Timestamp: ' || v); end; /
to take into account (unlikely) differences in sql / plsql lengths.
-
Problem with the window "Variables and stack calls ': Options / interpret as
Hello NO,.
I found a way to run the JIT-debugger LabWindows/CVI on ICB itself...
This is the procedure:
- I put a breakpoint, run the code, and the breakpoint, I opened the window "Variables and stack calls" by right clicking on a variable and selecting 'Display Variable View.
- Any variable shown, I right click and choose Options / interpret as
You're right, I could now reproduce as well. It seems as if the presence of a function pointer, if set or not, causes interpret as shatter the debugger. The ADE does not seem to be affected, but you will probably have to restart your debugging session when this happens.
I created the bug report 425151.
I really appreciate the time spent in this narrowing for me. Thank you!
Luis
-
Hello any help would be greatly appreciated, all of a sudden I could not receive the updates of windows vista Home premium and my mail AOL not the home page of AOL, but when I click on the mail tab sometimes blocked with explore and Firefox. I have checked all my security settings and toured various forums but have been unable to solve the problem. If anyone has any ideas please help. Thanks Steve
Hello
Question 1:
I suggest that reset you the Windows update components and check if you have the same problem. You can check the link that will give you information on how to reset below updated Windows component update:
http://support.Microsoft.com/kb/971058
Question 2:
Concerning the question associated with AOL mail, I suggest that you contact AOL support to help you. You can check the link that will give you information on the help of AOL Mail below:
http://help.AOL.com/help/product/aol_webmail/
Thank you
Irfan H, Engineer Support Microsoft Answers -
Repository initialization Blocks (OBIEE) variable
Hello
I've created a repository variable and the type of variable is dynamic, the variable called "Read_Data" and I initialized the block with this query "select FirstName from employees where idEmp =: val.
My problem is in obiee when I call the variable I need to initialize the value of idEmp
How can I do this?
I have another on the initialization blocks why when I use this query 'select FirstName from employees' and I get only the first data, even though my table contains 100 data?
Thanks for help
In addition to this Gabin says (initialization) to your first question, I assume that you have some idea of 'dynamic variable repository' a little bit.
A dynamic variable repository is not as dynamic as you imagine. The main feature compared to a static is that the value of the variable comes from a SQL instead of being entered manually in the administration tool.
SQL is a type of static query and not refresh when you call the variable and want to use it, but it is filled only once or maximum according to the calendar. For example, you use this query to store values as the period under review (and you have a query that retrieves the period max responsible for your data once per hour or something like that).
Even a session variable will not really what you expect or at least not exactly how you think that it: initialize the variable when you call it works only once if you check the box "performance" you just to delay the execution of the query until you access it for the first time , but at this point, it is defined and it will not refresh until you do not close the session to begin a new.
So for what you are trying to do, I suggest you find another way because it really does work.
-
What is anonymous block, what is the usefulness of this, when he'll create...
One of them please send me the link.Hello
An anonymous block with the keyword 'start' stats and ends with the "end" keyword
It store all of the commands you want this block to do.
Whenver required, you can then run this code to perform the same tasks over and over again.
But the preferred method is to use the functions and procedures stored in memory and runs faster.
For more details and information, please see:
http://www.orafaq.com/wiki/Anonymous_block
Procedures and functions:
http://www.techonthenet.com/Oracle/procedures.php
HTH
KK -
Error of closure with variable
Dear all,
Please help me. I want to loop recording. I have two diet. First of all, I do without variable and no mistake. Second, I do with variable and error occurs. below my syntax:
First of all:
------
declare
x varchar (50);
Start
-x: = 'choose the double dummy;
C1 in loop (double dummy selection)
dbms_output.put_line (C1. Dummy);
end loop;
end;
result:
-------
X
--------
Second:
declare
x varchar (50);
Start
x: = 'choose the double dummy;
C1 (looping x)
dbms_output.put_line (C1. Dummy);
end loop;
end;
result:
-------
Encountered the symbol "LOOP" when expected...If you want to use a dynamic SQL statement, you would need something like
SQL> ed Wrote file afiedt.buf 1 declare 2 l_cursor sys_refcursor; 3 l_sql_stmt varchar2(100); 4 l_dummy varchar2(1); 5 begin 6 l_sql_stmt := 'select dummy from dual'; 7 open l_cursor for l_sql_stmt; 8 loop 9 fetch l_cursor into l_dummy; 10 exit when l_cursor%notfound; 11 dbms_output.put_line( l_dummy ); 12 end loop; 13 close l_cursor; 14* end; SQL> / X PL/SQL procedure successfully completed.
Justin
-
How do I repair: windows7 error reboot and select proper boot device?
My computer is about 2 years old. Sound works just fine. One morning, I started it up and a black screen came with: reboot and select proper boot device or insert boot media in selected boot device and press a key. Any key you hit it just kept announces the same message, I had to tough out. As long as I start the computer with Del, F8 or F10, I can get the computer to boot. No matter what I change, it works for a few times then goes back to the same error. Also it will not always wake up after he falls asleep. I tried to do a repair of systems, but it does not work
Hello
1 do you have made no changes to software before this problem?
2. you have the Windows 7 installation disc?
3. what changes did you and have you been able to boot to the desktop after that?
Method 1:
I also suggest you to try the other options of WINRE (Windows Recovery Environment) and check.
What are the system recovery options in Windows 7?
http://Windows.Microsoft.com/en-us/Windows7/what-are-the-system-recovery-options-in-Windows-7
Method 2:
I also suggest you to check the drive for errors that it can cause a Windows to boot.
Follow this step to do the same thing:
- Click Start
- Type: CMD, according to the results, right-click CMD-> click on "Run as Administrator"
- At the command prompt, type: chkdsk /r
When you restart your system, your computer will be scanned for errors and will try to correct them.
Note: Running chkdsk on the drive if bad sectors are found on the disk hard when chkdsk attempts to repair this area if all available on which data can be lost.
Check a drive for errors
http://Windows.Microsoft.com/en-us/Windows7/check-a-drive-for-errors
The issue can also occur if the boot device is not correctly defined in the BIOS. Make sure that the hard drive where Windows is installed is selected as first boot device.
Note: Changing the BIOS / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.
See also:
-
Compare with variable binding sql stored proc vs
I have a complicated logic coded in the two sql with variables and stored procedure I need to compare the performance of the two and decide which binding. with sql, I think I must watch the plan exec etc. and get metrics. How can I do to stored procuser8798946 wrote:
the sql will be a plsql function. I have to choose wheter I implemting the sql code in the plsql or a version of sql plsql. hope that what I say makes sense.Are you meaning "I can write an SQL statement in a procedure, or I can PL/SQL code to do the same thing as the SQL statement and the loop via a slider?
If so, then go with the SQL statement.
-
Unexpected result with select max (colmn) in anonymous block
Hello
The following query gives me 28 800 like sum (sal)
But when I use the above query in anonymous block, it gives me 684400SELECT SUM(salary) FROM employees WHERE department_id =60 O/P is : 28800
Exit instructions above gives me 684400 as output... But the grounds are 28800DECLARE v_sum_sal NUMBER; department_id employees.department_id%TYPE := 60; BEGIN dbms_output.put_line ('The department_id is'||department_id); SELECT SUM(salary) into v_sum_sal FROM employees WHERE department_id = department_id ; dbms_output.put_line ('The sum of sal is'||v_sum_sal); END;
You can me why the output differs block anonymous reference pleaseHello
What about prefixing all your PL/SQL variables so that they do not match a column_name :
DECLARE v_sum_sal NUMBER; v_department_id employees.department_id%TYPE := 60; BEGIN dbms_output.put_line ('The department_id is'||v_department_id); SELECT SUM(salary) into v_sum_sal FROM employees WHERE department_id = v_department_id ; dbms_output.put_line ('The sum of sal is'||v_sum_sal); END;
Because, with the first names, where clause was equivalent to:
where 1=1
-
Anonymous blocks that goes down and creates a table
Version: 11.2.0.3
I'm relatively new to PL/SQL.
We have a table named CHK_CNFG_DTL.
I want to create a backup table for CHK_CNFG_DTL who will be named as CHK_CNFG_DTL_BKP_ < timestamp > for example: CHK_CNFG_DTL_BKP_JULY_22_2013
Creating this backup table must be automated, so I want to create an anonymous block that will first remove the existing backup table and then create a new backup of the original table.
The code below works fine. But the first time when you run it, the loop will not iterate because there is no such table named % CHK_CNFG_DTL_BKP.
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like '% CHK_CNFG_DTL_BKP')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
end;
/
PL/SQL procedure successfully completed.
-Backup table was not created.
SQL > select table_name from user_Tables where table_name like '% CHK_CNFG_DTL ';
TABLE-NAME
------------------------------
CHK_CNFG_DTL
Of course, this can fixed by creating a table as bleow before running the anonymous block
SQL > create table CHK_CNFG_DTL_BKP_JULY_22_2013 (x varchar2 (37));
Table created.
and now the block will be executed with success as
24 end;
25.
drop table CHK_CNFG_DTL_BKP_JULY_22_2013 purge
Creating table Bkp CHK_CNFG_DTL_BKP_22_JUL_2013
create the table CHK_CNFG_DTL_BKP_22_JUL_2013 select * from CHK_CNFG_DTL
PL/SQL procedure successfully completed.
But it goes to production. We cannot have a table like CHK_CNFG_DTL_BKP_JULY_22_2013 without an appropriate reason.
How can I change the code above so that if even if there is no such like '% CHK_CNFG_DTL_BKP' table, he will create the backup table?
Hello
Why don't you press the create backup of the loop?
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like 'CHK_CNFG_DTL_BKP %')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
end;
Maybe you are looking for
-
Satellite C850 - 1 9 8 Windows recovery disc language NH
Hello C850 my gran has a dead hard drive, and she did not Windows 8 recovery disks.I am pleased to order them directly from Toshiba, but when I do the single lagnuage option is NH. NH, what exactly? I need them in English. Any ideas? KeV
-
contact customer service link does not work
It indicates that the service is unavailable, whenever I click on the link to try and get intouch with them.
-
De : M.V.Miller Vista window Mail & Windows Live Mail both give me the same error: Your server suddenly put an end to the connection. The possible causes for this include server problems, network problems, or a long period of inactivity. Subject ' te
-
Windows Vista 64 bit not Shutting Down
I have Windows Vista 64-bit and after a few recent updates it will not shut correctly. The screen saying shutting down just y rest turns and it never stops. I have to use the power button then go through "Windows is not stopped correctly." Does anyon
-
problem starting C:/users/l/appdata/local/playto~l/updater.dll
need help to get users and update on my computer