Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag for India asked on

why my pl/sql program not running

what is wrong in the code

declare
cursor c1 is
select  '1' "a" ,'2' "b" ,'3' "c"  from dual ;
begin
for i in  c1
loop
--open c1;
dbms_output.put_line(i.a);
--close c1;
end loop;

end;


its giving error like

                       *
ERROR at line 8:
ORA-06550: line 8, column 24:
PLS-00103: Encountered the symbol "a" when expecting one of the following:
<an identifier> <a double-quoted delimited-identifier> delete
exists prior
Oracle DatabaseSQL

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
slightwv (䄆 Netminder)

double quotes force case sensitivity.

try:

...
select  '1' a ,'2' b ,'3' c  from dual ;
...

or

...
dbms_output.put_line(i."a");
...
Sathish David Kumar N

ASKER
both or giving error
slightwv (䄆 Netminder)

Make one change or the other.  Not both.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Sathish David Kumar N

ASKER
ya 2 nd one works....

how can use multiple for loop

eg:
for i in  c1 1..2 like that

 i need for loop excute 2 time
Sathish David Kumar N

ASKER
declare
cursor c1 is
select  '1' "a" ,'2' "b" ,'3' "c"  from dual WHERE ROWNUM<3;
begin
for i in 1..2 c1
loop
--open c1;
dbms_output.put_line(i."a");
--close c1;
end loop;

end;
slightwv (䄆 Netminder)

>>ya 2 nd one works....

You really should not use double quotes around object names in Oracle.  It will get you into trouble later.

Personally I would have gone with the first option.

>> i need for loop excute 2 time

No, you cannot do that.

Why do you need to loop through the records twice?

>>select  '1' "a" ,'2' "b" ,'3' "c"  from dual WHERE ROWNUM<3;

There is only one row in DUAL so ROWNUM<3 does nothing.


What real problem are you trying to solve?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Sathish David Kumar N

ASKER
i need to  fetching data  twise for writing in xml
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sathish David Kumar N

ASKER
<student>
<studentname>
<mark>
<sub1>10</sub1>
<sub1>20</sub1>
<sub1>20</sub1>
</mark>
</studentname>
<studentname>
<mark>
<sub1>10</sub1>
<sub1>20</sub1>
<sub1>20</sub1>
</mark>
</studentname>
</student>
Sathish David Kumar N

ASKER
This my sample xml file i need to genrate i get only one row mark i need to hard code student name how to do that !!

<student>
<studentname>Sathish</studentname>
<mark>
<sub1>10</sub1>
<sub1>20</sub1>
<sub1>20</sub1>
</mark>
<studentname>kumar</studentname>
<mark>
<sub1>10</sub1>
<sub1>20</sub1>
<sub1>20</sub1>
</mark>
</student>
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Sathish David Kumar N

ASKER
DECLARE
v_filename      VARCHAR2 (255);
V_XML_CONTENT   VARCHAR2 (4000);
v_filehandle    UTL_FILE.file_type;
CURSOR C1 IS
SELECT '2000' "v1",'01014337048' "v2" ,'087' "v3", 'SGD' "v4",'IT11031204202838' "V5",'120420' "v6" FROM EMPLOYEES
WHERE ROWNUM < 3;
begin

   v_filename := TO_CHAR (SYSDATE, 'YYYYMMDD_HH24MI') || '.xml';
   v_filehandle := UTL_FILE.fopen ('F:\sekar', v_filename, 'W');
for i in 1..2
loop
v_xml_content := v_xml_content || '<stuentname>' || CHR (10);
v_xml_content := v_xml_content || '<mark>' || CHR (10);
v_xml_content :=v_xml_content  || '<sub1>' || CHR (10);
v_xml_content := v_xml_content || '<sub2>' || CHR (10);
UTL_FILE.put_line (v_filehandle, v_xml_content);
UTL_FILE.fclose (v_filehandle);
END LOOP;
end;
Sathish David Kumar N

ASKER
any update/??
slightwv (䄆 Netminder)

I see you have asked a new question.  I can no longer post here or it becomes a duplicate.

I suggest you close this since it is about why the pl/SQL will not run and that has been answered.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Sathish David Kumar N

ASKER
any update
slightwv (䄆 Netminder)

Did you read my last post?

Also, posts in a question are only available to Experts that have already posted.  Posting asking for updates does nothing to help.