473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Explanation needed

3 New Member
Hi, can any one explain me what function of this for loop and the 'execute immediate command line' . C_ALTER_INDEXES is a cursor

FOR L_ALTER_INDEXES IN C_ALTER_INDEXES
LOOP
DBMS_OUTPUT.PUT _LINE(L_ALTER_I NDEXES.INDEX_AL TER);
EXECUTE IMMEDIATE L_ALTER_INDEXES .INDEX_ALTER;
END LOOP;
Feb 14 '08 #1
7 1260
debasisdas
8,127 Recognized Expert Expert
What Is The Problem With The Code ?

Is That Your Code ?
Feb 15 '08 #2
nahom
3 New Member
What Is The Problem With The Code ?

Is That Your Code ?

no it is by some one else and i am unable to understand the usage of the Execute Immediate function.
Feb 15 '08 #3
amitpatel66
2,367 Recognized Expert Top Contributor
no it is by some one else and i am unable to understand the usage of the Execute Immediate function.
Let me brief you on what is the use of EXECUTE IMMEDIATE:

EXECUTE IMMEDIATE is used to execute dynamic sql statements (queries). The sql statements which are not known till runtime are dynamic sql statements which are constructed dynamically and executed using EXECUTE IMMEDIATE statement.

The piece of code that you have provided is not enough for our experts to explain you in detail.

Please provide full source snippet, what is the cursor all about, and what data the cursor handle holds etc.
Feb 15 '08 #4
nahom
3 New Member
Thanks very much for this explanation I am able to make sense of the remaining code.
Feb 15 '08 #5
amitpatel66
2,367 Recognized Expert Top Contributor
Thanks very much for this explanation I am able to make sense of the remaining code.
You are welcome :) .
Feb 19 '08 #6
subashsavji
93 New Member
Hi, can any one explain me what function of this for loop and the 'execute immediate command line' . C_ALTER_INDEXES is a cursor

FOR L_ALTER_INDEXES IN C_ALTER_INDEXES
LOOP
DBMS_OUTPUT.PUT _LINE(L_ALTER_I NDEXES.INDEX_AL TER);
EXECUTE IMMEDIATE L_ALTER_INDEXES .INDEX_ALTER;
END LOOP;
some of example of execute immediate and cursor.
Expand|Select|Wrap|Line Numbers
  1.  
  2. DECLARE
  3. 2 MY_CURSOR NUMBER;
  4. 3 RESULT NUMBER;
  5. 4 BEGIN
  6. 5 MY_CURSOR := DBMS_SQL.OPEN_CURSOR;
  7. 6 DBMS_SQL.PARSE(MY_CURSOR,'SELECT 1 FROM DUAL',0);
  8. 7 RESULT := DBMS_SQL.EXECUTE(MY_CURSOR);
  9. 8 DBMS_SQL.CLOSE_CURSOR(MY_CURSOR);
  10. 9 END;
  11. 10 /
  12.  
  13. both compilation(parsing) and execution happens at same time.
  14. //
  15. create table Test
  16. (
  17. Id integer,
  18. SQLString varchar2(4000)
  19. );
  20.  
  21. insert into Test values (1, 'select count(*) from Emp');
  22. insert into Test values (2, 'select count(*) from Dept');
  23. insert into Test values (3, 'select count(*) from User_Tables');
  24.  
  25. commit;
  26.  
  27. Now, actual PL/SQL block:
  28.  
  29. declare
  30.  
  31. vCount integer;
  32.  
  33. cursor csrSQLToExecute (pId Test.Id%type)
  34. is
  35. select *
  36. from Test
  37. where Id > pId;
  38.  
  39. begin
  40.  
  41. for rec in csrSQLToExecute(0)
  42. loop
  43. execute immediate rec.SQLString into vCount;
  44. dbms_output.put_line('String: ' || rec.SQLString ||
  45. '. Result: ' || to_char(vCount));
  46. end loop;
  47.  
  48. end;
  49. //
  50.  
Feb 20 '08 #7
amitpatel66
2,367 Recognized Expert Top Contributor
Duplicate posts deleted for better management of the forum

MODERATOR
Feb 20 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1441
by: Phil Thompson | last post by:
Hi I'm very new to JavaScript and just need a bit of an explanation to some code and some ideas of how to edit it to do what I want. The script looks for every <pre> on a page and sets them to style="display:none" it then produces links to show and hide the hidden <pre>s. My problem is that I don't wish it to be a <pre> therefore I have...
10
8070
by: eLisHa | last post by:
i have an arraylist that gets it's values dynamiclly from the database, after paging, searching & more in the ASP.net file. What im trying to do, is sort the results that are sorted in the ArrayList, each time by another field. The ArrayList contains a list of a class which i built, that fits these results. I was told to use a IComparer with...
2
1804
by: Susan Bricker | last post by:
I went back to read my post and found an error in my description ... here is the post, again, corrected: The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the desired key value, and then make the entry...
1
3335
by: jimfortune | last post by:
From: http://groups-beta.google.com/group/comp.databases.ms-access/msg/769e67e3d0f97a90?hl=en& Errata: 19 solar years = 2939.6018 days should be 19 solar years = 6939.6018 days Easter Function explanation Part II
6
13907
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the oledbconnection and dataAdapter and filling the DataSet (ds) I tried this: TextBox1.DataBindings.Add("text", ds.Tables.Item("MyFile"), "MyField") ...
14
9726
by: Akhil | last post by:
plz c d following code #include<stdio.h> void main() { int x=4,y=1; y=x++++; //gives error message lvalue required y=x++ + ++y;//no errors
9
2630
by: deepunayak | last post by:
I need complete explanation on constant pointers. e.g char *const ptr ; const char *ptr ; char *const* ptr; please explain me the differences.
20
1400
by: Terrance | last post by:
Hello, I have a question I'm hoping someone can clarify for me. My question regards the declaration of a variable/ array variable. Anyhow, I was wondering if someone can explain the following declaration to me: Dim sendBytes as ( ) = Encoding.ASCII.GetBytes("Is anybody listening...") It looks like type byte is an array. Is this correct?...
12
2099
by: jacob navia | last post by:
Hi I am writing this tutorial stuff again in the holidays and I came across this problem: The "width" field in printf is a minimum width. Printf will not truncate a field. for instance: #include <stdio.h> int main(void) {
2
1663
by: korean_dave | last post by:
Hi. I need a dummy's explanation to utilizing the win32com component to access Microsoft Excel. So far, I have this code. import win32com.client xl = win32com.client.Dispatch("Excel.Application") xl.Visible = 1 workbook = xl.Workbooks.Open("C:\test.xls")
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.