LONG column and translate function
I want to get the default values of columns through all_tab_columns.
I have written the query :
select a.COLUMN_NAME, translate(a.DATA_DEFAULT,'''',' ')
from all_tab_columns a
where a.TABLE_NAME like 'T_MPR_MBT'
But it gives the following error:
ORA-00932: inconsistent datatypes: expected NUMBER got LONG
Is there a way to convert long to string?
Thanks
Ameya.
SQL> describe long_tab;
Name Null? Type
COL1 NUMBER
COL2 LONG
COL3 VARCHAR2(40)
SQL> select * from long_tab;
COL1 COL2 COL3
1 1st value for long characters 1st value for long characters
2
3 3rd value for long characters 3rd value for long characters
SQL> select * from long_tab
2 where nvl(col2,'x') = nvl(col2,'x');
where nvl(col2,'x') = nvl(col2,'x')
ERROR at line 2:
ORA-00932: inconsistent datatypes: expected LONG got CHAR
-- we know that we cannot compare a column with long datatype to other column that is not a long datatype.
-- we have to create some custom function to convert the long into a character type.
SQL> CREATE OR REPLACE Function convert_long_to_char( pTableName in varchar2,
2 pColumnName in varchar2,
3 pRowId in rowid ) return varchar2 As
4 vCursor integer default dbms_sql.open_cursor;
5 vN number;
6 vLongVal varchar2(4000);
7 vLongLen number;
8 vBuflen number := 4000;
9 vCurPos number := 0;
10 begin
11 dbms_sql.parse( vCursor,'select ' || pColumnName || ' from ' || pTableName ||
12 ' where rowid = :x',
13 dbms_sql.native );
14 dbms_sql.bind_variable( vCursor, ':x', pRowId );
15
16 dbms_sql.define_column_long(vCursor, 1);
17 vN := dbms_sql.execute(vCursor);
18
19 if (dbms_sql.fetch_rows(vCursor)>0) then
20 dbms_sql.column_value_long(vCursor, 1, vBuflen, vCurpos ,
21 vLongVal, vLongLen );
22 end if;
23 dbms_sql.close_cursor(vCursor);
24 return vLongVal;
25 end convert_long_to_char;
26 /
Function created.
SQL> select * from long_tab
2 where nvl(convert_long_to_char('long_tab','col2',rowid),'x') = nvl(col3,'x');
COL1 COL2 COL3
1 1st value for long characters 1st value for long characters
2
3 3rd value for long characters 3rd value for long characters
SQL>
-- in your case it would something like:
select a.COLUMN_NAME,
translate(convert_long_to_char('all_tab_columns','DATA_DEFAULT',rowid),'''',' ')
from all_tab_columns a
where a.TABLE_NAME like 'T_MPR_MBT';
Similar Messages
-
Invalid code in the column and DUMP function
Hi all,
My DB is 11.1 and Character set is UTF8.
After ETL, I find some invalid characters appear in my tables, one of which is '�'. Since they are history data, I can't find the source data for them.
The only choice for me now seems to remove all of them for downstream systems. After issuing select dump(column,10) from mytable, I find that '�' is represented by
239,191,189.
So I guess whether I can dump the data, remove the bad string and then umdump the contents to get the good string. In a word, is there an inverse function for dump function?
Can anybody give me some advices, please? Thank you very much.
Best regards,
LeonHi Leon
Its working for me
Not that the Datatype of variable "a" is "*NVARCHAR2*"
SQL>SELECT *
2 FROM t_13;
INSERT_SORCE NAME DUMP_NAME
TOAD Arun¿Gupta Typ=96 Len=12: 65,114,117,110,239,191,189,71,117,112,116,97
TOAD_To_Textpad_To_TOAD Arun?Gupta Typ=96 Len=10: 65,114,117,110,63,71,117,112,116,97
TOAD_To_SQLPlus Arun?Gupta Typ=96 Len=10: 65,114,117,110,63,71,117,112,116,97
SQL>DECLARE
2 a NVARCHAR2(100) := CHR(191);
3 b VARCHAR2(100);
4 c VARCHAR2(100);
5 b_dump VARCHAR2(200);
6 c_dump VARCHAR2(200);
7 BEGIN
8 SELECT name
9 ,REPLACE (name,a,'')
10 INTO b
11 ,c
12 FROM t_13
13 WHERE insert_sorce = 'TOAD';
14
15
16 SELECT DUMP(b)
17 ,DUMP(c)
18 INTO b_dump
19 ,c_dump
20 FROM DUAL;
21
22
23 DBMS_OUTPUT.PUT_LINE ('Value of b = '||b);
24 DBMS_OUTPUT.PUT_LINE ('Dump Value of b = '||b_dump);
25 DBMS_OUTPUT.PUT_LINE ('Value of c = '||c);
26 DBMS_OUTPUT.PUT_LINE ('Dump Value of c = '||c_dump);
27 END;
28 /
Value of b = Arun¿Gupta
Dump Value of b = Typ=1 Len=12: 65,114,117,110,239,191,189,71,117,112,116,97
Value of c = ArunGupta
Dump Value of c = Typ=1 Len=9: 65,114,117,110,71,117,112,116,97
PL/SQL procedure successfully completed.My DB
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
Regards
Arun
Edited by: Arun Kumar Gupta on Jun 15, 2011 2:44 PM -
Grand total of calculated column and case function in the same calcultd col
Hi Gurus,
In 9.0.4, the Grand total of the calculated column is not working as per the CASE function. It is taking the ELSE formula for all records. Is there a way to correct it.
Thanks,
PoojaHi Pooja,
In the totals ,which u mentioned try using cell sum function instead of sum function.
Manikandan
GKB Consulting Inc., -
Select LONG column into CLOB variable
Hi all,
I am trying retrieve the data present in a LONG column into a CLOB variable.
However I am getting an error, pls let me know how I can resolve it.
DECLARE
v_text CLOB;
BEGIN
SELECT TO_LOB(trigger_body)
INTO v_text
FROM
user_triggers
WHERE
ROWNUM <= 1;
END;
ERROR at line 8:
ORA-06550: line 8, column 20:
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got LONG
ORA-06550: line 8, column 5:
PL/SQL: SQL Statement ignored
Let me know if there is an alternate to this. I would like to get the data present in the LONG column into a variable.
The reason why I am not retrieving the LONG column into LONG variable is stated below (from Oracle Website):
You can insert any LONG value into a LONG database column because the maximum width of a LONG column is 2**31 bytes.
However, you cannot retrieve a value longer than 32760 bytes from a LONG column into a LONG variable.
Thanks and Regards,
SomuThere are couple of things I did (listed in order):
1) Create Global Temporary Table containing a CLOB column
2) Select LONG column and convert to CLOB by using TO_LOB and insert into Global Temporary Table containing a CLOB column
2) Select from this Global Temporary Table (which already contains data in CLOB) and assign it to a CLOB variable.
This is done because you can not directly use TO_LOB in a select statement to assign the value to a CLOB variable.
Stated below is an example:
-- Create Temporary Table
CREATE GLOBAL TEMPORARY TABLE glb_tmp_table_lob(
time TIMESTAMP WITH LOCAL TIME ZONE,
text CLOB
ON COMMIT DELETE ROWS;
-- PL/SQL Block to Execute
DECLARE
v_clob CLOB;
BEGIN
-- Insert into Temporary Table by converting LONG into CLOB
INSERT INTO glb_tmp_table_lob (
time ,
text
SELECT
sysdate ,
TO_LOB(dv.text)
FROM
dba_views dv
WHERE
ROWNUM <= 1
-- Select from the Temporary table into the variable
SELECT
gt.text
INTO
v_clob
FROM
glb_tmp_table_lob gt;
COMMIT;
-- Now you can use the CLOB variable as per your needs.
END;
/ -
UpdateCharacterStream for LONG column gives SQLException: Data size bigger than max
I have a LONG column and when I call updateCharacterStream via the resultset I get the following error:
SQLException: Data size bigger than max size for this type: 2391
I am trying to update the column with a value that is 2391 in length. The column is defined as a LONG so it is plenty big enough.
What gives?
If I use a UTF-8 database it works OK. But if I use a db that is on the default character set I get the error. There are NO multibyte characters, I just happened to test it against my unicode db and it worked.This only happens with the thin driver. I am using 8i. It also works OK if the target db is in UTF8!
D:\myjava>java OracleLongTest
Registering the ORACLE JDBC drivers.
Connecting to database
Connection = oracle.jdbc.driver.OracleConnection@1616c7
Insert via prepared statement with reader length = 2200
Insert with prepared statement was successfull
Updating via prepared statement with reader length = 2200
Update with prepared statement was successfull
===========================================================================
ticketDesc len = 2200 mod date = 970510081398
Updating with reader length = 2200
Updating C1 ts = 970510081608
Updating the row...
Exception 2 = java.sql.SQLException: Data size bigger than max size for this type: 2200
java.sql.SQLException: Data size bigger than max size for this type: 2200
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:775)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:82)
at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:761)
at oracle.jdbc.driver.OraclePreparedStatement.setDatum(OraclePreparedStatement.java:1464)
at oracle.jdbc.driver.OraclePreparedStatement.setCHAR(OraclePreparedStatement.java:1397)
at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:1989)
at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:2200)
at oracle.jdbc.driver.OraclePreparedStatement.setOracleObject(OraclePreparedStatement.java:2216)
at oracle.jdbc.driver.UpdatableResultSet.prepare_updateRow_binds(UpdatableResultSet.java:2070)
at oracle.jdbc.driver.UpdatableResultSet.updateRow(UpdatableResultSet.java:1287)
at OracleLongTest.run(OracleLongTest.java:146)
at OracleLongTest.main(OracleLongTest.java:41)
FINISHED!!
StringBuffer sb = new StringBuffer("");
for(int i = 0; i < 2200; i++)
sb.append("X");
Statement stmt = con.createStatement();
try
String insertSQL = "CREATE TABLE MYLONGTEST (C1 NUMBER(38), C2 LONG)";
stmt.executeUpdate(insertSQL);
catch( SQLException se) {}
PreparedStatement insertPstmt = con.prepareStatement("INSERT INTO MYLONGTEST VALUES (?, ?)");
PreparedStatement updatePstmt = con.prepareStatement("UPDATE MYLONGTEST SET C2 = ? WHERE C1 = ?");
PreparedStatement selectPstmt = con.prepareStatement("SELECT C1,C2 FROM MYLONGTEST WHERE C1 = ?", 1004, 1008);
long ts = System.currentTimeMillis();
String value = sb.toString();
Reader rdr = new StringReader(value);
int len = value.length();
try
System.out.println("Insert via prepared statement with reader length = " + len);
insertPstmt.setLong(1, ts);
insertPstmt.setCharacterStream(2, rdr, len);
insertPstmt.execute();
System.out.println("Insert with prepared statement was successfull");
catch( SQLException se )
System.out.println("Caught exception = " + se.toString());
try
System.out.println("Updating via prepared statement with reader length = " + len);
rdr = new StringReader(value);
updatePstmt.setCharacterStream(1, rdr, len);
updatePstmt.setLong(2, ts);
int rowcount = updatePstmt.executeUpdate();
System.out.println("Update with prepared statement was successfull");
updatePstmt.close();
catch( SQLException se )
System.out.println("Caught exception = " + se.toString());
System.out.println("===========================================================================");
selectPstmt.setLong(1, ts);
ResultSet rs = selectPstmt.executeQuery();
rs.absolute(1);
String c2 = rs.getString("C2");
ts = rs.getLong("C1");
System.out.println("c2 len = " + c2.length() + " mod date = " + ts);
rs.absolute(1);
ts = System.currentTimeMillis();
System.out.println("Updating with reader length = " + len);
rdr = new StringReader(value);
rs.updateCharacterStream("C2", rdr, len);
ts = System.currentTimeMillis();
System.out.println("Updating C1 ts = " + ts);
rs.updateLong("C1", ts);
System.out.println("Updating the row...");
rs.updateRow();
null -
Substr and instr for long column
Plesae need support ,how can use instr and substr function for column with long datatype
select substr(rec,1,(instr(rec,'?',1))) from F_DE_O_HISTORY_QUEUE_PRE_TST2
rec column is long,When execute this select message displayed as ORA-00932: inconsistent datatypes: expected NUMBER got LONGTry to create a global temporary table and work on this table using DBMS_LOB.INSTR and DBMS_LOB.SUBSTR:
SQL> desc t;
Name Null? Type
X NUMBER(38)
Y LONG
SQL> create global temporary table tmp on commit preserve rows as select x, to_lob(y) as y from t ;
Table created.
SQL> desc tmp;
Name Null? Type
X NUMBER(38)
Y CLOBEdited by: P. Forstmann on 19 janv. 2010 12:42 -
LONG RAW Columns and Replication Set-up
we are working to set-up a replicated environment for all of
our Oracle Applications.
I could not get a clear understanding which Version Oracle will
support BLOB/CLOB/LONG RAW replication support or
Whether we can plan for Replicating such kind of Applications.
I read from one of Oracle Press book - "Oracle Backup &
Recovery" it is documented
that Oracle doesn't replication support for columns that use
BLOBs,CLOBs ( Page
no. 434 )
As one of our application was designed using LONG RAW Column, I
was wondering
about carrying the existing LONG RAW column to be replicated
like a CLOB/BLOB, if oracle supports Replication of BLOB/CLOB.
It will be of great help, if you can provide some insight in the
complexity of
having BLOBs in the applications to go further on making our
efforts to have a
Replicated environment set-up.
Thanking you in anticipation.
Bhanu Prakash
< [email protected]>1) LONG and LONG RAW have been depricated since 8i so you shouldn't be using them ever for anything.
2) LONG and LONG RAW don't even have decent support to be manipulated from PL/SQL so there is essentially no SQL support.
3) It would be very rare that you would have anything to index in a LONG or a LONG RAW from a functionality standpoint. You're not likely, for example, to want to store more than 4k of data in a LONG and then do things like search for strings that start with a particular phrase. You're very very unlikely to want to search a binary LONG RAW to look for rows where the binary data starts with a particular string of bytes. You'd potentially want to be able to use Oracle Text on a LONG field to search for particular words and phrases in the text but I'm not sure that existed prior to LONGs being depricated.
Justin -
I recently began using reminders in ical and downloaded the iPhone and iPad app. It works great. However, the reminders in ical on the COMPUTER is difficult to work with - thin long column on the right rather than in it's own screen. is there a reminders app for the COMPUTER that is more user friendly?
sgreenie,
If you are willing to wait, Apple - OS X Mountain Lion - Inspired by iPad. Made for the Mac explains that a "Reminders" application will be included in the next release of OS X. -
Since ios 7 I can no longer use google translate in safari. I use this page every day to translate friends Facebook entries. Anyone else having this problem? And is there a fix? Currently it is in my bookmark bar beside Facebook and worked fine until I upgraded top ios 7 a few days ago.
Go to your Google translate bookmark.
Type in a word then tap whatever language.
Make a select for the language to be translated to by tapping Dutch (or whatever language you see in the box all the way to the right. You should see a language menu. -
Excel function and ev function not working in static column key
I have created a evdre report and I notice that when I tried to use any excel function and ev functions in the static column key cell to get the value for that cell, it's not working.
e.g I have Col key define as:
ColKeyRange Sheet!&$J$12:$N$14
In K13 which is key id for time. I define is as = $K$10 where K10 is the time value from current view, it not working,the value is still K13 = $K$10. then I tried to use EVCVW function to replace K10, it also not working, but I use the same function in the description of the ID underneath, both of the are working, Any thought?
Edited by: DFW on Feb 9, 2010 7:33 PMHi,
That was exactly what I meant. They just dont work on the green ID areas or the yellow data region. Few days back even I tried that, but didnt work. So, I followed the different approach. I dont remember about the dynamic templates. Are you sure that the functions were written in the green ID region?
I remember this used to work fine in the MS version. However, in the NW version, even I am not able to make them work.
Edited by: nilanjan chatterjee on Feb 9, 2010 9:38 PM -
How to save xml and xsl function to a data grid column
hi. wondering, i have a xml and a xsl file, and have the transform class, and so need to save the xml and the xsl file, and display the results on a particular data grid column and to loop through the data grid columns. so, how do i use the xml save function
class, any examples or point me to articles, where i can read how to do this. need to display a file, with a different colour and font. any ideas. thanks. marvin.hi. need to save a xml and xsl file and display the results on data grid. how do i do this. any
sample code or articles i can read about thanks. marvin.
http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOz
Hi.
Okay, well, did ask on the msdn forums, and some one replied, and so, will paste the code he suggested.
But getting a lot of errors.
Can you help me out.
Where am I going wrong.
So, I can then get this to work, then it shows the colours and the fonts on the specified data grid.
Can you help.
Want to get this working and passed today if possible.
Will pasate the code and the errors below.
Can you help.
Where am I going wrong.
Marvin.
// Set up the data set.
DataSet ds =
new
DataSet();
// Set up the data table.
DataTable dt =
new
DataTable();
// Ad the data table to the data set.
ds.Tables.Add(dt);
// Write the xml document to the data grid column.
ds.WriteXML(@"c:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\CurrentCount.xml");
ds.WriteXML(@"c:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\OnOrder.xml");
ds.ReadXML(@"c:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\CurrentCount.xml");
ds.ReadXML(@"c:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\OnOrder.xml");
// Set up the data table and the data set and set to 0.
dgvDisplayData.DataSource = ds.Tables[0];
Error 1 Invalid token '(' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 215
18 WoodStocks
Error 2 Invalid token ')' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 215
21 WoodStocks
Error 3 Invalid token '(' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 219
16 WoodStocks
Error 4 Invalid token '(' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 221
16 WoodStocks
Error 5 Invalid token '(' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 222
15 WoodStocks
Error 6 Invalid token '(' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 223
15 WoodStocks
Error 7 Invalid token '=' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 227
31 WoodStocks
Error 8 Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 227
43 WoodStocks
Error 9 Invalid token ';' in class, struct, or interface member declaration
C:\Docs\Education\CertificateFourProgramming\CoreInfrastructure\DevelopingXMLApplications\Assignments\WoodStocks\WoodStocks\frmData.cs 227
45 WoodStocks
Can you help me out.
Thanks.
http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOz -
The screen which comes up no longer displays a playlist column and when I hit the plus sign and choose new playlist the screen doesn't display the narrow right side column for a new playlist. Does this have something to do with the new iTunes version I installed?
iOS: Unable to update or restore
-
I am using iOS 7.0.4 and since the upgrade, I no longer have the airplay function or icon on my iPad. I want to use the AppleTV with the iPad in my classroom, but the Airplay icon is gone from the Controll. Can anyone help me to fix this PLEASE? I have updated the software on the AppleTV, and both the AppleTV and iPad are on the same network. I also restarted the router! Still no icon for the Airplay.
HotTub wrote:
... Apple has been less than no help with there only suggestion being that I should switch to Apple and quit using Microsoft. Real professional!...
If I can't get my contacts and calendar to sync, half of the reason I have a smart phone is gone.
Rather than switching to Apple, use a smartphone that WILL sync with your calendar and contacts - a Windows or Android phone. iPhones do sync with Apple products nearly flawlessly, but they don't play nice with other OS's.
Android works well with Google; and Windows works well with, well, Windows and Microsoft products. Android and Windows do cooperate somewhat. -
How to Make FUNCTION to return multiple column and multiple row output
Hi All,
Kindly Share ur Idea;Thanks in Advance;
i Have Table Demo.
table DEMO:
id name
1 a10
1 a11
1 a12
2 b10
2 b11
3 ccc
and the function is like:
create or replace function (p1 number) return varchar2 as
vid number;
vname varchar2(20);
begin
select id,name into vid,vname from demo where id=p1;
return v1;
end;
this function returns output for id=3;
BUT,
i need output as (for input as 1)
vid vname
1 a10
1 a11
1 a12A function returns a single datatype.
That datatype may be an atomic datatype (varchar2, number etc.) or it may be an object/record datatype, or even a collection datatype.
Where are you going to use this function? In PL/SQL or SQL?
If you are wanting to use it in SQL, then you would need a pipelined function e.g.
SQL> CREATE OR REPLACE TYPE myemp AS OBJECT
2 ( empno number,
3 ename varchar2(10),
4 job varchar2(10),
5 mgr number,
6 hiredate date,
7 sal number,
8 comm number,
9 deptno number
10 )
11 /
Type created.
SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myemp
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION pipedata(p_min_row number, p_max_row number) RETURN myrectable PIPELINED IS
2 v_obj myemp := myemp(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
3 BEGIN
4 FOR e IN (select *
5 from (
6 select e.*
7 ,rownum rn
8 from (select * from emp order by empno) e
9 )
10 where rn between p_min_row and p_max_row)
11 LOOP
12 v_obj.empno := e.empno;
13 v_obj.ename := e.ename;
14 v_obj.job := e.job;
15 v_obj.mgr := e.mgr;
16 v_obj.hiredate := e.hiredate;
17 v_obj.sal := e.sal;
18 v_obj.comm := e.comm;
19 v_obj.deptno := e.deptno;
20 PIPE ROW (v_obj);
21 END LOOP;
22 RETURN;
23 END;
24 /
Function created.
SQL> select * from table(pipedata(1,5));
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
SQL> select * from table(pipedata(6,10));
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
SQL> select * from table(pipedata(11,15));
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
SQL>If you are using it in PL/SQL then just populating a collection datatype and returning that will do. Though you should question why you want to pass large amounts of data around like that first.
Explain your purpose and what you are intending to do and we can recommend the best way.
{message:id=9360002} -
How to Copy a Long Column in PL/SQL
Hello. Can anyone tell me how to copy a table that contains a long column? I am using Oracle 8.0.5 SQL Worksheet
with the following code that generates an ORA-06502: PL/SQL: numeric or value error.
CREATE TABLE "Tmp_CB_REPORT"
CB_RPT_ID NUMBER(38, 0),
CB_ID NUMBER(38, 0),
CB_REGION_ID NUMBER(38, 0),
WHEN_PULLED DATE NOT NULL,
PARSED NUMBER(1, 0) DEFAULT (0) NOT NULL,
RAW_DATA LONG NOT NULL,
JOINT NUMBER(1, 0) DEFAULT (0) NOT NULL,
RPTTYPE NUMBER(38, 0) NOT NULL,
OPTION1 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION2 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION3 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION4 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION5 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION6 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION7 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION8 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION9 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION10 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION11 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION12 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION13 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION14 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION15 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION16 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION17 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION18 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION19 NUMBER(1, 0) DEFAULT (0) NOT NULL,
OPTION20 NUMBER(1, 0) DEFAULT (0) NOT NULL,
REGION_ID NUMBER(38, 0),
RPT_TYPE_DESC VARCHAR2(40)
LOCK TABLE CB_REPORT IN EXCLUSIVE MODE NOWAIT;
DECLARE
CURSOR datacursor IS SELECT CB_RPT_ID, CB_ID, CB_REGION_ID, WHEN_PULLED, PARSED, RAW_DATA, JOINT, RPTTYPE, OPTION1, OPTION2, OPTION3, OPTION4, OPTION5, OPTION6, OPTION7, OPTION8, OPTION9, OPTION10, OPTION11, OPTION12, OPTION13, OPTION14, OPTION15, OPTION16, OPTION17, OPTION18, OPTION19, OPTION20, REGION_ID, RPT_TYPE_DESC FROM CB_REPORT;
datarecord datacursor%ROWTYPE;
BEGIN
OPEN datacursor;
LOOP
FETCH datacursor INTO datarecord;
EXIT WHEN (datacursor%NOTFOUND);
INSERT INTO "Tmp_CB_REPORT"(CB_RPT_ID, CB_ID, CB_REGION_ID, WHEN_PULLED, PARSED, RAW_DATA, JOINT, RPTTYPE, OPTION1, OPTION2, OPTION3, OPTION4, OPTION5, OPTION6, OPTION7, OPTION8, OPTION9, OPTION10, OPTION11, OPTION12, OPTION13, OPTION14, OPTION15, OPTION16, OPTION17, OPTION18, OPTION19, OPTION20, REGION_ID, RPT_TYPE_DESC) VALUES (datarecord.CB_RPT_ID, datarecord.CB_ID, datarecord.CB_REGION_ID, datarecord.WHEN_PULLED, datarecord.PARSED, datarecord.RAW_DATA, datarecord.JOINT, datarecord.RPTTYPE, datarecord.OPTION1, datarecord.OPTION2, datarecord.OPTION3, datarecord.OPTION4, datarecord.OPTION5, datarecord.OPTION6, datarecord.OPTION7, datarecord.OPTION8, datarecord.OPTION9, datarecord.OPTION10, datarecord.OPTION11, datarecord.OPTION12, datarecord.OPTION13, datarecord.OPTION14, datarecord.OPTION15, datarecord.OPTION16, datarecord.OPTION17, datarecord.OPTION18, datarecord.OPTION19, datarecord.OPTION20, datarecord.REGION_ID, datarecord.RPT_TYPE_DESC);
END LOOP;
END;
The copy works fine if I remove the long column from the CREATE TABLE "Tmp_CB_REPORT" statement
and the cursor copy statement. Any help is appreciated.What I think you should do is to turn your long into a LOB. LOBs are much malleable than LONGs. I suggest you have a look at the documentation for DBMS_LOB. You can create a function using DBMS_LOB that uses a temporary CLOB to reas your long column an dreturn a CLOB.
Cheers, APC
Maybe you are looking for
-
Getting syntax error while executing keyfigure routine BI 7.0
Hello, I am writing a very simple keyfigure routine to calculate sales revune using sales quantity and sales price, I am getting error as follows - I am in 'Rules Details' screen and I have selected 'Routine' as the rule type. I enter the following c
-
Can't send message on AT&T - won't connect to server. Anyone else having this issue?
All of a sudden I can't send messages on my AT&T account. I get a message that Thunderbird cannot connect to server (STMP). Called AT&T and they verified all the settings; I can access my email account on Apple Mail and through Yahoo (AT&T's email pr
-
Connecting Mac Mini to AV Receiver
I thought this would be simple. I purchased a Mac Mini today with the thought of connecting it through my AV receiver to my LG tv. Here's what I did: 1) brought it home from the store 2) plugged an HDMI cable into the Mac Mini, and the other end into
-
To send the Payload as PDF Attachment in mail in PI 7.1
Hi All, I have to send a file as PDF attachment using a mail adapter. I gave the Content_Type as 'application.pdf'. I am receiving the mail, but I am unable to open the PDF. It says 'Could not open because the type is not supported or unable to decod
-
EDI troubles, parked documents
I am trying to help somebody with EDI. I have little knowledge of EDI but I think I'm tracking the problem down. The problem is that, in test, one vendor's inbound documents are being parked; the status is parked and online. However, we want the s