Query by Datatype

Is there a way that I can query all tables in a given database to return the table name and column name for all columns that are of type String?
For example:
table foo
id NUMBER(15)
name VARCHAR2(256)
age NUMBER(3)
desc VARCHAR2(512)
I'd want see the following results:
foo name
foo desc

1 select table_name, column_name
2 from dba_tab_columns
3* where data_type = 'VARCHAR2'
If you need, say VARCHAR2(40) only:
where data_type = 'VARCHAR2' and data_length='40'
To see what other dictionary views are available:
select *
from dictionary
order by table_name;

Similar Messages

  • QUERYING CLOB DATATYPE

    Hello Everyone,
    Before I go to my question let me give you the context. I wanted to upload the description of a set of products with their IDs into my database. Hence I created a table 'demo' with two columns of INT and CLOB datatypes using the following script. *create table demo ( id int primary key, theclob Clob );*
    Then I create a directory using the following script, *Create Or Replace Directory MY_FILES as 'C:\path of the folder.......\';*
    In the above mentioned directory I create one .txt file for each product with the description of the product. Using the below script I created a procedure to load the contents of the .txt files into my 'demo' table.
    *CREATE OR REPLACE*
    *PROCEDURE LOAD_A_FILE( P_ID IN NUMBER, P_FILENAME IN VARCHAR2 ) AS*
    *L_CLOB CLOB;*
    *L_BFILE BFILE;*
    *BEGIN*
    *INSERT INTO DEMO VALUES ( P_ID, EMPTY_CLOB() )*
    *RETURNING THECLOB INTO L_CLOB;*
    *L_BFILE := BFILENAME( 'MY_FILES', P_FILENAME );*
    *DBMS_LOB.FILEOPEN( L_BFILE );*
    *DBMS_LOB.LOADFROMFILE( L_CLOB, L_BFILE,*
    *DBMS_LOB.GETLENGTH( L_BFILE ) );*
    *DBMS_LOB.FILECLOSE( L_BFILE );*
    *END;*
    After which I called the procedure using, *exec load_a_file(1, 'filename.txt' );*
    When I queried the table like, select * from demo; I am getting the following output..... which is all fine.
    ID THECLOB
    1 "product x is an excellent way to improve your production process and enhance your turnaround time....."
    _*QUESTION*_
    When I did the exact same thing in my friend's machine and query the demo table, I get garbage value in the 'theclob' column (as shown below). The only difference is that mine is an enterprise edition of Oracle 11.2.0.1 and my friends is an Express edition of Oracle 11.2.0.2. Does this has anything to do with the problem?
    1 ⁦     猺⁁摶慮捥搠摡瑡潬汥捴楯渠捡灡扩汩瑩敳㨠扡牣潤攠獣慮湩湧Ⱐ灡湩挠慬敲琬⁷潲欠潲摥爠浡湡来浥湴Ⱐ睩牥汥獳⁦潲浳湤⁳異敲癩獯爠瑩浥⁥湴特⸊੃潭整⁍潢楬攠坯牫敲㨠周攠浯獴⁲潢畳琠灡捫慧攮⁐牯癩摥猠扵獩湥獳敳⁷楴栠愠捯浰汥瑥汹⁷楲敬敳猠潰敲慴楯湡氠浡湡来浥湴⁳祳瑥洮⁉湣汵摥猠慬氠潦⁃潭整⁔牡捫敲❳⁦敡瑵牥猠灬畳㨠䍡汥湤慲猬畴潭慴敤畳瑯浥爠捯浭畮楣慴楯湳Ⱐ睯牫牤敲⽩湶潩捥⁵灤慴楮朠晲潭⁴桥⁦楥汤Ⱐ睯牫牤敲⁳敱略湣楮本⁥硣敳獩癥⁳瑯瀠瑩浥汥牴猬⁷楲敬敳猠景牭猬⁴畲渭批⵴畲渠癯楣攠湡癩条瑩潮Ⱐ慮搠浯牥⸊ੁ摶慮捥搠坩
    2     ≁否吠潦晥牳摶慮捥搠睩牥汥獳⁦潲浳慰慢楬楴礠睩瑨⁃潭整⁅娠䍯浥琬⁔牡捫敲湤⁃潭整⁍潢楬攠坯牫敲ਊ䍯浥琠䕚㨠周攠浯獴⁲潢畳琬潳琠敦晥捴楶攠睥戠扡獥搠䵒䴠慰灬楣慴楯渠楮⁴桥⁩湤畳瑲礮⁃慰慢楬楴楥猠楮捬畤攠䝐匠汯捡瑩潮⁴牡捫楮本⁷楲敬敳猠瑩浥汯捫Ⱐ来漭晥湣楮朠睩瑨汥牴猬⁳灥敤湤⁳瑯瀠瑩浥汥牴猬湤渭摥浡湤爠獣桥摵汥搠牥灯牴楮朮ਊ䍯浥琠呲慣步爺⁁⁰潷敲晵氠捬楥湴ⵢ慳敤⁰污瑦潲洠瑨慴晦敲猠慬氠瑨攠晥慴畲敳映䍯浥琠䕚⁰汵猺⁁摶慮捥搠摡瑡潬汥捴楯渠捡灡扩汩瑩敳㨠扡牣潤攠獣慮湩湧Ⱐ灡湩挠慬敲琬⁷潲欠潲摥爠浡湡来浥湴Ⱐ睩牥汥獳⁦潲浳湤⁳異敲癩獯爠瑩浥⁥湴特⸊੃潭整⁍潢楬攠坯牫敲㨠周攠浯獴⁲潢畳琠灡捫慧攮⁐牯癩摥猠扵獩湥獳敳⁷楴栠愠捯浰汥瑥汹⁷楲敬敳猠潰敲慴楯湡氠浡湡来浥湴⁳祳瑥洮⁉湣汵摥猠慬氠潦⁃潭整⁔牡捫敲❳⁦敡瑵牥猠灬畳㨠䍡汥湤慲猬畴潭慴敤畳瑯浥爠捯浭畮楣慴楯湳Ⱐ睯牫牤敲⽩湶潩捥⁵灤慴楮朠晲潭⁴桥⁦楥汤Ⱐ睯牫牤敲⁳敱略湣楮本⁥硣敳獩癥⁳瑯瀠瑩浥汥牴猬⁷楲敬敳猠景牭猬⁴畲渭批⵴畲渠癯楣攠湡癩条瑩潮Ⱐ慮搠浯牥⸊ੁ摶慮捥搠坩牥汥獳⁆潲浳㨠呵牮湹⁰慰敲⁦潲洠楮瑯⁷楲敬敳猠捬潮攠潦⁴桥⁳慭攠楮景牭慴楯渠ⴠ湯慴瑥爠桯眠捯浰汩捡瑥搮⁓慶攠瑩浥礠瑲慮獦敲物湧⁩湦潲浡瑩潮慣欠瑯⁴桥晦楣攠睩瑨⁷楲敬敳猠獰敥搮⁓慶攠灡灥爠慮搠敬業楮慴攠摵慬•ഊ
    3     ≁䥒呉䵅⁍慮慧敲⁦牯洠䅔♔⁰牯癩摥猠愠浯扩汥灰汩捡瑩潮猠摥獩杮敤⁴漠瑲慣欠扩汬慢汥⁨潵牳⸠⁔桥⁁㑐⁳潬畴楯湳畴潭慴楣慬汹潧⁷楲敬敳猠敭慩氬慬汳Ⱐ慮搠扩汬慢汥⁥癥湴猬獳潣楡瑥猠瑨敭⁷楴栠捬楥湴爠灲潪散琠捯摥猠慮搠摩牥捴猠扩汬慢汥⁲散潲摳⁴漠扩汬楮朠獹獴敭献†周攠呩浥乯瑥⁳潬畴楯湳⁰牯癩摥⁳汩浭敤潷渠數灥物敮捥Ⱐ慬汯睩湧⁦潲牥慴楯渠潦慮畡氠扩汬慢汥⁥癥湴献†周敲攠慲攠瑷漠癥牳楯渠潦⁁㑐湤⁔業敎潴攮ਊ䭥礠䙥慴畲敳㨊⨠䥮捬畤攠捡灴畲攠慤⵨潣楬污扬攠敶敮瑳ਪ⁃慰瑵牥潢楬攠灨潮攠捡汬湤⁥浡楬†慳楬污扬攠敶敮瑳Ⱐਪ⁁扩汩瑹⁴漠慳獩杮楬污扬攠敶敮琠瑯汩敮琠慮搠灲潪散琊⨠䅢楬楴礠瑯⁳敡牣栠慮搠獣牯汬⁴桲潵杨楬污扬攠敶敮瑳Ⱐ潰瑩潮⁴漠楮瑥杲慴攠睩瑨楬汩湧⁳祳瑥浳 ⨠偯瑥湴楡氠扥湥晩瑳⁩湣汵摥⁩湣牥慳敤⁰牯摵捴楶楴礠慮搠牥摵捥搠慤浩湩獴牡瑩癥癥牨敡搠湤⁩湣牥慳敤⁲敶敮略略⁴漠浯牥捣畲慴攠捡灴畲楮朠潦楬污扬攠敶敮瑳•ഊ
    4     ≁灲楶慐慹⁁乄⁁灲楶慐慹⁐牯晥獳楯湡氠晲潭⁁否吠瑵牮⁹潵爠浯扩汥敶楣攠楮瑯⁰潲瑡扬攠捲敤楴慲搠瑥牭楮慬⸠坩瑨潭灡瑩扬攠䅔♔⁳浡牴灨潮攬⁁灲楶慐慹爠䅰物癡偡礠偲潦敳獩潮慬⁳潦瑷慲攬湤敲捨慮琠慣捯畮琬⁹潵爠浯扩汥⁷潲武潲捥慮⁰牯捥獳牥摩琠潲敢楴慲搠灡祭敮瑳⁦牯洠瑨攠晩敬搮ਊ䭥礠䙥慴畲敳㨠 ⨠卭慲瑰桯湥ⵢ慳敤⁳潬畴楯渠⁴漠灲潣敳猠捲敤楴慲搠灡祭敮瑳 ⨠䙵汬ⵦ敡瑵牥搠灯楮琭潦⵳慬攠獯汵瑩潮⁳異灯牴楮朠慬氠浡橯爠瑲慮獡捴楯渠瑹灥ਠ⨠卵灰潲瑳牥摩琠慮搠摥扩琠瑲慮獡捴楯湳 ਊ∍
    To make sure that the .txt files are accessible in the directory I executed the following script, Host Echo Hello World > C:\...path...\1.Txt
    After which I found the contents of the file changed to "Hello World". Later I loaded the .txt file with "Hello World" and queried the table. Still I am getting some garbage value. However since the string "Hello World" is much smaller than the previous contents, the garbage size is also smaller for ID 1. I don't get any errors, but you can see the output as follows.
    1      䠀攀氀氀漀 圀漀爀氀搀  ഀ਀
    2     ≁否吠潦晥牳摶慮捥搠睩牥汥獳⁦潲浳慰慢楬楴礠睩瑨⁃潭整⁅娠䍯浥琬⁔牡捫敲湤⁃潭整⁍潢楬攠坯牫敲ਊ䍯浥琠䕚㨠周攠浯獴⁲潢畳琬潳琠敦晥捴楶攠睥戠扡獥搠䵒䴠慰灬楣慴楯渠楮⁴桥⁩湤畳瑲礮⁃慰慢楬楴楥猠楮捬畤攠䝐匠汯捡瑩潮⁴牡捫楮本⁷楲敬敳猠瑩浥汯捫Ⱐ来漭晥湣楮朠睩瑨汥牴猬⁳灥敤湤⁳瑯瀠瑩浥汥牴猬湤渭摥浡湤爠獣桥摵汥搠牥灯牴楮朮ਊ䍯浥琠呲慣步爺⁁⁰潷敲晵氠捬楥湴ⵢ慳敤⁰污瑦潲洠瑨慴晦敲猠慬氠瑨攠晥慴畲敳映䍯浥琠䕚⁰汵猺⁁摶慮捥搠摡瑡潬汥捴楯渠捡灡扩汩瑩敳㨠扡牣潤攠獣慮湩湧Ⱐ灡湩挠慬敲琬⁷潲欠潲摥爠浡湡来浥湴Ⱐ睩牥汥獳⁦潲浳湤⁳異敲癩獯爠瑩浥⁥湴特⸊੃潭整⁍潢楬攠坯牫敲㨠周攠浯獴⁲潢畳琠灡捫慧攮⁐牯癩摥猠扵獩湥獳敳⁷楴栠愠捯浰汥瑥汹⁷楲敬敳猠潰敲慴楯湡氠浡湡来浥湴⁳祳瑥洮⁉湣汵摥猠慬氠潦⁃潭整⁔牡捫敲❳⁦敡瑵牥猠灬畳㨠䍡汥湤慲猬畴潭慴敤畳瑯浥爠捯浭畮楣慴楯湳Ⱐ睯牫牤敲⽩湶潩捥⁵灤慴楮朠晲潭⁴桥⁦楥汤Ⱐ睯牫牤敲⁳敱略湣楮本⁥硣敳獩癥⁳瑯瀠瑩浥汥牴猬⁷楲敬敳猠景牭猬⁴畲渭批⵴畲渠癯楣攠湡癩条瑩潮Ⱐ慮搠浯牥⸊ੁ摶慮捥搠坩牥汥獳⁆潲浳㨠呵牮湹⁰慰敲⁦潲洠楮瑯⁷楲敬敳猠捬潮攠潦⁴桥⁳慭攠楮景牭慴楯渠ⴠ湯慴瑥爠桯眠捯浰汩捡瑥搮⁓慶攠瑩浥礠瑲慮獦敲物湧⁩湦潲浡瑩潮慣欠瑯⁴桥晦楣攠睩瑨⁷楲敬敳猠獰敥搮⁓慶攠灡灥爠慮搠敬業楮慴攠摵慬•ഊ
    3     ≁䥒呉䵅⁍慮慧敲⁦牯洠䅔♔⁰牯癩摥猠愠浯扩汥灰汩捡瑩潮猠摥獩杮敤⁴漠瑲慣欠扩汬慢汥⁨潵牳⸠⁔桥⁁㑐⁳潬畴楯湳畴潭慴楣慬汹潧⁷楲敬敳猠敭慩氬慬汳Ⱐ慮搠扩汬慢汥⁥癥湴猬獳潣楡瑥猠瑨敭⁷楴栠捬楥湴爠灲潪散琠捯摥猠慮搠摩牥捴猠扩汬慢汥⁲散潲摳⁴漠扩汬楮朠獹獴敭献†周攠呩浥乯瑥⁳潬畴楯湳⁰牯癩摥⁳汩浭敤潷渠數灥物敮捥Ⱐ慬汯睩湧⁦潲牥慴楯渠潦慮畡氠扩汬慢汥⁥癥湴献†周敲攠慲攠瑷漠癥牳楯渠潦⁁㑐湤⁔業敎潴攮ਊ䭥礠䙥慴畲敳㨊⨠䥮捬畤攠捡灴畲攠慤⵨潣楬污扬攠敶敮瑳ਪ⁃慰瑵牥潢楬攠灨潮攠捡汬湤⁥浡楬†慳楬污扬攠敶敮瑳Ⱐਪ⁁扩汩瑹⁴漠慳獩杮楬污扬攠敶敮琠瑯汩敮琠慮搠灲潪散琊⨠䅢楬楴礠瑯⁳敡牣栠慮搠獣牯汬⁴桲潵杨楬污扬攠敶敮瑳Ⱐ潰瑩潮⁴漠楮瑥杲慴攠睩瑨楬汩湧⁳祳瑥浳 ⨠偯瑥湴楡氠扥湥晩瑳⁩湣汵摥⁩湣牥慳敤⁰牯摵捴楶楴礠慮搠牥摵捥搠慤浩湩獴牡瑩癥癥牨敡搠湤⁩湣牥慳敤⁲敶敮略略⁴漠浯牥捣畲慴攠捡灴畲楮朠潦楬污扬攠敶敮瑳•ഊ
    4     ≁灲楶慐慹⁁乄⁁灲楶慐慹⁐牯晥獳楯湡氠晲潭⁁否吠瑵牮⁹潵爠浯扩汥敶楣攠楮瑯⁰潲瑡扬攠捲敤楴慲搠瑥牭楮慬⸠坩瑨潭灡瑩扬攠䅔♔⁳浡牴灨潮攬⁁灲楶慐慹爠䅰物癡偡礠偲潦敳獩潮慬⁳潦瑷慲攬湤敲捨慮琠慣捯畮琬⁹潵爠浯扩汥⁷潲武潲捥慮⁰牯捥獳牥摩琠潲敢楴慲搠灡祭敮瑳⁦牯洠瑨攠晩敬搮ਊ䭥礠䙥慴畲敳㨠 ⨠卭慲瑰桯湥ⵢ慳敤⁳潬畴楯渠⁴漠灲潣敳猠捲敤楴慲搠灡祭敮瑳 ⨠䙵汬ⵦ敡瑵牥搠灯楮琭潦⵳慬攠獯汵瑩潮⁳異灯牴楮朠慬氠浡橯爠瑲慮獡捴楯渠瑹灥ਠ⨠卵灰潲瑳牥摩琠慮搠摥扩琠瑲慮獡捴楯湳 ਊ∍
    Edited by: Arunkumar Gunasekaran on Jan 3, 2013 11:38 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    >
    To make sure that the .txt files are accessible in the directory I executed the following script, Host Echo Hello World > C:\...path...\1.Txt
    After which I found the contents of the file changed to "Hello World". Later I loaded the .txt file with "Hello World" and queried the table. Still I am getting some garbage value. However since the string "Hello World" is much smaller than the previous contents, the garbage size is also smaller for ID 1. I don't get any errors, but you can see the output as follows.
    >
    The most common problem I have seen using BFILEs is the character set; BFILEs do NOT handle character set conversion.
    That is the main reason I don't recommend using BFILEs for loading data like this. Either SQL*Loader or external tables can do the job and they both handle character set conversions properly.
    See the LOADFROMFILE Procedure of DBMS_LOB package in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm#i998778
    >
    Note:
    The input BFILE must have been opened prior to using this procedure. No character set conversions are performed implicitly when binary BFILE data is loaded into a CLOB. The BFILE data must already be in the same character set as the CLOB in the database. No error checking is performed to verify this.
    Note:
    If the character set is varying width, UTF-8 for example, the LOB value is stored in the fixed-width UCS2 format. Therefore, if you are using DBMS_LOB.LOADFROMFILE, the data in the BFILE should be in the UCS2 character set instead of the UTF-8 character set. However, you should use sql*loader instead of LOADFROMFILE to load data into a CLOB or NCLOB because sql*loader will provide the necessary character set conversions.
    >
    I suggest you use an external table definition to do this load. You can do an ALTER to change the file name for each load.
    See External Tables Concepts in the Utilities doc for the basics
    http://docs.oracle.com/cd/B28359_01/server.111/b28319/et_concepts.htm
    See Altering External Tables in the DBA doc for detailed information
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables013.htm
    >
    DEFAULT DIRECTORY
    Changes the default directory specification
    ALTER TABLE admin_ext_employees
    DEFAULT DIRECTORY admin_dat2_dir;
    LOCATION
    Allows data sources to be changed without dropping and re-creating the external table metadata
    ALTER TABLE admin_ext_employees
    LOCATION ('empxt3.txt',
    'empxt4.txt');
    >
    You can also load in parallel if you have licensed that option.

  • Stream has already been closed - in SQL Developer v4.0.0.12

    Within SQL Developer v4.0.0.12 (Build 12.84) I have "Stream has already been closed" error message in the "Query result" pane.
    Used SQL:
         select * from all_mviews;
    Oracle11g Database v11.2.0.3 but this query works fine within SQL*Plus.
    When I select all the columns, I have the same error:
         select OWNER, MVIEW_NAME, CONTAINER_NAME, QUERY, QUERY_LEN, UPDATABLE, UPDATE_LOG, MASTER_ROLLBACK_SEG,
                MASTER_LINK, REWRITE_ENABLED, REWRITE_CAPABILITY, REFRESH_MODE, REFRESH_METHOD, BUILD_MODE,
                FAST_REFRESHABLE, LAST_REFRESH_TYPE, LAST_REFRESH_DATE, STALENESS, AFTER_FAST_REFRESH, UNKNOWN_PREBUILT,
                UNKNOWN_PLSQL_FUNC, UNKNOWN_EXTERNAL_TABLE, UNKNOWN_CONSIDER_FRESH, UNKNOWN_IMPORT, UNKNOWN_TRUSTED_FD,
                COMPILE_STATE, USE_NO_INDEX, STALE_SINCE, NUM_PCT_TABLES, NUM_FRESH_PCT_REGIONS, NUM_STALE_PCT_REGIONS
           from all_mviews;
    I though it was the QUERY column (datatype is LONG), but the following SQL works fine:
         select OWNER, MVIEW_NAME, CONTAINER_NAME, QUERY, query_len, updatable, update_log, master_rollback_seg,
                master_link, rewrite_enabled, REWRITE_CAPABILITY, REFRESH_MODE, REFRESH_METHOD, BUILD_MODE,
                FAST_REFRESHABLE, LAST_REFRESH_TYPE, LAST_REFRESH_DATE, STALENESS, AFTER_FAST_REFRESH, UNKNOWN_PREBUILT,
                UNKNOWN_PLSQL_FUNC, UNKNOWN_EXTERNAL_TABLE, UNKNOWN_CONSIDER_FRESH, UNKNOWN_IMPORT, UNKNOWN_TRUSTED_FD,
                COMPILE_STATE, USE_NO_INDEX, STALE_SINCE, NUM_PCT_TABLES
           from all_mviews;
    just left out some columns (at the end).
    This works also, all columns but just leaving out the QUERY column:
         select OWNER, MVIEW_NAME, CONTAINER_NAME, QUERY_LEN, UPDATABLE, UPDATE_LOG, MASTER_ROLLBACK_SEG, MASTER_LINK,
                REWRITE_ENABLED, REWRITE_CAPABILITY, REFRESH_MODE, REFRESH_METHOD, BUILD_MODE, FAST_REFRESHABLE,
                LAST_REFRESH_TYPE, LAST_REFRESH_DATE, STALENESS, AFTER_FAST_REFRESH, UNKNOWN_PREBUILT, UNKNOWN_PLSQL_FUNC,
                UNKNOWN_EXTERNAL_TABLE, UNKNOWN_CONSIDER_FRESH, UNKNOWN_IMPORT, UNKNOWN_TRUSTED_FD, COMPILE_STATE,
                USE_NO_INDEX, STALE_SINCE, NUM_PCT_TABLES, NUM_FRESH_PCT_REGIONS, NUM_STALE_PCT_REGIONS
           from all_mviews;
    It seams that these queries are reaching the limit (of data transfer) within SQL Developer v4.0.0.12 (note this was also a problem in SQL Developer v3.x).

    Hi Guy,
    Did you happen to see this recent discussion?  SQL Developer v4 giving error 'Stream has been closed' while querying tables containing long data
    I recommend trying the workaround described there just in case your issue also relates to LONG column:
    Add the following line in sqldeveloper.conf file:
       AddVMOption -Doracle.jdbc.useFetchSizeWithLongColumn=true
    Regards,
    Gary
    SQL Developer Team

  • Split Output from Select into 2 different Cols

    Hi,
    I am new to oracle dev. Env Oracle 10g R2
    I need a help with the following.
    I have a select query that returns comma separated values.
    Column LIST1 in table svp_1.
    This needs to hold that data returned by the select query.
    Datatype of Column LIST1 varchar2(4000)
    I get the follwing error.
    ORA-19011: Character string buffer too small
    CREATE OR REPLACE PROCEDURE
    sale_temp( pType in Char,lDate in date) as
    cnt number;
    v_error_code NUMBER;
    v_error_msg VARCHAR2(2000);
    cursor c1 is select svp
    from sale
    where type = pType
    var1 c1%ROWTYPE;
    BEGIN
    UPDATE svp_1
    SET LIST1 = ( SELECT LTRIM( xmlagg (xmlelement (c, RTRIM(RELATED_SVP) || ',')).extract ('//text()'), ',' ) AS RELATED_SVP from (
    SELECT rtrim(BASE_SVP) BASE_SVP,
    rtrim(RELATED_SVP) RELATED_SVP
    from
    svp_enc se
    where
    se.effective date<= pDate
    and (se.expiration_date is null or se.expiration_date > plDate )
    and se.base_svp in
    ( var1.svp
    and se.RELATION_TYPE = '4'
    )group by base_svp)
    WHERE type = pType
    commit;
    dbms_output.put_line('UPDATE done' );
    end;
    end loop;
    close c1;
    END ;
    My requirement :
    In need to capture the data from the select query and update the column.
    The data needs to be returned as comma separated values.
    This data can also be split into 2 columns.....ie data split and updated into 2 cols ie LIST1 AND LIST2 ( can be added to existing table).
    What is the best way to do this?
    Is the below approach possilble?
    LOOP through cursor ...check the length of data....for the select query ....check length .if > 3990 byte.....then write into 2 plsql variables.....and update 2 cols....
    Is this apporach right, if so how to do that in the procedure ? Please give an example...
    Are there any other approaches...?
    All I need is to Split Output from Select into 2 different columns and avoid the ORA-19011: Character string buffer too small error.
    Thanks in advance.

    Re: ORA-19011: Character string buffer too small

  • Lexical paramaters

    Am very new to Oracl Reports - and SQL. I have the Oracle U training manuals, and Pinnacle's book, have used the online help. I'm sorry, but I do not find any simple explanation on exactly how to use the lexical parameters. I've created 4 user parameters I wish to have as drop downs for user querying. They show up when running the report, but do not work.
    I see by other posts I need to use a trigger, however, again, I see no explanations easy enough, or complete enough. Also, how does one use/enter 'all' in a lexical parameter? And select more then one item in a list?
    Much thanks for any help, or any books, or direction you could point me to.

    VIII. RESTRICTIONS ON LEXCIAL PARAMETER IN ORACLE REPORTS
    1) You cannot make lexical references in a PL/SQL statement.
    2) If a column or parameter is used as a lexical reference in a query, its datatype must be Character.
    3) If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute.
    In addition, you should assign an alias to each lexical reference. This enables you to use the same layout field and boilerplate label for whatever value you enter for the lexical reference on the Runtime Parameter Form.
    4) If you use lexical references in your SELECT clause, you must specify the same number of items at runtime as were specified in the report's data model. Each value you specify for your lexical references at runtime must have the same datatype as its Initial Value.
    5) If you use lexical references in your SELECT clause, the width of the column is derived from the Initial Value of the arameter. Consequently you should ensure that the Initial Value of the parameter corresponds to the widest column that you intend to use.
    6) A Report Builder link should not depend upon a lexical reference. That is, neither the child column of a link or its table name should be determined by a lexical reference. To achieve this functionality, you need to create a link with no columns specified and then enter the SQL clause (e.g., WHERE) for the link directly in the query. For example,
    your parent and child queries might be written as follows:
    Parent Query: SELECT DEPTNO FROM EMP
    Child Query : SELECT &PARM_1 COL_1, &PARM2 COL_2 FROM EMP WHERE &PARM_1 = :DEPTNO
    7) Note how the WHERE clause makes a bind reference to DEPTNO, which was selected in the parent query. Also, this example assumes that you have created a link between the queries in the Data Model editor with no columns specified.
    8) A lexical reference cannot be used to create additional bind variables after the After Form trigger fires. For example, suppose you have a query like the following (note that the WHERE clause is replaced by a lexical reference):
    SELECT ENAME, SAL FROM EMP &where_clause
    If the value of the WHERE_CLAUSE parameter contains a reference to a bind variable, you must specify the value in the After Form trigger or earlier. You would get an error if you supplied the following value for the parameter in the Before Report trigger:
    WHERE SAL = :new_bind
    If you supplied this same value in the After Form trigger, the report would run.
    Hope this information is helpful regarding Lexical parameters.
    Best Regards,
    Murali D B,
    Oracle Support Services.

  • Dynamically Create Report

    Dear All,
    I am working with oracle 10g reports along oracle 10g database. Now I want to create a dynamic report based on parameter, which columns I will select from forms only those filed will be shown on the report. Number of columns will not be static and report will only show those columns selected by the users from form.
    Please help me to solve this problem.
    Thanks and Regards,

    See the report Builder Help on Lexical parameters. Carefully read everything about it, especially the restrictions, like "If a column or parameter is used as a lexical reference in a query, its Datatype must be Character" and "If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute". Here is an example:
    SELECT &P_ENAME NAME, &P_EMPNO ENO, &P_JOB ROLE FROM EMP
    P_ENAME, P_EMPNO, and P_JOB can be used to change the columns selected at runtime. For example, you could enter DEPTNO as the value for P_EMPNO on the Runtime Parameter Form. Note that in this case, you should use aliases for your columns. Otherwise, if you change the columns selected at runtime, the column names in the SELECT list will not match the Report Builder columns and the report will not run.

  • REP-498 Error

    I am executing the following query in Reports and I am getting the error REP-498: Number of columns selected by the query is incompatible with report definition.
    Select 1, sysdate
    &P_1
    from dual
    I pass the string for the lexical parameter P_1 => ,sysdate, sysdate-1
    What is the solution?
    Thanks,
    Kunal

    Always start with the Reports Online Help. It's so informative:
    .     If a column or parameter is used as a lexical reference in a query, its Datatype must be Character.
    .     If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute. In addition, you should assign an alias to each lexical reference. This enables you to use the same layout field and boilerplate label for whatever value you enter for the lexical reference on the Runtime Parameter Form.
    .     If you use lexical references in your SELECT clause, you must specify the same number of items at runtime as were specified in the report's data model. Each value you specify for your lexical references at runtime must have the same datatype as its Initial Value.
    .     If you use lexical references in your SELECT clause, the width of the column is derived from the Initial Value of the parameter. Consequently, you should ensure that the Initial Value of the parameter corresponds to the widest column that you intend to use.
    Your query violates the requirements in bold.

  • Query results: which kind of datatype?

    Hi to all,
    I have a query which returns more more more records. I must insert this records in a string that i have to return from a function ( i have to invoke this procedure from an application visual basic 6).
    What kind of datatype i have to use? Long datatype is small for me (and for my demand i cannot use clob).
    Maybe i could return from a function (for example) a string that is concatenation of more than 2 long datatype! But could i do this? And, if yes, how could i declare my procedure (or function)?
    Thanks
    Edited by: user635881 on 8-ott-2008 11.09
    Edited by: user635881 on 8-ott-2008 11.20

    This is my code:
    declare
    risultati LONG;*
    i number;
    TYPE t_cur IS REF CURSOR;
    TYPE type_rec IS RECORD (...more code...more code...);
    cur  t_cur;
    bilancio_def_entry   type_rec;
    BEGIN
    OPEN cur FOR
    SELECT q.codicepool, q.codicefisico, q.denominazione,
    q.tipoedificio, q.tipoimpianto, q.stationtypecaminus, q.codiceateco,
    +...more code ...more code...+
    --end of select;+     
    risultati:='';
    LOOP
    FETCH cur INTO bilancio_def_entry;
    EXIT WHEN cur%NOTFOUND;
    if bilancio_def_entry.codicepool is null then
    bilancio_def_entry.codicepool := bilancio_def_entry.codicefisico;
    end if;
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita1)) || ';' || trim(to_char( bilancio_def_entry.energia1)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato1)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita2)) || ';' || trim(to_char( bilancio_def_entry.energia2)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato2)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita3)) || ';' || trim(to_char( bilancio_def_entry.energia3)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato3)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita4)) || ';' || trim(to_char( bilancio_def_entry.energia4)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato4)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita5)) || ';' || trim(to_char( bilancio_def_entry.energia5)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato5)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita6)) || ';' || trim(to_char( bilancio_def_entry.energia6)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato6)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita7)) || ';' || trim(to_char( bilancio_def_entry.energia7)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato7)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita8)) || ';' || trim(to_char( bilancio_def_entry.energia8)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato8)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita9)) || ';' || trim(to_char( bilancio_def_entry.energia9)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato9)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita10)) || ';' || trim(to_char( bilancio_def_entry.energia10)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato10)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita11)) || ';' || trim(to_char( bilancio_def_entry.energia11)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato11)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita12)) || ';' || trim(to_char( bilancio_def_entry.energia12)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato12)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita13)) || ';' || trim(to_char( bilancio_def_entry.energia13)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato13)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita14)) || ';' || trim(to_char( bilancio_def_entry.energia14)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato14)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita15)) || ';' || trim(to_char( bilancio_def_entry.energia15)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato15)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita16)) || ';' || trim(to_char( bilancio_def_entry.energia16)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato16)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita17)) || ';' || trim(to_char( bilancio_def_entry.energia17)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato17)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita18)) || ';' || trim(to_char( bilancio_def_entry.energia18)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato18)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita19)) || ';' || trim(to_char( bilancio_def_entry.energia19)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato19)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita20)) || ';' || trim(to_char( bilancio_def_entry.energia20)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato20)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita21)) || ';' || trim(to_char( bilancio_def_entry.energia21)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato21)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita22)) || ';' || trim(to_char( bilancio_def_entry.energia22)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato22)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita23)) || ';' || trim(to_char( bilancio_def_entry.energia23)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato23)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita24)) || ';' || trim(to_char( bilancio_def_entry.energia24)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato24)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita25)) || ';' || trim(to_char( bilancio_def_entry.energia25)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato25)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita26)) || ';' || trim(to_char( bilancio_def_entry.energia26)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato26)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita27)) || ';' || trim(to_char( bilancio_def_entry.energia27)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato27)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita28)) || ';' || trim(to_char( bilancio_def_entry.energia28)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato28)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita29)) || ';' || trim(to_char( bilancio_def_entry.energia29)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato29)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita30)) || ';' || trim(to_char( bilancio_def_entry.energia30)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato30)) || chr(10);*
    risultati:= risultati || trim(bilancio_def_entry.codicepool) || ';' || trim(bilancio_def_entry.codicefisico) || ';' ||  trim(bilancio_def_entry.denominazione) || ';' ||  trim(bilancio_def_entry.tipoedificio) || ';' || trim(bilancio_def_entry.tipoimpianto) || ';' ||*
    trim(bilancio_def_entry.stationtypecaminus) || ';' || trim(bilancio_def_entry.codiceateco) || ';' || trim(to_char(bilancio_def_entry.capacitatrasporto)) || ';' ||*
    trim(to_char(bilancio_def_entry.capacitaconferita31)) || ';' || trim(to_char( bilancio_def_entry.energia31)) || ';' ||   trim(to_char(bilancio_def_entry.volumeprofilato31)) || chr(10);*
    END LOOP;
    INSERT INTO APPOGGIO VALUES (risultati);
    commit;
    CLOSE cur;
    END;
    Pl sql variable is risultati (it is a long type).
    In the previous code i insert it in a table (but only to see what is results of concatenation ...it's not my purpose). When i insert this code in a procedure i want return from the procedure pl sql the variable risultati+. If risultati is longer than 32k i obtain an error. How could i do to obtain at the end a variable (or a concatenation of variables) long (for example) 2.000.000 of characters? This variable is the return variable of a procedure pl sql.
    Thanks a lot.

  • Query XML(CLOB) datatype

    Hello,
    I am new to XML and have been trying this for few days and get no luck ...
    First, I have an Excel file, which contains a list of bills for customers. It is a sample file to test my application.
    In the future, my application will receive data of XML-datatype, so my job here is to import this Excel file into my Oracle database 11gr2, then transform it to XML datatype one.
    I did import it by using Oracle SQL Developer and nicely stored it in a table called so_lieu.
    After that, I run the following code to convert the table data to XML datatype:
    CREATE TABLE xmlDoc(temp CLOB);
    DECLARE
      qryCtx DBMS_XMLGEN.ctxHandle;
      temp CLOB;
    BEGIN
      qryCtx := DBMS_XMLGEN.newContext('SELECT * FROM huy.so_lieu');
      -- Set the row header to be bill
      DBMS_XMLGEN.setRowTag(qryCtx, 'bill');
      -- Get the result
      temp := DBMS_XMLGEN.getXML(qryCtx);
      INSERT INTO xmlDoc VALUES(temp);
      --Close context
      DBMS_XMLGEN.closeContext(qryCtx);
    END;
    It is a success:
    table XMLDOC created.
    anonymous block completed
    When I run: SELECT * from xmlDoc; I can get a data of XML-datatype as following:
    <?xml version="1.0"?>
    <ROWSET>
    <bill>
      <MA_CQTT>5335</MA_CQTT>
      <ACCOUNT>P482668</ACCOUNT>
      <TEN_CQTT>Công ty TNHH FrieslandCampina Việt Nam</TEN_CQTT>
      <DIACHI>phường Bình Hòa, Thị xã Thuận An, Bình Dương</DIACHI>
      <MS_THUE>3700229344-   -</MS_THUE>
      <SDT>754422 ext 333</SDT>
      <LOAI_DV>48</LOAI_DV>
      <TEN>Mail - SMD</TEN>
      <CUOC_DV>0</CUOC_DV>
      <DC>0</DC>
      <CUOC_TBSD>0</CUOC_TBSD>
      <TRUY_THU>0</TRUY_THU>
      <TONG_TIEN>22254545</TONG_TIEN>
      <VAT>2225455</VAT>
    </bill>
    <bill>
      <MA_CQTT>90255</MA_CQTT>
      <ACCOUNT>P0421100</ACCOUNT>
      <TEN_CQTT>VPĐD HOME MERIDIAN INTERNATIONAL,INC TạI TP.HCM</TEN_CQTT>
      <DIACHI>Tầng trệt, Block C, Cao ốc An Khang, P. An Phú, Q.2, TP.HCM</DIACHI>
      <MS_THUE>0302199864-   -</MS_THUE>
      <SDT>838228511</SDT>
      <FAX>838293764</FAX>
      <LOAI_DV>7</LOAI_DV>
      <TEN>Internet trực tiếp</TEN>
      <CUOC_DV>0</CUOC_DV>
      <DC>0</DC>
      <CUOC_TBSD>35446000</CUOC_TBSD>
      <TRUY_THU>0</TRUY_THU>
      <TONG_TIEN>35446000</TONG_TIEN>
      <VAT>3544600</VAT>
    </bill>
    </ROWSET>
    Then I try to select/query the XML elements inside that XML data (to parse them into another tables) but cannot. I tried:
    SELECT XMLQuery('
        for $x in ora:view("xmlDoc")/ROW
           return $x/TEMP/ROWSET/bill/MA_CQTT
    ' RETURNING CONTENT) FROM DUAL;
    It gave errors
    ORA-19276: XPST0005 - XPath step specifies an invalid element/attribute name: (ROWSET)
    19276. 00000 -  "XP0005 - XPath step specifies an invalid element/attribute name: (%s)"
    *Cause:    The XPath step specified invalid element or attribute name that did not match any nodes according to the input XML schema or structure.
    *Action:   Correct the element or attribute name as the name may be mis-spelled.
    I read several threads and think that maybe my ROWSET element is not XML anymore. Thus, cannot select using XPath. How can I fix it?
    Thank you in advance,
    Huy Do.
    PS: I tried using XMLTABLE as below:
    SELECT x2.*
      from XMLDOC h,
        XMLTABLE(
          '//ROWSET/bill'
          PASSING xmltype(h.temp)
          COLUMNS ma_cqtt  varchar(20) path 'ma_cqtt'
          ) x2
    The query gave me a table of 2566 row of "ma_cqtt" but their value are all "null" (excel file has 2566 rows of record)
    Message was edited by: 2716502

    Thank you Odie I tried:
    INSERT INTO DM_TABLE (ma_cqtt, account, thang_ps)
        select x.ma_cqtt
             , x.account
             , thangps as thang
    Of course it returned an error, how silly of me to complicate thing like that
    And I have one more question about the speed to parse a xml data. Please, help me with it.
    In my code, I usually store xml data as a row in a temporary table (table mau_so_lieu). Then when doing parsing, I call the xml data from that table and the processing time is usually ~0.5s only. The code is like below:
    INSERT INTO mau_so_lieu VALUES(xmlData);
    INSERT INTO DM (                         
                                ma_kh, account, thang_ps)
        select x.ma_kh, x.account, thang
          from mau_so_lieu m, xmltable
              ('//Bao_cuoc'
                passing m.BILL
                columns
                   ma_kh varchar2(20) path '@ma_cqtt'
                  , account varchar2(20) path '@account'
              ) x;
    But one of my senior (SQL server expert) suggested to store xml data in a variable (xmlData XMLType) as he thought the processing time will be even shorter, as well as no temporary table needed (no trash left which need to be cleaned later). I tried that but somehow the processing time is > 5s with the code as below:
    INSERT INTO DM (                         
                                ma_kh, account, thang_ps)
        select x.ma_kh, x.account, thang
          from xmltable
              ('//Bao_cuoc'
                passing xmlData
                columns
                   ma_kh varchar2(20) path '@ma_cqtt'
                  , account varchar2(20) path '@account'
              ) x;
    Could you tell me why the processing time are so different? Is it because of the default RAM of Oracle XE 11g is too small to process?
    Thank you very much,
    Huy Do.

  • How can i work with getdate() in my query if i have a varchar datatype on where clause column ?

    Hi All,
    I have a column like lastdate with varchar datatype. now I want to work with lastdate column in where clause with getdate().
    Ex:  where
    getdate()  -  lastdate < 1
    when I use above one I got error like
    Error = Conversion failed when converting date and/or
    time from character string.
    I knew the datatypes for lastdate and getdate() are different...
    how can I use...
    Thanks,
    rup

    You need to convert the string date to datetime or date. See conversion examples here:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Example for the where clause:
    WHERE DATEDIFF(DD, convert(datetime, lastdate, 101), getdate() ) < 1
    Can you post sample string dates?
    Are you looking for today's records? Another option (depends on lastdate format):
    WHERE lastdate = convert(char(8), getdate(), 112)
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Datatype : 25 not supported error while saving Logical Query in BIP Dataset

    Hi All,
    I have created a nested logical Query in OBIEE Publisher Datamodel using parameters.
    Here is the simple query :
    Select name, revenue, date from
    select "SubjectAreaName"."TableName"."Name" name,
    case when :Date > date '2012-01-01' then "SubjectAreaName"."TableName"."Revenue" else NULL end Revenue,
    date date
    from
    "SubjectAreaName"
    where
    date = :Date
    ) T1
    Note - :Date is the parameter. When I try saving this dataset as-is, it throws me Datatype : 25 not supported error. But, when i replace the parameter :Date with actual date, then the query works. Also, the inner query works with or without parameters. The issue arises when I use the outer query and the parameters.
    Please let me know if you have come across such a problem ?
    Any help on this regard would be highly appreciated.
    Thanks
    Swarna

    ya i can understand we wont do the sql logic at the data model part as some time performance issue may come when comparaed to sql run in package and sql running in data model . so i have mostly done using package and i will just do select * from table in the data set of data model so i didn't face any issue's like this .
    once check this tutorial may be you already
    i use to create parameters like this i didn't face any issue
    SELECT * from TEST where ID=:p_id
    http://st-curriculum.oracle.com/obe/fmw/bi/bip/bip11g/gettingstarted/gettingstarted.htm

  • VERY URGENT: problem in sql query with long datatype in weblogic

    I have a problem while tryind to retrieve a column value with a long datatype using servlet and oci driver and the server is weblogic5.1 .I have used prepared statement the problem comes in the
    preparedStatement.executeQuery().
    The sql Query is simple query and runs well in all cases and fails only when the long datatype column is included in the query.
    The exception that comes on the weblogic server is that :
    AN UNEXPECTED EXCEPTION DETECTED IN THE NATIVE CODE OUTSIDE THE VM.

    Did you try changing the driver then?
    Please use Oracle's thin driver instead of the oci driver.
    There are many advantages of using the type 4 driver. the first and foremost being that it does not require oracle client side software on your machine. Therefore no enteries to be made in tnsnames.ora
    The thin driver is available in a jar called classes112.zip the class which implements the thin driver is oracle.jdbc.driver.OracleDriver
    the connection string is
    jdbc:oracle:thin:@<machine name>:1521:<sid>
    please try out with the thin driver and let me know.
    regards,
    Abhishek.

  • SQL Query : Getting specific datatype in select clause

    Hi
    I want to write one query that returns me the values inside a table based on the datatype of column(s) of the table. For e.g. I need only those columns of the table in select clause where the datatype of the column is VARCHAR.
    Can you please help me on this?

    Use the "user_tab_columns" Data Dictionary to get the columns and build the SQL Dynamically.
    Thanks,
    Karthick.

  • Table defination in datatype size can effect on query execution time.

    Hello Oracle Guru,
    I have one question , suppose I have create one table with more than 100 column
    and i tacke every column datatype varchar2(4000).
    Actual data are in every column not more than 300 character so in this case
    if i execute only select query
    so oracle cursor internaly read up to 4000 character one by one
    or it read character one by one and in last character ex. 300 it will stop there.
    If i reduce varchar2 size 300 instend of 4000 in table defination,
    so is it effect on select query execution time ?
    Thanks in advance.

    When you declare VARCHAR2 column you specify maximum size that can be stored in that column. Database stores actual number of bytes (plus 2 bytes for length). So if yiou insert 300 character string, only 302 bytes will be used (assuming database character set is single byte character set).
    SY.

  • Datatype issue in function query

    Hi,
    Below is my table
    create table dsource(
    prod varchar2(10),
    source_dt date,
    source_type varchar2(2),
    list_owner_nbr number);
    insert into dsource values('TOH','01-jul-2010','D',9);
    insert into dsource values('TOH','01-jul-2010','D',24);
    insert into dsource values('TOH','01-jul-2010','D',238);
    insert into dsource values('TOH','01-jul-2010','D',253);
    insert into dsource values('TOH','01-jul-2010','D',521);
    insert into dsource values('TOH','01-jul-2010','D',617);
    insert into dsource values('TOH','01-jul-2010','D',680);
    commit;
    I created one function
    create or replace function mark_camp (v_prod_abbr varchar2,source_dt varchar2,source_type varchar2,v_list_owner_nbr varchar2) return varchar2 as
    begin
    select *
    from dsource
    where prod_abbr=v_prod_abbr
    and to_char(source_start_dt,'MONYY')=source_dt and mke_mag_source_type_cd=source_type
    and list_owner_nbr in(v_list_owner_nbr) ;
    return(v_prod_abbr||','||source_dt||','||source_type||','||v_list_owner_nbr);
    end mark_camp;
    Now I am running one query
    select mark_camp('TOH','JUL2010','D','9, 24, 238, 253, 521, 617, 680') from dual;
    I am getting 0 rows returned
    if I execute
    select mark_camp('TOH','JUL2010','D',9, 24, 238, 253, 521, 617, 680) from dual;
    then error occurs ORA-06553: PLS-306: wrong number or types of arguments in call to 'MARK_CAMP'
    Here list_owner_nbr datatype is number in table and I am passing multiple values in function so I used varchar2 in function
    but this query is not working. can anybody please help because user will enter multiple values in list_owner_nbr.

    799301 wrote:
    Now I am running one query
    select mark_camp('TOH','JUL2010','D','9, 24, 238, 253, 521, 617, 680') from dual;
    I am getting 0 rows returnedThe reason why your first call to function succeed is that anything between single quotes in considered as a single string. so '9, 24, 238, 253, 521, 617, 680' is considered as a single varchar2 value. Your function expectes 4 varchar2 values and the same are being provided.
    if I execute
    select mark_camp('TOH','JUL2010','D',9, 24, 238, 253, 521, 617, 680) from dual;
    then error occurs ORA-06553: PLS-306: wrong number or types of arguments in call to 'MARK_CAMP'In second call you are passing 3 varchar2 and 7 numbers (9,24,238,...are being considered as individual paramerter) and hence the error.
    Coming to your actual problem :
    Here list_owner_nbr datatype is number in table and I am passing multiple values in function so I used varchar2 in function
    but this query is not working. can anybody please help because user will enter multiple values in list_owner_nbr.This is called varying in list and the forum FAQ page has a listing for it :
    {message:id=9360009}

Maybe you are looking for

  • HP Deskjet 710c printer don't work on a Mac Mini

    I have a Mac Mini with OSX 10.9 but my HP Deskjet 710c printer don't work. I install the HP driver package from Apple but I don't see my printer in the list. Who can help me out? Thanks.

  • How to change the TCP session limit for Domain Controllers in TMG2010

    I've many errors in TMG2010, that relates with too many TCP sessions, that are generated from my two domain controllers. how can i change since settings? Regards! Lasandro Lopez

  • RAW support new camera's - Fujifilm X-Pro1

    As an experienced photographer, I've chosen Aperture over Lightroom. Reason was that I hoped for a better support of new camera's & features in the Mac-world (I don't like Adobe so much). To me, it looks to be an opportunity for Apple to beat Adobe i

  • Can't Connect to OS X Server 10.6.4 using AFP - but can via SMB

    OK, I'm stumped. This is a brand new Mini server running OS X Server 10.6.4. I can connect from 10.5 and 10.6 clients using SMB but not AFP. Access to all services is set to 'Allowed' so it's not a service restriction. Server has good DNS resolution

  • Archiving Business Partners

    Hi, I was hoping someone could help me with this. When I use the transaction: SARA to archive flagged Business Partners, it doesn't seem to write them to the database or to a flat file. I think it may be that I haven't configured the customizing opti