What is wrong in SQL Statement with CLOBs Fields
Hello, need help!! I create that SQL:
select
id, caid, region_id, folder_id, masterthingid, visible, display_name, image, keywords, publish_date, subtype, text,
max(decode(name, 'Destaque', value, null)) destaque,
max(decode(name, 'Fonte', value, null)) fonte,
max(decode(name, 'Legenda', value, null)) legenda,
max(decode(name, 'chamada', value, null)) chamada,
max(decode(name, 'TitulodaChamada', value, null)) titulo_chamada,
max(decode(name, 'Tema', value, null)) tema
from portal.lista_noticias_total
group by id, caid, region_id, folder_id, masterthingid, visible, display_name, image, keywords, publish_date, subtype
But the field 'text' doesn't appear =|~
Im doing anything wrong?
Help-me!!
Thks for attencion
Hi,
You can't GROUP BY a CLOB.
Sorry, I missed that part of your subject line.
My original answer follows:
I don't see a ; anywhere. Is that the complete query?
If so, you need to add text to the GROUP BY clause:
group by id, caid, region_id, folder_id, masterthingid, visible, display_name, image, keywords, publish_date, subtype
, textEdited by: Frank Kulash on Mar 4, 2009 3:04 PM
Similar Messages
-
Hello together,
I post this Question here in
Re: SQL-Statement with OO4O
and i should paste my question again in an another database forum.
now here again:
I have here following Problem:
Everthime I make a connection to my database with this code
Set oSess = Server.CreateObject("OracleInProcServer.XOraSession")
Set oDB = oSess.DbOpenDatabase(tnsname, user/PWD, 4)
I get always this Statement in the DB-queue
SELECT parameter, VALUE
FROM SYS.nls_database_parameters
WHERE parameter IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')
Can me anyone tell me why I get this statement and how I can disable it?
Best Regards
AndyHi,
What can you do/change?I must ask next week my boss when he is back,
what kind of changes I can do.
Can you add a PL/SQL call to DBMS_APPLICATION_INFO into application?my boss must give me the permission to do a call to DBMS_APPLICATION_INFO.
A way to identify the source of the badly behaving code is required; whether that be within the DB or external of it.I think so too.
So please wait, until I have talk with my boss, than I will give you the answer you want. Sorry.
Any other ideas, what I can do without call/changes on the database to find the problem?
Best Regards
Andy -
ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long
Dear All,
I am getting an error "ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long" while executing the following statement:
CLEAR LS_RANGE.
LS_RANGE-SIGN = 'I'
+LS_RANGE-OPTION = 'CP' +
LS_RANGE-LOW = 'S_ADMI_FCD'
LS_RANGE-HIGH = 'S_ADMI_FCD'
COLLECT LS_RANGE INTO LT_RANGE.
SELECT *
FROM UST12
INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
WHERE FIELD IN LT_RANGE
AND AKTPS = 'A'.
For options like BT(Between), EQ(Equal) in range table, this above query is executing without dump. But for option CP, it simply dumps & in dump what i found is, it is concatenating the value in low & high.
Does anyone have any idea regarding open sql using range tables.
Thanks,
BhupinderHi,
I commented as follows:
If LS_RANGE-HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions. Yet operators CP and NP do not have the full functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*' or '+' ) are used in the input fields. If wildcards are entered on the selection screen, the system automatically uses the operator CP.
If LS_RANGE-HIGH is filled, you can use BT (BeTween) and NB (Not Between). These operators correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to a range. You cannot use wildcard characters.
You can try:
CLEAR LS_RANGE.
LS_RANGE-SIGN = 'I'.
+LS_RANGE-OPTION = 'CP' +
LS_RANGE-LOW = 'S_ADMI_FCD'.
LS_RANGE-HIGH = 'S_ADMI_FCD'.
FIND '*' IN LS_RANGE.
IF sy-subrc = 0.
LS_RANGE-OPTION = 'CP'.
ELSE.
LS_RANGE-OPTION = 'EQ'.
ENDIF.
COLLECT LS_RANGE INTO LT_RANGE.
SELECT *
FROM UST12
INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
WHERE FIELD IN LT_RANGE
AND AKTPS = 'A'.
If you use wildcards the LS_RANGE length should not exceed 10 characters.
Hope this information is help to you.
Regards,
José -
Pl/sql statement with output in reports
Hello,
I am quite new to reports and pl/sql, i have built a pl/sql statement with some loops that works fine when running it in sqlplus.
I would really like to have this running in reports with the variables (v_year, v_month and v_sumvalue) in a table/record in the data view, so i can use them just like any ordinary fields in a table for example in a diagram.
I have tried to create a package spec, setting up a record with the variables as fields. And then a pl/sql function with the following sql (which was a bit modified to work in the pl/sql function). Everything seemed to work since the pl/sql table/record was there with the variables as fields in it, but it never returned anything... just fatal error.
Here is the original pl/sql statement which is working in sqlplus, any help/directions in how to get this working so i can use the variables like fileds in a regular table would be fantastic:
DECLARE
v_year number(4);
v_month number(2);
v_sumvalue number(9,3);
v_sta varchar2(10);
v_end varchar2(10);
v_stopmonth number(2);
BEGIN
--## Get last 5 years ##--
select
to_char(add_months(sysdate,-60),'YYYY'),
to_char(sysdate,'MM')
into v_year, v_stopmonth
from
dual;
--dbms_output.put_line(v_year);
--## Loop 5 years ##--
for i in 1..5 loop
v_year := v_year + 1;
--dbms_output.put_line(v_year);
--## Loop 12 times (months) ##--
for k in 0..11 loop
v_month := k +1;
--dbms_output.put_line(v_year ||'-'|| v_month);
select
sum(nvl(p.value,0)) / 3,
last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1,
last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
into v_sumvalue, v_sta, v_end
from
project p
where
p.country_code = 'SWE'
and
p.project_type_code = 'P'
and
p.start_date between last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1 and last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
and
p.q_category_code between 1000 and 1299
and
p.geography_code between 2100 and 2199;
dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue);
--dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue ||' '|| v_sta ||' '|| v_end);
--## Stop monthloop ##--
end loop;
--## Stop yearloop ##-
end loop;
END;Output:
2003-1 19.1
2003-2 20.1
2007-11 164.5
2007-12 135.167Best regards,
OlleHi,
Maybe pipelined functions will be useful for you:
http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Table_Functions_Cursor_Expressions/Pipelined_Table_Functions.htm
Regards
Jakub Flejmer -
Dynamic SQL Statement with table name
Dear all
i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
should be something like "select * from <mytablename>"
Thank you
HerbertYes this is possible. use the below reference code for this.
data: g_tablename type w_tabname,
gv_dref TYPE REF TO data.
FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
ASSIGN gv_dref->* TO <g_itab>.
now use the below select query to fetch the data
SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
Hope this will help -
How to find sql statement with Unix process pid
Hi
how to find sql statement with Unix process pid
is there any view to find that.
please if so let me know
Thanks in advancethis is how I am doing this:
oracle 7352340 7459066 0 07:47:10 - 0:00 oracleJDERED (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 7459066 5386396 2 07:47:10 pts/1 0:01 sqlplus
select sid,serial# from v$session where process='7459066';
SID SERIAL#
2178 6067
select sql_text
from
v$sqlarea a,
v$session b
where a.hash_value = b.sql_hash_value
and b.sid = 2178
; -
SQL statement with union clause
Hi,
I have a scenario where i need to generate a sql statement with UNION .
Eg:
SELECT B.YY_ID,
FROM XXXX.YY B
WHERE (B.YY_TY= 'as')
UNION
SELECT B.YY_ID
FROM XXXX.YY_ALT_NAME A, XXXX.YY B
WHERE (A.YY_TY= 'zx'
AND (B.YY_ID=A.YY_ID)"
I tried ns1:table1() union ns3:table2() in XQuery.
But it is pushdown as 2 seperate sqls.
Is it possible to create XQuery that pushdown as SINGLE SQL statement with union clause ?
ThanksNo. See 3.1.1.5 in the document I referenced in your previous post.
-
Display the sql statement with arguments with ojdbc14_g.jar
Hi,
I'd like to display the sql statements with ojdbc14_g.jar.
So I've followed the documentation and set an OracleLog.properties file which is linked to my java program.
The problem is the trace generated is huge and I only need the SQL requests wich are made with the arguments but I don't know how to configure that.
Have you got a sample file which handle that ?
I've tried that :
oracle.jdbc.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=CONFIG
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
oracle.level=INFO
oracle.jdbc.driver.level=OFF
oracle.jdbc.driver.OraclePreparedStatement.level=OFF
oracle.jdbc.pool.level=OFF
oracle.jdbc.util.level=OFF
oracle.sql.level=INFO
But that doesn't display only the SQL and args :(
Regards.The fact is the statement are made by ejb entities on JBoss so I don't have a way to make specific logger to display the sql order. The only thing I can do is to set the log4j org.jboss.ejb.plugins.cmp to a trace level in order to see the sql order but without the arguments.
I tried those traces however I see stuff like that without any SQL orders :
<<
10:10:53,833 INFO [STDOUT] NFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
INFO: PhysicalConnection.getDefaultFixedString() returning false
29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=2, x=VIEW_ACTION_NAMES)
29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:52 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
29 nov. 2007 10:10:52 oracle.jdbc.driver.OracleResultSetImpl close
INFO: OracleResultSetImpl.close()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
INFO: PhysicalConnection.getCatalog()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
INFO: PhysicalConnection.getDefaultFixedString() returning false
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
INFO: OracleResultSetImpl.close()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
INFO: PhysicalConnection.getCatalog()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
INFO: PhysicalConnection.getDefaultFixedString() returning false
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
INFO: OracleResultSetImpl.close()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
INFO: PhysicalConnection.getCatalog()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
INFO: PhysicalConnection.getDefaultFixedString() returning false
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
INFO: OracleResultSetImpl.close()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
INFO: PhysicalConnection.getCatalog()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
INFO: PhysicalConnection.getRemarksReporting()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
INFO: PhysicalConnection.getDefaultFixedString() returning false
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
INFO: PhysicalConnection.getRestrictGetTables() returned false
29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
INFO: OracleResultSetImpl.close()
29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
INFO: PhysicalConnection.getMetaData()
29 nov. 20>> -
What would be the SQL statement?
What would be the SQL statement to pull data from the current week that the data was queried, regardless of what day of the current week that you queried the data?
WHERE Date_Col >= TRUNC(SYSDATE, 'DY')
Note that the first day of the week depends on national settings:
SQL> alter session set nls_territory = 'AMERICA';
Session altered.
SQL> SELECT TRUNC(SYSDATE, 'DY') FROM DUAL;
TRUNC(SYS
20-JAN-08
SQL> alter session set nls_territory = 'GERMANY';
Session altered.
SQL> SELECT TRUNC(SYSDATE, 'DY') FROM DUAL;
TRUNC(SY
21.01.08Regards,
Dima -
How to Run SQL Tuning Advisor on the SQL statement with SQL_ID?
Can you give the steps to run the SQL tuning advisor on the SQL statement with SQL_ID?
Database version: 10g Release 2Hi,
You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
-- creating the tuning task
set serveroutput on
declare
l_sql_tune_task_id varchar2(100);
begin
l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
sql_id => '<your_sql_id>',
scope => dbms_sqltune.scope_comprehensive,
time_limit => 60,
task_name => '<your_tuning_task_name>',
description => 'tuning task for statement your_sql_id.');
dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
end;
-- executing the tuning task
exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
-- displaying the recommendations
set long 100000;
set longchunksize 1000
set pagesize 10000
set linesize 100
select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
Cheers
Legatti -
Understanding logminer results -- inserting row into table with CLOB field
In using log miner I have noticed that inserts into rows that contain a CLOB (I assume this applies to other LOB type fields as well, have only tested with CLOB so far) field are actually recorded as two DML entries.
--the first entry is the insert operation that inserts all values with an EMPTY_CLOB() for the CLOB field
--the second entry is the update that sets the actual CLOB value (+this is true even if the value of the CLOB field is not being set explicitly+)
This separation makes sense as there may be separate locations that the values are being stored etc.
However, what I am tripping over is the fact the first entry, the Insert, has a RowId value of 'AAAAAAAAAAAAAAAAAA' which is invalid if I attempt to use it in a flashback query such as:
SELECT * FROM PERSON AS OF SCN #####' where RowId = 'AAAAAAAAAAAAAAAAAA'The second operation, the Update of the CLOB field, has the valid RowId.
Now, again, this makes sense if the insert of the new row is not really considered "+done+" until the two steps are done. However, is there some way to group these operations together when analyzing the log contents to know that these two operations are a "+matched set+"?
Not a total deal breaker, but would be nice to know what is happening under the hood here so I don't act on any false assumptions.
Thanks for any input.
To replicate:
Create a table with CLOB field:
CREATE TABLE DEVUSER.TESTTABLE
ID NUMBER
, FULLNAME VARCHAR2(50)
, AGE NUMBER
, DESCRIPTION CLOB
);Capture the before SCN:
SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;Insert a new row in the test table:
INSERT INTO TESTTABLE(ID,FULLNAME,AGE) VALUES(1,'Robert BUILDER',35);
COMMIT;Capture the after SCN:
SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;Start logminer session with the bracketing scn values and options etc:
EXECUTE DBMS_LOGMNR.START_LOGMNR(STARTSCN=>2619174, ENDSCN=>2619191, -
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + DBMS_LOGMNR.NO_ROWID_IN_STMT + DBMS_LOGMNR.NO_SQL_DELIMITER)Query the logs for the changes in that range:
SELECT
commit_scn, xid,operation,table_name,row_id
,sql_redo,sql_undo, rs_id,ssn
FROM V$LOGMNR_CONTENTS
ORDER BY xid asc,sequence# ascResults:
2619178 0C00070028000000 START AAAAAAAAAAAAAAAAAA set transaction read write
2619178 0C00070028000000 INSERT TESTTABLE AAAAAAAAAAAAAAAAAA insert into "DEVUSER"."TESTTABLE" ...
2619178 0C00070028000000 UPDATE TESTTABLE AAAFEXAABAAALEJAAB update "DEVUSER"."TESTTABLE" set "DESCRIPTION" = NULL ...
2619178 0C00070028000000 COMMIT AAAAAAAAAAAAAAAAAA commitEdited by: 958701 on Sep 12, 2012 9:05 AM
Edited by: 958701 on Sep 12, 2012 9:07 AMScott,
Thanks for the reply.
I am inserting into the table over a database link.
I am using the new version of HTML Db (2.0)
HTML Db is connected to an Oracle 10 database I think, however the table I am trying to insert data into (via the database link) is in an Oracle 8 database - this is why we created a link to it as we couldn't have the HTML Db interacting with the Oracle 8 database directly due to compatibility problems (or so I've been told)
Simon -
Problems While Working With CLOB fields
HI Friends,
I am facing one big problem while working with CLOB fields. I work in crystal reports in my project and My team is works in BMC Remedy tool. As per database configuration by default the date fields are stored in numbers. There is a field named Work Log which stores the complete history information of a ticket or a call.
While generating reports I convert the date fields from numbers into date values by using to_date function. But I am not able to change the dates mentioned in the worklog which is a CLOB field. As a result when I am generating reports text part of the work log is comming fine but the date fields are comming in numbers.
Please refer the below example:-
*1291012455anilkumarptesting*
Full Name:
PRG Name - EUC-APP PKGN1291012585anilkumarptesting
Full Name:
PRG Name - EUC-APP PKGN1291012631anilkumarptest
Full Name:
PRG Name - EUC-APP PKGN1291207510anilkumarpfd
Full Name: Anil Kumar Pantangi
PRG Name - Prod_Ops1291207535anilkumarpf
Full Name: Anil Kumar Pantangi
PRG Name - Prod_Ops
Assignment notification disabled for this transaction1291212517kapilbasd
Full Name: Anil Kumar Pantangi
PRG Name - Prod_Ops
See the first line of the worklog "1291012455anilkumarptesting", 1291012455 is referring a date value, but due to database configuration it's comming in number. All the other numbers in the above text are dates only which need's to be converted. These dates are captured in remedy tool when someone updates that ticket.
I am not able to decide how to change this numbers into dates. As it is containing lot's of numbers i am really confused how to come with a solution.
Can I expect a solution from you, atleast a way how to proceed resolving this problem. Should I have to write a procedure for this??
Please help..........
Kindly let me know if you need any more input.
Regards,
Arijit937670 wrote:
1291012455 represents a date value,What date value does it represent? Since it's not obvious to us what date you want that converted into, it's obviously hard for us to help. For example, perhaps you want that to be Jan 29, 2010 with "12455" representing a time component in some non-obvious format. Perhaps you want that to be December 1991 at 1:24:55. Perhaps you want to convert it to a completely different date. You're going to need to tell us in words how to convert your numeric data into a date.
My question is how can I convert all the numbers into date in the CLOB field and present it in a proper manner.Given your sample data, what do you expect the output to be? Do you expect many rows of data, one for every date in the CLOB? Do you expect a comma-separated list? Something else?
Justin -
Getting table script using dbms_metadata.get_ddl, but with clob field
So, Oracle 11g R2..
I'm using dbms_metadata.get_ddl to get table scripts and it's working fine..
now, I have a table with clob field, and it's not working... I got an 'missing right parenthesis (ora-0907)' error...
I could paste a script that I got, but I don't think it makes any sense..
does anybody have some experience on using this package on clob tables?
tnxthis is script that I got... it's long, and it looks like it's not good
CREATE TABLE "COMMON"."TEST_AAA2"
( "ID" NUMBER(10,0),
"TEKST" VARCHAR2(200 CHAR),
"UPDATESTAMP" DATE,
"OBJEKAT" CLOB,
CONSTRAINT "TEST_PART_PK2" PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
ALTER INDEX "COMMON"."TEST_PART_PK2" UNUSABLE ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
PARTITION BY RANGE ("UPDATESTAMP")
(PARTITION "P_201012" VALUES LESS THAN (TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201101" VALUES LESS THAN (TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201102" VALUES LESS THAN (TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201103" VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201104" VALUES LESS THAN (TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201105" VALUES LESS THAN (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201106" VALUES LESS THAN (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201107" VALUES LESS THAN (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_MAXVALUE" VALUES LESS THAN (MAXVALUE)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ) -
SQL statement with LIMIT and total count?
Hello,
I would like to know if it is possible to execute a single SQL statement that will return me a subset of data (for pagination purposes) that not only includes the subset of data for the page but the count of all available data. Can this be done so as to not take up the cpu and time it takes to essentially run two queries? One to get the subset and one to get the count? I think simply doing a subselect is not going to give me what I want in that we actually query twice.
There may be no way to do this other than that, but I wanted to check with the gurus here first. :)
Thanks,
Markselect *
from (
select i.*,
row_number() over(order by i) rn, -- used for
pagination
count(*) over(partition by 1) cnt -- total count
of rows found for this search
from mytable
where < PUT ALL LIMITING (i.e., "search") CONDITIONS
HERE >
where rn between 41 and 50 -- pagination clauseNice one
BUT of course it adds additional row in execution plan and takes additional time and CPU :)
I assume that it directly depends of course on returned result set and some other factors like available sort space but a simple test case on a table big which actually is 1.6 M rows like dba_source got following results:
here is the first one returning also count(*)
SQL> select *
2 from (
3 select i.*,
4 row_number() over(order by owner, name, type) rn
5 , -- used for pagination
6 count(*) over(partition by 1) cnt -- total count of rows found for this search
7 from big i
8 where owner like 'S%' and name like '%A%'
9 )
10 where rn between 41 and 45
11 /
OWNER NAME TYPE
LINE
TEXT
RN CNT
SYS ANYDATA TYPE
13
STATIC FUNCTION ConvertVarchar(c IN VARCHAR) return AnyData,
41 999744
SYS ANYDATA TYPE
11
STATIC FUNCTION ConvertDate(dat IN DATE) return AnyData,
42 999744
SYS ANYDATA TYPE
9
43 999744
SYS ANYDATA TYPE
7
They serve as explicit CAST functions from any type in the Oracle ORDBMS
44 999744
SYS ANYDATA TYPE
6
enable construction of the AnyData in its entirity with a single call.
45 999744
Elapsed: 00:00:41.02
SQL> ed
Wrote file afiedt.buf
1 select n.name, m.value from v$statname n, v$mystat m
2 where n.statistic# = m.statistic#
3* and (upper(name) like '%SORT%' or upper(name) like '%TEMP%')
SQL> /
NAME VALUE
physical reads direct temporary tablespace 35446
physical writes direct temporary tablespace 17723
RowCR attempts 0
SMON posted for dropping temp segment 0
sorts (memory) 36
sorts (disk) 1
sorts (rows) 1999596
OTC commit optimization attempts 0
8 rows selected.here is the second one returning only rows:
SQL> ed
Wrote file afiedt.buf
1 select *
2 from (
3 select i.*,
4 row_number() over(order by owner, name, type) rn
5 --, -- used for pagination
6 -- count(*) over(partition by 1) cnt -- total count of rows found for this search
7 from big i
8 where owner like 'S%' and name like '%A%'
9 )
10* where rn between 41 and 45
SQL> /
OWNER NAME TYPE
LINE
TEXT
RN
SYS ANYDATA TYPE
13
STATIC FUNCTION ConvertVarchar(c IN VARCHAR) return AnyData,
41
SYS ANYDATA TYPE
11
STATIC FUNCTION ConvertDate(dat IN DATE) return AnyData,
42
SYS ANYDATA TYPE
9
43
SYS ANYDATA TYPE
7
They serve as explicit CAST functions from any type in the Oracle ORDBMS
44
SYS ANYDATA TYPE
6
enable construction of the AnyData in its entirity with a single call.
45
Elapsed: 00:00:12.09
SQL> select n.name, m.value from v$statname n, v$mystat m
2 where n.statistic# = m.statistic#
3 and (upper(name) like '%SORT%' or upper(name) like '%TEMP%')
4 /
NAME VALUE
physical reads direct temporary tablespace 0
physical writes direct temporary tablespace 0
RowCR attempts 0
SMON posted for dropping temp segment 0
sorts (memory) 10
sorts (disk) 0
sorts (rows) 999812
OTC commit optimization attempts 0
8 rows selected.So execution time 41 sec vs 12 sec
sorts (rows) 1 999 596 vs 999 812
physical reads/writes direct temporary tablespace 35446/17723 vs 0/0
I assume that for a small overall returned row count it probably is OK, but for less restrictive search it can be quite deadly as before with two queries.
Gints Plivna
http://www.gplivna.eu -
How to run a sql statement with bind variable in a test environment
Hello,
I have a sql statement in prod that I like to run in test. I got the sql statement from statspack, but the statement has bind variables. How do I get this statement to run in test? Thank you.Hi,
If you have the SQL statement and all the referenced objects are available in your test env then what is the problem to run it?
If I am not wront to get your reqmnt...
i.e
SQL> select * from emp
where emp_no = &empno
and dept_code = &deptcode;
Thanks
Maybe you are looking for
-
Changing from Portrait to Landscape having completed report
Hi Im using 9i to build a report which the customer now wants landscape. I have changed the system parameter ORIENTATION and set the header and trailer pages to landscape and 11 by 8.5. Set the main page orientation to Lanscape and width to 11 but th
-
Assigning a JSTL variable to a ariable in scriptlet
Hi how do i assign a JSTL to a variable in Scriptlet? Regards Abhinav
-
I lose my internet connection when i sync iTunes and ATV. Please help
Ive just bought a new Apple TV and I am trying to stream TV shows and movies from my iMac via the wireless network. The ATV found the right network instantly and I wrote in the password. Ive paired the iMac iTunes and ATV and I can see all the episod
-
Cannot publish new .htm file with Contribute
A client of mine is having an issue with a webpage he maintains daily using the Contribute package, and one major problem has come up while trying to add new features to his presentation. Instead of linking directly to a file as has been done in the
-
hai Can anyone send the 'How to create queries on effeciencitenly on the Multiproviders' document to me please. rizwan