PL/SQL Max character
Hi All,
What is the maximum length that can be stored in a variable for executing a query.
var := 'SELECT * FROM TAB WHERE A='CLKJDJFAJDJFLA' AND B='DFLKAJSFJSKLAFJL'
UNION ALL
SELECT * FROM TAB WHERE A='CLKJDJFAJDJFLA' AND B='DFLKAJSFJSKLAFJL
UNION ALL
SELECT * FROM TAB WHERE A='CLKJDJFAJDJFLA' AND B='DFLKAJSFJSKLAFJL
UNION ALL
SELECT * FROM TAB WHERE A='CLKJDJFAJDJFLA' AND B='DFLKAJSFJSKLAFJL
execute query using var.
Thanks & Regards,
CDPrasad
cdprasad wrote:
Hi all,
As suggested
I'm trying to run a SQL query in PL/SQL which is of lenght more than 32000 bytes.
Since execute immediate cannot execute CLOB datatype,It can in 11g r2 onwards.
Im divinding the strings into multiple pieces and trying to store in a varchar2(32000) datatype.
Then I'l append these variables in execute immediate statement. I donno whether it will work or not.Right sort of idea (for 10g), but not with execute immediate. You have to use DBMS_SQL package instead and split it into 256 character chunks for the DBMS_SQL.VARCHAR2S array structure...
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_large_sql CLOB;
3 v_num NUMBER := 0;
4 v_upperbound NUMBER;
5 v_sql DBMS_SQL.VARCHAR2S;
6 v_cur INTEGER;
7 v_ret NUMBER;
8 begin
9 -- Build a very large SQL statement in the CLOB
10 LOOP
11 IF v_num = 0 THEN
12 v_large_sql := 'CREATE VIEW vw_tmp AS SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
13 ELSE
14 v_large_sql := v_large_sql || ' UNION ALL SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
15 END IF;
16 v_num := v_num + 1;
17 EXIT WHEN DBMS_LOB.GETLENGTH(v_large_sql) > 40000 OR v_num > 800;
18 END LOOP;
19 DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_large_sql));
20 DBMS_OUTPUT.PUT_LINE('Num:'||v_num);
21 --
22 -- Now split that large SQL statement into chunks of 256 characters and put in VARCHAR2S array
23 v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_large_sql)/256);
24 FOR i IN 1..v_upperbound
25 LOOP
26 v_sql(i) := DBMS_LOB.SUBSTR(v_large_sql
27 ,256 -- amount
28 ,((i-1)*256)+1 -- offset
29 );
30 END LOOP;
31 --
32 -- Now parse and execute the SQL statement
33 v_cur := DBMS_SQL.OPEN_CURSOR;
34 DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
35 v_ret := DBMS_SQL.EXECUTE(v_cur);
36 DBMS_OUTPUT.PUT_LINE('View Created');
37* end;
SQL> /
Length:40015
Num:548
View Created
PL/SQL procedure successfully completed.
SQL> select count(*) from vw_tmp;
COUNT(*)
548
SQL> select * from vw_tmp where rownum <= 10;
COL1
The number of this row is : 0000000
The number of this row is : 0000001
The number of this row is : 0000002
The number of this row is : 0000003
The number of this row is : 0000004
The number of this row is : 0000005
The number of this row is : 0000006
The number of this row is : 0000007
The number of this row is : 0000008
The number of this row is : 0000009
10 rows selected.
SQL>
Similar Messages
-
Improve built in SQL MAX function
Hi
I am trying to improve the performance of the built in SQL max function. right now searching through over 500,000 rows takes lot of time which can be reduced. Can anyone suggest me something which would be helpful in this or may be give me a link if it has been discussed before?
Anything is appreciated.
ThanksTolls wrote:
Um...considering you were planning on improving on the MAX function, I sort of thought you might actually know how to use it. Otherwise how would you know it was running slowly?thanks Tolls i'd figured it out right after i posted it. i guess i was too excited after reading (you got it in milliseconds) that posted right away without doing anything myself..but yeah it did make it super fast..thanks a lot for your help and time..
cotton.m wrote:
d_khakh wrote:
hi tolls thanks for getting back
could u explain how did u do that? i found out how to create index..i have the following statement:
create index col on table2 (col2);
cud u tell me how to go from here and find the max in col2..thanks again for ur help?
sigh
Where to go from here? Just execute your damn query. If you really did create the index on the right column and your database isn't stupid and there isn't a lot more to this problem then you told us about like some where clauses then that's it. She's as fast as she's going to get.
And remember, it's impolite to converse in a public forum while chewing your cud. Unless of course you actually meant "could" but were just too lazy to type it. Don't be lazy, use full words. Thanks.like i said above..i figured it out after some time.
i wasn't being lazy ..thats msn talk..i thought people understood that..anyways your point noted too. -
I need to use query-database functionality in transform activity to make a stored function call. My sql query parameter should be
Select CDMB_BPEL_UTILS_PKG.get_coa(null) from dual
Corresponding XML is
?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc" exclude-result-prefixes="xsl ns0 xsd ldap xp20 bpws ora orcl">
<xsl:template match="/">
<ns0:OracleRoot>
<ns0:OracleMappedOut>
<ns0:ExpType>
<xsl:value-of select="orcl:query-database('select cdmb_bpel_utils_pkg.get_coa(null) from dual',false(),false(),'eis/JNDI/GDB2')"/>
</ns0:ExpType>
</ns0:OracleMappedOut>
=========But I get the following error when testing the same===========
oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name
========================================================
I guess I need to use escape characters to pass ( . I tried using " and ' but in vain. Any help is appreciated to resolve this issue.Siva,
version: 10.1.3.4
Your inputs may be of high use for me as well.
I have similar requirement. I have to execute the following sql query
select sum(salary) from emp. When I run this query using ora:orcl:query-database, I got the same exception what you have got. So do you mean if i use an alias for this, it would solve my pbm?
select sum(salary) sal from emp+
rgds,
sen -
Hi,
I am trying to load data created on IBM OS/390 into Oralce on Solaris using SQL*LOADER CHARACTER SET option. I am currently using the character set WE8EBCDIC500 and everything is working fine except that '!' are being converted to ']'. I am wondering if I am using the right character set or not. Any help is appreciated.
thanks!MY character set from database is
PARAMETER VALUE
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16
My oracle is under linux and version is 11g R2
I am running loader from windows xp. -
Max Character File Size Limit exceeded.The document is too large to process
Hi
I have made set on section on products in report.
the Reports contains around 50 products when im opening the report
in draft mode the following error is displayed
"Max Character File Size Limit exceeded.The document is too large to be proceesed by the server .Contact your business Objects Administrator."
can some body help me out how to increase my report character file sizeHi,
If you are using Business Objects XIR2, there is a performance parameter in the Web_Intelligence Report Server where you can increase the size of that file. The parameter is Maximun Character File Size. Go to the CMC>Server>server.Web_IntelligenceReportServer in the Properties tab you will see it.
Cheers,
Luigi -
Max Character Length for Text Variables
Hi folks,
Quick question:
Does OPA have a max character length for text variables?
-IsamuObviously common sense prevails here. The system is unlikely to perform very well if you start passing around MBs of data in text variables!
-
SQL Buffer character limit too small.
I am attempting to execute an .SQL script file using the SQLPlus.exe command line. The script is a simple INSERT statement and executes fine as long as the text being inserted is english. But when the text is translated to either Traditional or Simplified Chinese the script generates the following error:
SP2-0341: line overflow during variable substitution (>3000 characters at line 2)
Some background information:
1. The database was created with the National Character Set of AL16UTF16 and the Database Character Set of AL32UTF8.
2. The data types for the columns being populated are NVARCHAR2 and NCLOB.
3. SQLPlus command line syntax: SQLPLUS.EXE -MARKUP "HTML ON SPOOL ON" UID/PWD@DBNAME @CREATE-5-CHINESE1.sql > CREATE-5-CHINESE1.HTML
4. Environment variable setting: NLS_LANG=.UTF8
5. Contents of CREATE-5-CHINESE1.SQL:
WHENEVER SQLERROR EXIT SQL.SQLCODE
SET DEFINE OFF
SET ECHO ON;
SET ESCAPE ON;
CLEAR BUFFER
INSERT INTO tbl_lm_notification_nls (col_id_notification, col_id_language, col_name_notification, col_subject, col_text) VALUES (1001, 5, '默认测评者邀请', '%s - 你被选择参与', '你已经被选择参加360度反馈调查,本调查使用一种称为 xxxxxxxxxxxxxxxxx(R) 的网络反馈工具来收集对人们的强项和发展需要的观察信息。 \
你要完成的调查将要求你对自己在一些与工作相关的技能、行为和知识等方面进行评估。 你还将邀请与你的工作有关的人们完成调查。 这些测评者可以包括你的经理、同级人员、直接下属、客户及其他人。 评估信息的质量和准确性要依赖于你和你的测评者们诚实地提供反馈。\
A提交调查答案之后,xxxxxxxxxxxxxxxxx 将计算结果并产生报告。 报告将把你的自我看法与测评者对你的看法相比较。 这个比较可以指出先前未知的强项和发展需要,还将协助确认你和他人有一致看法的领域。\
报告中的信息将协助你回答两个重要问题:\
o 你最强的地方是什么?\
o 你最需要发展的地方是什么?\
了解你的强项和发展需要将协助你和你的组织识别适当的发展活动和你的未来成长计划。\
COMMIT;
EXIT SQL.SQLCODE;
6. Contents of CREATE-5-CHINESE.HTML (command output):
SQL*Plus: Release 10.1.0.2.0 - Production on Wed Oct 19 11:02:58 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options
SQL> SET ESCAPE ON;
SQL> /
SP2-0103: Nothing in SQL buffer to run.
SQL> CLEAR BUFFER
SQL> INSERT INTO tbl_lm_notification_nls (col_id_notification, col_id_language, col_name_notification, col_subject, col_text) VALUES (1001, 5, '默认测评者邀请', '%s - 你被选择参与', '你已经被选择参加360度反馈调查,本调查使用一种称为 xxxxxxxxxxxxxxxxx(R) 的网络反馈工具来收集对人们的强项和发展需要的观察信息。 \
2 \
3 你要完成的调查将要求你对自己在一些与工作相关的技能、行为和知识等方面进行评估。 你还将邀请与你的工作有关的人们完成调查。 这些测评者可以包括你的经理、同级人员、直接下属、客户及其他人。 评估信息的质量和准确性要依赖于你和你的测评者们诚实地提供反馈。\
4 \
5 A提交调查答案之后,xxxxxxxxxxxxxxxxx 将计算结果并产生报告。 报告将把你的自我看法与测评者对你的看法相比较。 这个比较可以指出先前未知的强项和发展需要,还将协助确认你和他人有一致看法的领域。\
6 \
7 报告中的信息将协助你回答两个重要问题:\
8 \
9 o 你最强的地方是什么?\
10 o 你最需要发展的地方是什么?\
11 \
12 了解你的强项和发展需要将协助你和你的组织识别适当的发展活动和你的未来成长计划。\
13 \
14 ');
SP2-0341: line overflow during variable substitution (>3000 characters at line 2)
SQL> /
SP2-0341: line overflow during variable substitution (>3000 characters at line 2)
SQL> COMMIT;
Commit complete.
SQL> EXIT SQL.SQLCODE;
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options
I believe that increasing the size of SQL Buffer may fix the problem, but I am unsure of how to do this or if it is even possible.
Thanks in advance for any information that you can provide.
Mike Z.I'm not suggesting this is your problem, but
select status
into v_status,
from registration_offender_xref But you have declared
v_status varchar2(10);Much better to declare things like this
v_status registration_offender_xref.status%type;That way you know your variable is declared with a proper length, if the column length ever changes ... your code doesn't go kaboom.
Cheers, -
Sql injection character fields
Is it true that with MSSQL in the background, character fields can't be used for sql injection?
A) One source says that in MSSQL single quotes are escaped into double quotes.
B) Another source says that " SQL injection (within ColdFusion apps) is really only an issue with non textual fields. If a text value is tampered with you'll end up with tampered text, but that text will all be part of the core string (within quotes) passed as a value, and will therefore not be executed as separate statements. Numbers, on the other hand, are not enclosed within quotes, and so extraneous text can be tampered "
Questions about A): How does escaping 's with "s help, by making string literals in MSSQL not valid?
How could A) above be true when names like O'Mally are being stored with a single quote ?
Questions about B) Does it mean code like DELETE * FROM atable would just be stored as a string and not execute ?
If so, is that accurate ?To actually answer your question's.
A) A single quote in SQL is a comment. To store a single quote as DATA one has to escape it by doubling it. So to store O'Mally it would be passed as o''Mally.
The simple SQL injection attack is to end a number value with a random value, that is followed with a ; to end the SQL statment and then another statement can be run, this is then followed by a single quote to comment out any other SQL in the original statement. ColdFusion automatically escapes single quotes in text fields in most situations, so this is harder to do with text fields, but not impossible. -
SQL MAX QUERY / SQL COUNT QUERY
Hi all,
i would like to get the value of the number of rows i have, but i dun seem to work it out with the getRow statements. i think the syntax of my statement is ok, but maybe i am doing the wrong way to get the value out.
I tried with COUNT, and it gives me the same error.
The error is: java.sql.SQLException: Column not found
This is the part of my code
Connection con;
String Q;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:RFID Logistics");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT MAX(Queue) FROM Forklift1");
while(rs.next())
Q = rs.getString("Queue");
System.out.println(Q);
catch(ClassNotFoundException f)
f.printStackTrace();
catch(SQLException f)
f.printStackTrace();
Thx alot in advance =)Please use code tags when posting code. There is a code button above the message editor that inserts the tags.
Do you want to get the number of rows? If soConnection con;
int num = 0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:RFID Logistics");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM Forklift1");
while(rs.next())
num = rs.getInt(1);
System.out.println(num );
rs.close();
stmt.close();
catch(ClassNotFoundException f)
f.printStackTrace();
catch(SQLException f)
f.printStackTrace();
}This is untested, but should be close enough. -
In a table I have a field "Ticket No.". I am using Ticket No in a format like:
00021-10-06-0201
The first set (left side) represents Ticket No. Then month, year, and code.
Each time when a user wants to enter new record a new ID is generated as:
"Select max(Left(TicketID,5)) from Ticket".
The new id becomes result+1.
I want to know that the above field is a string. But when I use LEFT
function, as above, it successfully returns max of the first set. Does
it automatically converts it to Long integer?
If not, how to use it securely so that first the left set is converted
to Long Integer and then the MAX is found. All in SQL query.I want to know whether your "substr(00021...)
approach and in my example, does max function
automatically converts it to a numeric type.I did not use MAX in my example, but still it is converting to numeric depending on the operator you are using. Elaborating....see below..
SQL> select substr('00021-10-06-0021',1,5)+1 from dual;
SUBSTR('00021-10-06-0021',1,5)+1
22
SQL> select substr('A0021-10-06-0021',1,5)+1 from dual;
select substr('A0021-10-06-0021',1,5)+1 from dual
ERROR at line 1:
ORA-01722: invalid number
SQL> select substr('A0021-10-06-0021',1,5)||'A' from dual;
SUBSTR
A0021ASee the above 1st and 3rd query, the behaviour is completely based on the operators. -
How to specify SQL escape character
The percent (%) and underscore (_) character have special meaning in SQL,
and I want to escape these so users cannot type them in and effect the
queries. The database is DB2, which does not have a default escape
character, but one can be specified in an "escape" clause, like this:
select * from customer where name like 'ERIC\%' escape '\'
This query will look for a row where the name is literally equal to
'ERIC%'. This brings me to my question:
How do I specify to Kodo that it adds the "escape" clause to the end of
the SQL?
Thanks,
EricHow do I specify to Kodo that it adds the "escape" clause to the end of
the SQL?Unfortunately there is no easy way to do this. The only way I can think of off
the top of my head is to create a subclass of the appropriate DBDictionary for
your database (see src/kodo/jdbc/sql/) and override the DBDictinoary's
toSelect(SQLBuffer, SQLBuffer...) method to add the escape clause. You can then
plug your custom dictionary into kodo:
kodo.jdbc.DBDictionary: your.custom.class.Name -
Hello
I have a table with name,startdate,enddate and I would like to know for today what was the max Simultaneous calls there were.
ex
Danny,'14-JUL-2008 14:35:21','14-JUL-2008 14:35:29'
Danny,'14-JUL-2008 14:35:22','14-JUL-2008 14:35:23'
Danny,'14-JUL-2008 14:35:20','14-JUL-2008 14:35:28'Based on test data from Isotope, maybe that can give you some ideas:
SQL> with t as (
2 select 'Danny' as name,
3 to_date('14-JUL-2008 11:35:21','DD-MON-YYYY HH24:MI:SS') as start_date,
4 to_date('14-JUL-2008 11:35:25','DD-MON-YYYY HH24:MI:SS') as end_date
5 from dual union all
6 select 'Danny' as name,
7 to_date('14-JUL-2008 11:35:22','DD-MON-YYYY HH24:MI:SS'),
8 to_date('14-JUL-2008 11:35:23','DD-MON-YYYY HH24:MI:SS')
9 from dual union all
10 select 'Danny' as name,
11 to_date('14-JUL-2008 11:35:26','DD-MON-YYYY HH24:MI:SS'),
12 to_date('14-JUL-2008 11:35:29','DD-MON-YYYY HH24:MI:SS')
13 from dual union all
14 select 'Danny' as name,
15 to_date('14-JUL-2008 11:35:28','DD-MON-YYYY HH24:MI:SS'),
16 to_date('14-JUL-2008 11:35:37','DD-MON-YYYY HH24:MI:SS')
17 from dual union all
18 select 'Danny' as name,
19 to_date('14-JUL-2008 14:35:21','DD-MON-YYYY HH24:MI:SS') ,
20 to_date('14-JUL-2008 14:35:29','DD-MON-YYYY HH24:MI:SS')
21 from dual union all
22 select 'Danny' as name,
23 to_date('14-JUL-2008 14:35:22','DD-MON-YYYY HH24:MI:SS'),
24 to_date('14-JUL-2008 14:35:23','DD-MON-YYYY HH24:MI:SS')
25 from dual union all
26 select 'Danny' as name,
27 to_date('14-JUL-2008 14:35:20','DD-MON-YYYY HH24:MI:SS'),
28 to_date('14-JUL-2008 14:35:28','DD-MON-YYYY HH24:MI:SS')
29 from dual)
30 -- End of test data
31 select max(count(*))
32 from (select name,
33 start_date,
34 end_date,
35 sum(interval_change) over(partition by name order by end_date, start_date) interval_no
36 from (select name,
37 start_date,
38 end_date,
39 case
40 when (lag(end_date)
41 over(partition by name order by end_date,
42 start_date) - start_date) > 0 then
43 0
44 else
45 1
46 end interval_change
47 from t))
48 group by name, interval_no
49 ;
MAX(COUNT(*))
3You can as well search this forum for term overlap to see another approaches.
Best regards
Maxim -
How to increase the max character for a table name..!!
Hi All,
The maximum characters that supports for the table Name is 30
How can I increase this so that I can have table names lengthier than 30
This is required as I was doing a conversion of the database from SQL server 2005 to Oracle 9i
Many thanks in advance...
Best Regards..,So How can I make it possible..?!!If it not possible, you cannot make it possible.
If you can create a synonym on more than 30 char., you cannot use it on more than 30 char :
SQL> create synonym my_very_long_synonym_name_for_emp_table for emp;
Synonym created.
SQL> select count(*) from my_very_long_synonym_name_for_emp_table;
select count(*) from my_very_long_synonym_name_for_emp_table
ERROR at line 1:
ORA-00972: identifier is too long
SQL> select * from user_synonyms;
SYNONYM_NAME TABLE_OWNER TABLE_NAME
DB_LINK
/91b591a7_MY_VERY_LONG_SYNONYM SCOTT EMP
SQL> select count(*) from "/91b591a7_MY_VERY_LONG_SYNONYM";
COUNT(*)
14Nicolas. -
Is there any max character length for index usage ?
deleting this thread..
Edited by: OraDBA02 on Oct 3, 2012 2:32 PMThis is a fairly well documented issue. (At least, I documented it a few years ago in "CBO Fundamentals").
Oracle only considers the first few bytes of a character string when calculating selectivity, so you can get all sorts of anomalous results.
You could start by reading a couple of notes I wrote some time ago - this might give you a few pointers for your particular case:
http://jonathanlewis.wordpress.com/2010/10/05/frequency-histogram-4/
http://jonathanlewis.wordpress.com/2010/10/13/frequency-histogram-5/
Regards
Jonathan Lewis -
Pl/sql - returning sql query
hello everyone...hope someone can help.
Worked a lot to solve this, but I can't find a solution.
DECLARE
lv_sql VARCHAR(32767);
lv_pivot_cols VARCHAR2(1000);
BEGIN
FOR i IN (SELECT DISTINCT comp_name, pro_name FROM cat_attributes order by comp_name)
LOOP
lv_pivot_cols := lv_pivot_cols ||'('||''''||i.comp_name||''''||','|| '''' || i.pro_name ||''''||')'||',';
END LOOP;
lv_pivot_cols := RTRIM(lv_pivot_cols,',');
lv_sql := 'SELECT * FROM
(SELECT position,cat_id, att_name as ATTRIBUTE, pro_name, value,comp_name
FROM cat_attributes )
PIVOT (
max (value)
FOR (comp_name,pro_name) IN (' ||lv_pivot_cols||')) where cat_id=:P1100_CHOOSE_CATEGORY order by position';
RETURN lv_sql;
--DBMS_OUTPUT.PUT_LINE(lv_sql);
END;the above code works well, but i want to add a where-condition in the distinct statement, which depends on an apex item.
like:
SELECT DISTINCT comp_name, pro_name FROM cat_attributes where cat_id=:P1100_CHOOSE_CATEGORY order by comp_name But if a add this condition a got
report error: ORA-01403: no data found
any suggestions????
also want to edit the column header max character size. now, there can be only *30* characters for column-header. is there a possibilty to raise this?
Thanks for all your suggestionsI get data In sql commands. If I run the statement in sql-commands window, a pop-up opens, where I have to enter any disired value of the item.
It's the item in where condition of the distinct statement
So I get all wisched values.
But in region source, it doesn't work.
I can't get data with an apex item.
works not:
DECLARE
lv_sql VARCHAR(32767);
lv_pivot_cols VARCHAR2(1000);
BEGIN
FOR i IN (SELECT DISTINCT comp_name, pro_name FROM cat_attributes where cat_id=:P1100_CHOOSE_CATEGORY order by comp_name)
LOOP
lv_pivot_cols := lv_pivot_cols ||'('||''''||i.comp_name||''''||','|| '''' || i.pro_name ||''''||')'||',';
END LOOP;
lv_pivot_cols := RTRIM(lv_pivot_cols,',');
lv_sql := 'SELECT * FROM
(SELECT position,cat_id, att_name as ATTRIBUTE, pro_name, value,comp_name
FROM cat_attributes )
PIVOT (
max (value)
FOR (comp_name,pro_name) IN (' ||lv_pivot_cols||')) where cat_id =:P1100_CHOOSE_CATEGORY order by position';
RETURN lv_sql;
--DBMS_OUTPUT.PUT_LINE(lv_sql);
END;works:
DECLARE
lv_sql VARCHAR(32767);
lv_pivot_cols VARCHAR2(1000);
BEGIN
FOR i IN (SELECT DISTINCT comp_name, pro_name FROM cat_attributes where cat_id=1 order by comp_name)
LOOP
lv_pivot_cols := lv_pivot_cols ||'('||''''||i.comp_name||''''||','|| '''' || i.pro_name ||''''||')'||',';
END LOOP;
lv_pivot_cols := RTRIM(lv_pivot_cols,',');
lv_sql := 'SELECT * FROM
(SELECT position,cat_id, att_name as ATTRIBUTE, pro_name, value,comp_name
FROM cat_attributes )
PIVOT (
max (value)
FOR (comp_name,pro_name) IN (' ||lv_pivot_cols||')) where cat_id =:P1100_CHOOSE_CATEGORY order by position';
RETURN lv_sql;
--DBMS_OUTPUT.PUT_LINE(lv_sql);
END;It isn't possible to reference the where-clause on apex-item
Edited by: Locke90210 on 30.04.2013 05:12
Maybe you are looking for
-
Every time I try to open iPhoto, it quits unexpectedly
I use a MacBook Pro OS X 10.8.5 I can't tell you what version of iPhoto I use, as it quits to quickly for me to double-check Please can someone help?! The first 50 lines of the Report to send to Apple are as follows: Process: iPhoto [735] Pat
-
No response returned for the http request
My application is running on Weblogic 10 in a clustered environment. The UI is a developed in Eclipse RCP. I have a problem where a particular request never returns from the server to the desktop. This can be reproduced only in Beta environment and d
-
I'm trying to stream music videos from imac to apple tv. If i drag music videos into a new playlist in itunes and go to the apple tv only videos from apple store show up in the playlist. My personal videos were encoded in mpeg-4 using "vuze" software
-
Table for User Name and User ID?
Hi Experts, I hv User ID, that Logs in. So, I waanna to pull the corresponding Name. So, Wher Can I find these data i.e. Which is the best Table/source? ThanQ.
-
HT4623 Starbucks app won't start on iphone5 OS6
On IPhone 5 my Starbucks app starts and then shuts down immediately. I have deleted and reinstalled. Turned phone on and off and rebooted phone. Any help would be appreciated