Home » Developer & Programmer » Forms » count the number of column
count the number of column [message #271854] Wed, 03 October 2007 03:00 Go to next message
ramaro
Messages: 2
Registered: May 2007
Location: MADAGASCAR-Antananarivo
Junior Member
Hi all,
I work with forms 6i and database oracle 8. I want to know if it's possible to count the number of column in a sql query. For exemple, i have : "select id, name, dtbirth from table". In this query, I have 3 column. But I don't know how can I get it! Someone can help me! please!

best regards.
Re: count the number of column [message #271856 is a reply to message #271854] Wed, 03 October 2007 03:05 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Count number of commas + 1 between SELECT and FROM.

What do you plan to do with this information?
Re: count the number of column [message #271864 is a reply to message #271856] Wed, 03 October 2007 03:45 Go to previous messageGo to next message
ramaro
Messages: 2
Registered: May 2007
Location: MADAGASCAR-Antananarivo
Junior Member
Thank's for your help. I can't do this because my select is in a cursor.

I fetch data in a loop. And in this loop, i create an another loop for affectation. I want to do this :
........
for c1 in cur_ex loop
while i<nbr_col
dbms_output.put_line('column['||i||']=' ||c1(i));
i:=i+1;
end;
........
for exemple.

end loop;
Re: count the number of column [message #271874 is a reply to message #271864] Wed, 03 October 2007 04:25 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Who wrote this cursor? You? If so, number of columns is not unknown.

What is "c1(i)" supposed to do? Such a syntax is invalid (unless there's a function named c1, but - regarding the context - I'd say that you are talking about a cursor variable).

Finally, what are you trying to do? What should be the result of this operation?
Re: count the number of column [message #272116 is a reply to message #271874] Thu, 04 October 2007 01:27 Go to previous messageGo to next message
anisam10674
Messages: 18
Registered: March 2007
Junior Member
As far as number of columns of a table is concerned we can use the following query...

SELECT COUNT(column_name) FROM all_tab_columns WHERE table_name =<table_name>

Maybe some logical inclusions in the above query can solve your purpose
Re: count the number of column [message #272440 is a reply to message #272116] Fri, 05 October 2007 01:21 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
For crying out loud, WHAT ARE YOU TRYING TO DO?

David
Previous Topic: frm-41214: unable to run report
Next Topic: Tiny_Oracle Arrives !!
Goto Forum:
  


Current Time: Sat Dec 03 01:06:22 CST 2016

Total time taken to generate the page: 0.10557 seconds