Limit on Select clause
I am working on Oracle 10g 10.2.0.3 and I cannot select more than 1000 columns using SQL.
But I could select more than 1000 columns in Oracle 11g R2.
What is the limit on number of columns that can be selected in a select query on Oracle 11g R2?
Also, can i get Oracle documentation which specifies this limit for select query?
Hi,
I think you can select as many columns you like in both 10g and 11g.
http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/limits003.htm#i288032
You cannot however use more than 1000 columns in say create view as ... or create table as ...
In both cases you will get
ORA-01792: maximum number of columns in a table or view is 1000
These limits probably also mean that you cannot use more than 1000 columns in your select list, when this is part of subquery factoring or inline views, or whenever the optimizer feels like treating that query as a view or table.
In other words, you can:
select 'n1', 'n2', ..., 'n1001' from dual;But you cannot:
select * from
select 'n1', 'n2', ..., 'n1001' from dual
);My guess is, since you have a query in 11g that will not execute in 10g, it is due to how the optimizer re-writes the query in those two versions.
Regards
Peter
Similar Messages
-
Logical limit on Select clause
I am working on Oracle 10g 10.2.0.3 and I cannot select more than 1000 columns using SQL.
But I could select more than 1000 columns in Oracle 11g R2.
What is the limit on number of columns that can be selected in a select query on Oracle 11g R2?
Also, can i get Oracle documentation which specifies this limit for select query?
Edited by: 844063 on Apr 26, 2011 10:53 PMWell, then, on a related note, I have at least some tables that do not show all the columns in the column or data views in SQL Developer. I get the first 76 columns for one table that I have in mind. The index build utility also does not show all the available columns in the table.
"Select *" does show all the columns, and so does the DESCRIBE statement. Is there a setting in preferences (I couldn't find it) that controls this? -
Decimal Separator in SELECT Clause
Hi
I have the following decimal format parameters:
SQL> select value
2 from v$nls_parameters
3 where parameter = 'NLS_NUMERIC_CHARACTERS';
VALUE
If I show a number with decimal I get a comma as the decimal separator
SQL> select 10/100 from dual;
10/100
,1
But if I use a decimal separator in the SELECT clause I get:
SQL> select 100 * 1,1 from dual;
100*1 1
100 1
It doesn't work. But using a period as the decimal separator works:
SQL> select 1.1 * 100 from dual;
1.1*100
110
Maybe this is something I've never had to deal with before but I thought that the numeric format applied to the sql results and also the numbers that you used in the sql clauses.
Regards,
Néstor BoscánHi,Néstor,
user594312 wrote:
... I thought that the numeric format applied to the sql results and also the numbers that you used in the sql clauses.No; it applies to results, and it can affect implicit conversions, but it doesn't apply to SQL code.
The period (or dot, '.') is always the decimal separator in numeric literals. There is no way to change that.
Think how confusing it would be if it did apply to SQL code! For example:
WHERE num_col IN (1,2)Are we comparing num_col to 1 value or 2 values? Whichever it is, what if we wanted to do the opposite?
If you really wanted to use comma as the decimal separator, you could have to use strings, not numbers, and that could be a lot less efficient.
For example:
SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct
FROM dual;Of course, efficiency won't be an issue when you're selecting 1 row from dual. -
Need to know the column names in my dynamic select clause
Dear All,
Please go through the following code. While executing the following code i am getting an error saying that dbms_sql.describe_columns overflow, col_name_len=35. Use describe_columns2.
Please guide me how to proceed further. Or please help me, how can i get the column names when i issue a dynamic select clause.
DECLARE
CUR INTEGER;
COL_CNT INTEGER ;
A INTEGER;
SEL_CLAUSE VARCHAR2(2000);
DESC_T DBMS_SQL.DESC_TAB;
REC DBMS_SQL.DESC_REC;
b number;
BEGIN
SEL_CLAUSE := 'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'',3,''THREE'') FROM DUAL';
--'SELECT ROWID,PARA_SUB_CODE,DECODE('||''''||'ENG'||''''||','||''''||'ENG'||''''||',PARA_NAME,PARA_BL_NAME),NULL,NULL FROM PCOM_APP_PARAMETER';
--'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'') FROM DUAL';
DBMS_OUTPUT.PUT_LINE( SEL_CLAUSE );
CUR := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(CUR,SEL_CLAUSE,DBMS_SQL.NATIVE);
DBMS_SQL.DESCRIBE_COLUMNS(CUR,COL_CNT,DESC_T);
B := desc_t.first;
FOR J IN 1..COL_CNT
LOOP
DBMS_OUTPUT.PUT_LINE('J := '||J || ' COL CNT ' || COL_CNT);
END LOOP;
BEGIN
A := DBMS_SQL.EXECUTE(CUR);
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END;
Regards,
BalajiIs there any way can i have it directly??It does not work with static SQL either. Dynamic SQL is no different.
SQL> select 1 x from dual where x = 1 ;
select 1 x from dual where x = 1
ERROR at line 1:
ORA-00904: "X": invalid identifier
SQL>As suggested already, you will need to use alias if you want your select expression to be referred in the where clause.
SQL> BEGIN
2 FOR rec IN (SELECT *
3 FROM (SELECT 1,
4 2,
5 DECODE(1, 1, 'ONE', 2, 'TWO', 3, 'THREE') "DECODE(1, 1, 'ONE', 2, 'TWO', "
6 FROM DUAL)
7 WHERE "DECODE(1, 1, 'ONE', 2, 'TWO', " = 'ONE')
8 LOOP
9 NULL;
10 END LOOP;
11 END;
12 /
PL/SQL procedure successfully completed.
SQL>Message was edited by:
Kamal Kishore -
¶m lexical variable in SELECT clause
Is there a way to get Oracle*Reports to accept a lexical variable in the SELECT clause? The example is:
SELECT
table.column1,
table.column2,
&PARAM as column3
FROM
table
I am already using lexical variables in the WHERE clause, but getting one to work in the SELECT clause has thus far failed.
The SQL is accepted if :PARAM is used in place of &PARAM, but I am unable to actually vary the selected column this way.
The bind variable PARAM has the following code behind it in a BeforeReport trigger:
IF :ANOTHER_PARAM := 'ALL' THEN
:PARAM = 'ALL'
ELSE
:PARAM = 'table.column3'
When using :PARAM in the SELECT clause, the literals 'table.column3' are returned, not the contents of table.column3.Sorry for the wasted bandwidth. I found a solution. Here it is:
SELECT
table.column1,
table.column2,
CASE :P_USER
WHEN 'ALL' THEN 'ALL'
ELSE table.column3
END as column3 -
Merge can't accept a variable in the select clause?
oracle 10.2
I have a stored procedure.
I have a variable, vseq, which I set a sequence variable. With all other sql statements I can do
insert into table a
select vseq
from dual;
Apparently a merge can't handle variables in the select clause. I get an error. I can get it to work when I hard code a value.
this is ridiculous...merge can't handle variables in the select clauseCare to prove?
sql> DECLARE
2 v_first_name varchar2(20) := 'BOSS';
3 BEGIN
4 MERGE INTO sun_employees se
5 USING (SELECT * FROM employees WHERE department_id = 20) e
6 ON (e.employee_id = se.employee_id)
7 WHEN MATCHED THEN
8 UPDATE SET salary = e.salary
9 WHEN NOT MATCHED THEN
10 INSERT(employee_id, first_name, last_name, department_id)
11 VALUES (e.employee_id, v_first_name, e.last_name, e.department_id);
12 END;
13 /
PL/SQL procedure successfully completed.
sql> select first_name from sun_employees;
FIRST_NAME
BOSS
BOSS -
Using @Prompt in the SELECT clause (?)
Post Author: faltinowski
CA Forum: Semantic Layer and Data Connectivity
Product: Business Objects
Version: 6.5 SP3
Patches Applied: MHF11 and CHF48
Operating System(s): Windows
Database(s): Oracle
Error Messages: "Parse failed: Exception: DBD, ORA-00903 invalid table name State N/A"
Hi! I'm bewildered -- we have an object that parses but when I try to reproduce this object, it does not.
We have a universe that's been in production for several years using an object developed by another designer who's no longer with the company. This object is a dimension, datatype is character, and there's no LOV associated. The SELECT statement in this object is
decode(@Prompt('Select Snapshot Month','A','Object Definitions\CY Month Snapshot',MONO,CONSTRAINED),'00-Previous Month',to_number(to_char(add_months(sysdate,-1),'MM')),'01-Current Month',to_number(to_char(add_months(sysdate,0),'MM')),'01-January','1','02-February','2','03-March','3','04-April','4','05-May','5','06-June','6','07-July','7','08-August','8','09-September','9','10-October','10','11-November','11','12-December','12')
This object parses. The client uses the object in the select clause to capture the "month of interest" for the report. So the report may be for the entire year's data which is graphed to show trends, but there's a table below the graph which is filtered to show just the month of interest. Typically they use the value "00-Previous Month" so they can schedule the report and it will always show the last month's data.
Problem
The original object parses.
If I copy the object within the same universe, it parses.
If I copy the code into a new object in the same universe, it doesn't parse
If I copy the code into a new object in a different universe, it doesn't parse
If I copy the object to a different universe, then edit the LOV reference, it doesn't parse
If I create any new object having @Prompt in the SELECT statement, it doesn't parse.
If another designer tries - they get the same thing.
What am I missing? Obviously someone was able to create this successfully.
On the brighter side
The object I created in a new universe (which doesn't parse in the universe) seems to work fine in the report.Seems that, the prompt syntax is correct.
But the condition is not correct.
You are taking the prompt value and not doing anything. That could be one issue for this error.
I believe that, you just want to capture the prompt value use it in report level and do not want to apply as a filter.
So, use the condition as follows.
@Prompt('Select Grouping','A',{'A','B','C'},mono,constrained) = @Prompt('Select Grouping','A',{'A','B','C'},mono,constrained)
Hope this helps! -
How to append new field in select clause of dynamic VO through CO
I have dynamic VO "FaoWorkPerObjPerfRatingsVO" in controlloer below:
public class FaoWorkApprObjectivesCO extends ApprObjectivesCO
public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
super.processRequest(oapagecontext, oawebbean);
OAApplicationModule oam = oapagecontext.getApplicationModule(oawebbean);
oracle.apps.fnd.framework.server.OADBTransaction oadbtransaction = oam.getOADBTransaction();
OAViewObject oav = (OAViewObject)oam.findViewObject("FaoWorkPerObjPerfRatingsVO");
if(oav != null)
System.out.println("FAO Found VO PerObjPerfRatingsVO for ObjectivesAM. This means we have re-entered the page");
} else
oav = (OAViewObject)oam.createViewObject("FaoWorkPerObjPerfRatingsVO", "oracle.apps.per.selfservice.objectives.server.PerObjPerfRatingsVO");
How can I append 2 new fields are MULTIRATERS_AVERAGE and COUNT_MULTIRATERS as statement below in select clause of dynamic VO above (FaoWorkPerObjPerfRatingsVO)
fao_pems_utility.AVG_STEP_VALUE(fao_pems_utility.GET_APPRAISAL_ID(PCE.ASSESSMENT_ID),
'MULTIRATER',
Null,
PCE.COMPETENCE_ID) MULTIRATERS_AVERAGE,
fao_pems_utility.COUNT_RATINGS(Null,
Null,
fao_pems_utility.GET_APPRAISAL_ID(PCE.ASSESSMENT_ID),
PCE.COMPETENCE_ID,
Null,
'MULTIRATER',
Null) || ' out of ' ||
(fao_pems_utility.HOW_MANY_RATING(fao_pems_utility.GET_APPRAISAL_ID(PCE.ASSESSMENT_ID),
'GROUPAPPRAISER') +
fao_pems_utility.HOW_MANY_RATING(fao_pems_utility.GET_APPRAISAL_ID(PCE.ASSESSMENT_ID),
'REVIEWER')) COUNT_MULTIRATERS
Thank you very much.Hi
My VO is VO Extension below. In the seeded VO (oracle.apps.per.selfservice.objectives.server.PerObjPerfRatingsVO) doesn't include 2 fields that I want to add in VO.
oav = (OAViewObject)oam.createViewObject("FaoWorkPerObjPerfRatingsVO", "oracle.apps.per.selfservice.objectives.server.PerObjPerfRatingsVO");
Could you please provide me the coding to append 2 new fields in VO Extension approach. I would like to append them in select clause.
Thank you. -
Using a select clause in the column formula in an Analysis
Hi all,
Is there a function or syntax that I can use to simulate a "SELECT" clause in the column formula of an Analysis? What I am trying to achieve is displaying a measure from a specific fact record into the current record. For example, if the current record displays "Region","position", and "salary", I would like to add an additional column called "compared to" in which I can display the "salary" measure from another specific fact record whose attributes I know.
Is there a function/statement that I can use to achieve this?
ThanksHi,
U can't do it in Edit formula column..it's possible below one
Add SQL filter in that column then follow blow steps
Convert this filter to SQL
i.e : add more option to sql here u can write SQL query in that column
Thanks
Deva -
How to use a function in select clause
hi gems...good evening...
I want to write a select clause from a function. The scenario is like below:
function parameters
CREATE OR REPLACE FUNCTION FUNCTION_DEMO(p_pid IN NUMBER,
p_bankerNum IN NUMBER,
p_banker_name IN VARCHAR2,
p_business_num IN NUMBER,
p_businesses IN table_typ_businesses)
return table_typ_bankers
as .......
global object and table types
CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER);
CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses;
CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,0));
CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers;
The select query
select * from
table(cast(FUNCTION_DEMO(1,
2,
'ALEX',
2,
table(cast(select businesses_id from reference_businesses) as table_typ_businesses) as table_typ_bankers)But it is giving error with Missing expression.
My function is compiled successfully. I just want to make the select query to view the output given by the function i.e the table type "table_typ_bankers".
Please help...thanks in advance..Hi ,
You can check this and change your code by taking this as an example. I just noted down with simple one input and return as collection type
and how to use/call it in select statement.
SQL> CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER)
2 /
Type created.
SQL> CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses
2 /
Type created.
SQL> CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,2))
2 /
Type created.
SQL> CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers
2 /
Type created.
/* Now creating a demo function and just focusing on your one input as collection type */
SQL> create or replace function f11 ( tab_rec IN table_typ_businesses)
2 return table_typ_bankers
3 is
4 t_val table_typ_bankers:= table_typ_bankers();
5 begin
6 dbms_output.put_line('tab_rec count -'||tab_rec.count);
7
8 for i in 1..tab_rec.count
9 loop
10 dbms_output.put_line ('tab_rec value ('||i||')'||tab_rec(i).businesses);
11 t_val.EXTEND;
12 t_val(i) := obj_typ_bankers(tab_rec(i).businesses * 12.50);
13 end loop;
14 return t_val;
15 end;
16 /
Function created.
/* To run your function by a select statement */
SQL> SELECT * FROM TABLE(f11(table_typ_businesses(obj_typ_businesses(5),
2 obj_typ_businesses(12),
3 obj_typ_businesses(18))
4 ) )
5 /
BANKER_NUM
62.5
150
225
tab_rec count -3
tab_rec value (1)5
tab_rec value (2)12
tab_rec value (3)18Hope this will help you... :)
Thanks!
Ashutosh -
How to remove column name in select clause
Hello Guys,
I just want to remove a column name in select clause. Because, I don't want to write all column names. I hope I express myself.
In other words, I want the following.
Select * - unwanted_column from table;
instead of this
Select col1, col2, col3, col4, ........ col 10000 from table;Hi,
Sorry, there's nothing in SQL that means "all columns *except* ...". As the others have said, the only way to get those results in SQL is to list all the columns you do want.
Your front end may have some feature that allows you to hide a specific column. For example, in SQL*Plus, you can use <tt> COLUMN ... NOPRINT </tt> , like this:
COLUMN dname NOPRINT
SELECT *
FROM scott.dept
ORDER BY dname
;Output:
` DEPTNO LOC
10 NEW YORK
40 BOSTON
20 DALLAS
30 CHICAGOThere is a column called dname in the scott.dept table; the query above actually uses it. But, because of the COLUMN command, SQL*Plus won't display that column.
Edited by: Frank Kulash on Feb 26, 2013 10:10 AM
Changed scott.dept example. -
Maximum no. of columns allowed in SELECT clause - Urgent please
Hi,
I am constructing SQL query dynamically in a stored proc. based on user inputs. I am getting following error when I have around 400 columns in my SELECT clause. FROM, WHERE, GROUP BY clauses are same eventhough I have 30 columns and I don't have any problems here. Can anyone please let me know what is maximum no. of columns allowed in a query. I am working on Oracle 9i Release2.
Thanks in advance.ORA-01467 sort key too longIt's not the SELECT clause that causes this, it's most likely the GROUP BY clause. Basically, the columns in the GROUP BY clause have to fit comfortably within a single database block. Does that sound like it might be a problem with your query?
Cheers, APC
Message was edited by:
APC -
Hi,
I need to have a dynamic selsction of fields in a select query.
I am using the same trick used in the where clause for te SELECT clause as follows:
concatenate 'RBUKRS' 'RACCT' 'RZZRCNTR' v_field
into v_sel separated by space
. select (v_sel)
from zgroupt
into table i_zgroupt
where racct eq s_hkont..
But this doesnt work.
I have a requirement to fetch certain fields based on some conditions. How do i achieve it ?
Regards,
StockHi,
Here is the dynamic where clause example code
PARAMETERS: carr_id TYPE spfli-carrid,
conn_id TYPE spfli-connid.
DATA: where_clause TYPE STRING,
and(4),
wa_spfli TYPE spfli.
IF carr_id IS NOT INITIAL.
CONCATENATE 'CARRID = ''' carr_id '''' INTO where_clause.
and = ' AND'.
ENDIF.
IF conn_id IS NOT INITIAL.
CONCATENATE where_clause and ' CONNID = ''' conn_id ''''
INTO where_clause.
ENDIF.
SELECT * FROM spfli INTO wa_spfli WHERE (where_clause).
WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom,
wa_spfli-cityto, wa_spfli-deptime.
ENDSELECT.
Regards
Sudheer -
Hi all
I have a small question regarding the SELECT clause syntax.
In my CEP application I'm processing events which hold several properties, mostly primitives, but a few of type java.awt.Point.
I can select the Point object itself in the SELECT clause, but I don't know how to reference the x / y properties of the Point object.
e.g -
SELECT int1, int2, string1, string2, point1 - works fine.
SELECT int1, int2, string1, string2, point1.x - query won't get parsed.
I did manage to access the x / y properties using a custom java method that gets the Point object and returns the x / y properties.
Can I reference the x / y properties directly in the CQL query?
Thanks,
Roy
Edited by: user8868221 on Feb 17, 2010 10:59 AMHi,
What you are doing is correct. CQL currently only supports a small set of built-in types, so if your event contains a property of a type like Point, then you need to use a user-defined function to access and manipulate that property. This is discussed in the CQL documentation:
2.2.2 Handling Other Datatypes Using a User-Defined Function
Support for Java types and custom user-defined classes is coming in a future release.
Hope that helps.
Seth -
Select clause with where part is needs 600 times longer to complete
Hello.
I have two select clauses one with where, which needs 120 seconds to complete and one without where, which completes in 0,3 seconds. I want to know why is that.
120 seconds
SELECT B.* FROM
(SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B WHERE B.ALLOWED = '1' ORDER BY OLOG;0,3 seconds
SELECT B.* FROM
(SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B ORDER BY OLOG;Table FLOG has arround 270000 records, but only 40 of them are distinct.
IsProtocolAllowed checks if user has a permision to view the record.
Thank you for your help.
Regards,
Borut Ojcinger
Edited by: 993896 on 14.3.2013 7:24Hi,
welcome to the forum.
Please read SQL and PL/SQL FAQ
If you have a performance issue have a look at SQL and PL/SQL FAQ
Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
Regards.
Al
Maybe you are looking for
-
Hello can someine help before i throw this 5s in the trash please? I have the iphone 5s. I cannot get the playlists from my computer to sync to iphone5s but it works just fine with my 4s. I have done everything, it has even deleted my playlists that
-
I'm getting about 15k rows from an Access 2003 database using the jdbc odbc driver but when I iterate over my resultset, it's taking about 40 seconds (although spikes to almost 2 minutes in some cases). I'm just wondering if this is a reasonable numb
-
How to lock html page in stagewebview
Hi guys, I want to remove scrolling/panning behavior with the stagewebview. Approaches already used but didnt work for me: 1. Tried listening to TransformGestureEvent for pan and swipe, but unable to receive these events on stagewebview. 2. Tried tou
-
This is not an iphone specific issue as it happens on my iPad as well. If I send an email that does not contain a subject, once the person replies to me and I reply back, the subject is now "Re: RE:" This does not happen using mail on Android devices
-
i am new to mac, difficulty using this system. How do I create aa mailing list, or do i need to purchase more software. T have a imac all in one. Tom