Equivalent of this db2 syntax in oracle?
Can somebody please tell me what is the equivalent of the following in oracle:
SELECT X.*
FROM XMLTABLE (xmlnamespaces (DEFAULT "http://posample.org"),
'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo'
COLUMNS "CUSTNAME" CHAR(30) PATH 'name',
"PHONENUM" XML PATH 'phone')
as X
I took this from http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/doc/c0023903.htm.
Thx!
SELECT X.*
FROM XMLTABLE
xmlnamespaces (DEFAULT "http://posample.org"),
'/customerinfo' passsing "CUSTOMER.INFO"
COLUMNS
"CUSTNAME" VARCHAR2(30) PATH 'name',
"PHONENUM" XMLTYPE PATH 'phone'
) x
Similar Messages
-
How to Migrate DB2 database to Oracle 10g R2 with this Developer Workbench
Hi
Can anybody tell how to migrate all the data which is present in DB2 to Oracle 10g Release2 through this tool. will it be possible to migrate all the data(tables,stored procedures,views,etc)?.
if anybody knows how to do it please provide me the entire steps for the same.
I am in bad need of help to Migrate my database to Oracle 10g R2
Thanks in expectation,
SelvaSelva,
The link for plugins is: http://www.oracle.com/technology/software/tech/migration/workbench/index.html. You can find DB2 plugins at the bottom of the page.
Regarding the migration procedure, you can start by reading this document:
http://www.oracle.com/technology/tech/migration/workbench/htdocs/101040/user_guide/book.pdf
Good luck,
andrei -
How do I connect to a DB2 database from Oracle 10G on linux?
Hi
I have tryed to connect to a DB2 database from oracle 10 G on linux.
I have installed unixODBC and a db2 odbc driver. I can connect to the db2 using isql, but oracle comes with this error:
select * from testtable@acc_spc_gr2
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Generic Connectivity Using ODBC]DRV_InitTdp: DB_ODBC_INTERFACE (718): ; [C077]
Could not find symbol 'SQLAllocConnect' in dynamic library
DB_ODBC_INTERFACE (722): ; [C079] Failed to load dynamic library
'/opt/ibm/iSeriesAccess/lib/libcwbodbc.so'
ORA-02063: preceding 3 lines from ACC_SPC_GR2
What am I doing wrong? Any one have a guide to do this?
- Jesperthis is my complete configuration
Database_
-bash-3.2$ export ORACLE_SID=XE
-bash-3.2$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mié Jul 7 10:04:43 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Conectado a:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Platform_
Linux srvpdf 2.6.18-164.el5xen #1 SMP Thu Sep 3 04:47:32 EDT 2009 i686 i686 i386 GNU/Linux
*/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/hs/admin/initDB2DATABASE.init*
#This is a sample agent init file that contains the HS parameters that are
# needed for an ODBC Agent.
# HS init parameters
#HS_FDS_CONNECT_INFO = ODBC_DSN
HS_FDS_CONNECT_INFO = prueba
HS_FDS_TRACE_FILE_NAME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/hs/admin/DB2DATABASE.log
HS_FDS_CONNECT_INFO = DB2DATABASE
#HS_FDS_TRACE_LEVEL = debug
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME = /opt/ibm/iSeriesAccess/lib/libcwbodbc.so
# ODBC specific environment variables
set ODBCINI=/etc/odbc.ini
# Environment variables required for the non-Oracle system
set DB2INSTANCE=is400
listener.ora_
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
(SID_DESC =
(SID_NAME = DB2DATABASE)
(ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
(PROGRAM =hsodbc)
(ENVS = LD_LIBRARY_PATH = /opt/ibm/iSeriesAccess/lib:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.3.32)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.3.31)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
DEFAULT_SERVICE_LISTENER = (XE)
tnsnames.ora_
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srvpdf)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
DB2DATABASE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =localhost )(PORT=1521))
(CONNECT_DATA =
(SERVICE_NAME = DB2DATABASE)
(HS=OK)
odbc.ini_
[prueba]
Description = iSeries Access ODBC Driver
Driver = iSeries Access ODBC Driver
System = xxx.xx.3.2
UserID = xxxxxx
Password = xxxxxx
Naming = 0
DefaultLibraries = QGPL
Database = CHERRYWEB
ConnectionType = 0
CommitMode = 2
ExtendedDynamic = 0
DefaultPkgLibrary = QGPL
DefaultPackage = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression = 0
MaxFieldLength = 32
BlockFetch = 1
BlockSizeKB = 128
ExtendedColInfo = 0
LibraryView = 0
AllowUnsupportedChar = 0
ForceTranslation = 0
Trace = 0
odbcinst.ini_
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1
[iSeries Access ODBC Driver]
Description = iSeries Access for Linux ODBC Driver
Driver = /opt/ibm/iSeriesAccess/lib/libcwbodbc.so
Driver64 = /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
Setup = /opt/ibm/iSeriesAccess/lib/libcwbodbcs.so
Setup64 = /opt/ibm/iSeriesAccess/lib64/libcwbodbcs.so
UsageCount = 1
CPTimeout =
CPReuse =
System = 172.18.3.2
User = inf5mito
Password = lonco3pue
NOTE1 = If using unixODBC 2.2.11 or later and you want the 32 and 64-bit ODBC drivers to share DSN's,
NOTE2 = the following Driver64/Setup64 keywords will provide that support.
Threading = 2
DontDLClose = 1
ODBC Driver_
-bash-3.2$ cd /opt/ibm/iSeriesAccess/lib
-bash-3.2$ ls -ltr
total 2260
-r-xr-xr-x 1 root root 443939 Apr 5 2008 libcwbxda.so
-r-xr-xr-x 1 root root 94504 Apr 5 2008 libcwbrc.so
-r-xr-xr-x 1 root root 16636 Apr 5 2008 libcwbodbcs.so
-r-xr-xr-x 1 root root 729572 Apr 5 2008 libcwbodbc.so
-r-xr-xr-x 1 root root 998060 Apr 5 2008 libcwbcore.so
and this is my error.
SQL> /
select from display@db2database*
ERROR en línea 1:
ORA-28500: la conexión de ORACLE a un sistema no Oracle ha devuelto este
mensaje:
*[Generic Connectivity Using ODBC][C077] Could not find symbol 'SQLAllocConnect'*
in dynamic library
*[C079] Failed to load dynamic library*
*'/opt/ibm/iSeriesAccess/lib/libcwbodbc.so'*
ORA-02063: 3 lines precediendo a DB2DATABASE
Edited by: user6669081 on 07-jul-2010 6:31 -
Bug in JOIN syntax? (oracle 9i)
Hi,
take these three tables:
MASTER (id NUMBER, name VARCHAR2(10))
DETAIL (id NUMBER, master_id NUMBER)
SUBDETAIL (id NUMBER, detail_id NUMBER, name VARCHAR(10)
When I perform this query:
SELECT SUBDETAIL.id as did, MASTER.id as mid
FROM SUBDETAIL
JOIN DETAIL ON (SUBDETAIL.detail_id = DETAIL.id)
JOIN MASTER ON (DETAIL.master_id = MASTER.id)
WHERE
name = 'joe';
I would expect the parser to give me 'column ambiguously defined' (because the 'name' field from the whereclause is defined in both subdetail and master).
However, it does not say that. Instead, it assumes that it should use the name field from master. This is confusing, as this could easily lead to mistakes (as it did in my application)
Greetings,
IvoThere seems to be a difference between the way Oracle resolves column names using the ANSI join syntax and Oracle's syntax. It appears that Oracle does not know about the columns, until it processes each join, and further, the last table joined seems to be sued to resolve nameing conflicts. Consider:
SQL> SELECT * FROM master;
ID NAME
1 joe
SQL> SELECT * FROM subdetail;
ID DETAIL_ID NAME
1 2 fred
SQL> SELECT * FROM detail;
ID MASTER_ID
2 1
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM subdetail
3 JOIN detail ON (subdetail.detail_id = detail.id)
4 JOIN master ON (detail.master_id = master.id)
5 WHERE name = 'joe';
DID MID
1 1
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM subdetail
3 JOIN detail ON (subdetail.detail_id = detail.id)
4 JOIN master ON (detail.master_id = master.id)
5 WHERE name = 'fred';
no rows selected
So, it is clearly going after master.name. However,
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM detail
3 JOIN master ON (master.id = master_id)
4 JOIN subdetail ON (subdetail.detail_id = detail.id)
5 WHERE name = 'joe'
no rows selected
But,
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM detail
3 JOIN subdetail ON (subdetail.detail_id = detail.id)
4 JOIN master ON (master.id = master_id)
5 WHERE name = 'joe'
DID MID
1 1
Old style syntax gives:
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM subdetail, detail, master
3 WHERE subdetail.detail_id = detail.id and
4 detail.master_id = master.id and
5 name = 'joe';
name = 'joe'
ERROR at line 5:
ORA-00918: column ambiguously defined
and note that
SQL> SELECT subdetail.id AS did, master.id AS mid
2 FROM subdetail
3 JOIN master ON (detail.master_id = master.id)
4 JOIN detail ON (subdetail.detail_id = detail.id)
5 WHERE name = 'joe'
JOIN master ON (detail.master_id = master.id)
ERROR at line 3:
ORA-00904: invalid column nameSo, in ANSI syntax, order matters, and whatever the syntax good testing matters.
TTFN
John -
How to write this sql query to oracle
Hi sir,
i am using one query in my sql stored procedure that is:
select @maxtime=CONVERT(Time,Out_Time+DATEADD(n,60,0)) from shift where Shift_Code = @ShiftCode
so here i am getting this value 01/01/1900 12:00 AM
the same i used in oracle my query is :
to_char(Out_Time,'1900-01-01' + 0/(24*60),'DD/MM/YYYY HH:MI AM')
INTO v_maxtime
FROM shift
WHERE Shift_Code = v_ShiftCode;
but getting error that is: Encountered the symbol INTO when expecting one of the following :=(%;
am i doing any thing wrong.
thanksAPC wrote:
The error you're getting is a syntax error. In this case because you've mangled the TO_CHAR syntax. Alas I cannot give you the correct version because I cannot unpick what you're trying to do with that statement.
It would be easier if you expalined what business logic you're trying to implement instead of asking us to interpret a piece of shonky SQL.It's yet another of the OP's questions about how to do DATEs in Oracle (so many threads it can get very confusing - even though the OP has been asked to stick to one thread!).
The code looks like it's based on the answer I gave here:
How to get exact query of sql in oracle?
but clearly he doesn't understand the basic syntax of Oracle or the datatypes he's using. Sometimes you just have to give up... (I know I have) -
Help with translating SQL query from SQL Server syntax to Oracle syntax
Hi,
is it someone that can help me translate following SQL query from SQL Server syntax to Oracle syntax.
SELECT ID,
[LMT(MTR)] = MAX(case when TYPE = 'LMT' then VALUE end),
[AAD(KGM)] = MAX(case when TYPE = 'AAD' then VALUE end),
[VOL(MTQ)] = MAX(case when TYPE = 'VOL' then VALUE end)
FROM yourtable
GROUP BY ID
Your help is highly appreciated, thanks in advance.Like this,
SELECT ID,
MAX(case when TYPE = 'LMT' then VALUE end) LMT_MTR,
MAX(case when TYPE = 'AAD' then VALUE end) AAD_KGM ,
MAX(case when TYPE = 'VOL' then VALUE end) VOL_MTQ
FROM yourtable
GROUP BY ID-Arun -
Query DB2 tables from oracle using normal view
This is with regard to querying db2 tables using oracle views. The view is created using dblink. The querying is not an one time activity.querying will be done once in a day. Can i use normal view (will it work ) or should i use materialised view. will i be able to view the added records in db2 table using normal view?
thanks,
vinodhVinodh2 wrote:
This is with regard to querying db2 tables using oracle views. The view is created using dblink. The querying is not an one time activity.querying will be done once in a day. Can i use normal view (will it work ) or should i use materialised view. will i be able to view the added records in db2 table using normal view?How can the SQL select statement via a dblink not work for a view, but the same SQL select statement work for a materialised view?
Do you think the database link or remote database care whether the select SQL that hits it, comes from a PL/SQL procedure, a view, a materialised view, a job or whatever else? It has no idea what/who is behind that select SQL - and nor does it care.
As for the benefits of a view vs. a materialised view - that depends on the requirements for needing to use that foreign database's data in the local database. -
Need to find out a way to figure out how DB2 connect to Oracle and data mirroring etc.
Hi, Gurus,
I just take over a project which source is ICOMS as400 db2 database. Seems data mirro CDC is used to replicate from DB2 to oracle.
I am very new to this datamirror CDC , plus I am new to figure out how db2 connect to oracle, is that through db link or what? or is there tnsnames entry?
I would like anybody in this forum can point me to the right direction.
Thanks in advance.user9233598, if mirroring/replication from DB2 to Oracle already exists then question is what product is being used? If the product has already been purchased then I do not think it is very likely that management is going to want to purchase another product so I do not see how extra-cost Golden Gate or other Oracle Gateway features apply if those are not currently in use. If Golden Gate or the Oracle Transparent Gateway are in use then you already have your answer
Oracle supports ODBC/JODBC and the replication application on the AS400 likely uses these features or a thick Oracle client as the interface to Oracle.
HTH -- Mark D Powell -- -
DB2 timestamp to oracle timestamp conversion
Does any one know how to convert Db2 timestamp into oracle timestamp.
From DB2 we are getting timestamp in this format (2000-03-06-16.02.19.074474) (26 bytes).
I want to insert this into oracle thru owb into oracle table with column type timestamp.
Does anyone know the procedure for this type of conversion
Thanks in advance..Hi,
Try a migration tool at www.ispirer.com/chyfo.html
It provides you the fastest, the easiest and the most powerful way to migrate
DB2 database into Oracle.
It works in conjunction with Oracle SQL Loader. The tool creates text files (moving of LOBs are fully supported), generates
CREATE TABLE scripts for Oracle and control files for SQL Loader.
The tool has a lot of other features.
Best regards, Dmitry.
null -
I have OSX 10.7.5. I loaded Powerschool, this sent me to oracle to load java 7, now powerschool won't laod, java 7 logo just spins. I contacted orgacle live help, said it was a mac problem that they could fix for $75. Any help would be wonderful. MT
Pearson put out a tech note on this today - the new versions of Java are what's causing the problem. If you can use Time Machine to rollback java prior to a java 7 or 1.6.0_37 version that will get you going again. I've been searching for hours for a place to download the older version but it seems Apple's site and Oracle all only have the latest release. Still trying to see if I have a copy downloaded on a system that hasn;t been updated to copy off to a network drive or usb and install the older version on to systems.
PowerSchool Tech Notes
PowerTeacher Gradebook and recent Mac OS X Java update
An update to Java for Mac OS X was released on October 16, 2012. An issue has been identified with this Java update (Java for OS X 2012-006) which prevents teachers from launching PowerTeacher Gradebook.
Teachers using PowerTeacher Gradebook should avoid taking this Java update to version 1.6.0_37 until notified that PowerTeacher Gradebook has been certified with this latest version of Java 1.6 for Mac OS X. PowerTeacher Gradebook will continue to work on Mac OS X workstations with Java version 1.6.0_35.
Additional communication will be provided once a workaround is identified or an updated version of PowerTeacher Gradebook is available. -
I am practicing Triggers in SQL Server 2012. Please help me correct this Trigger Syntax for this practice question below.
Build a trigger on the emp table after insert that adds a record into the emp_History table and marks IsActive column to 1
CREATE TRIGGER trgAfterInsert ON [dbo].[emp_triggers]
FOR INSERT
AS
declare @empid int;
declare @empname varchar(100);
declare @isactive int;
select @empid=i.empid from inserted i;
select @empname=i.empname from inserted i;
set @isactive= 1;
insert into emphistory
(empid, empname)
values(@empid, @empname, @isactive) ;
PRINT 'AFTER INSERT trigger fired.'Your trigger does not work if an insert statement inserts multiple rows into your emp_triggers table. Never write triggers that only work correctly when 1 row is inserted, updated, or deleted by one command. You want
CREATE TRIGGER trgAfterInsert ON [dbo].[emp_triggers]
FOR INSERT
AS
insert into emphistory
(empid, empname, isactive)
select empid, empname, 1 from inserted ;
which will work correctly no matter how many rows (0, 1, or many) are inserted by one INSERT command.
Tom -
What is the non-recursive stack based equivalent of this function?
what is the non-recursive stack based equivalent of this function?
static void _try (int n)
int i; if (n==4) print(); else for (i=0; i<4; i++) if (is_free(i,n)) {
x[n] = i;
_try(n+1);
}It goes infinite no output. Thanks though.
public class CopyOfDamen { // x[i] = x coordinate of queen in row i.
static int N = 4; static Stack stack = new Stack(); static int [] x = new int[8]; public static void main(String [] par) { _try(); }
// prints field
static void print ()
int i,j;
System.out.print ("+----------------+\n");
for (i=0; i<8; i++) {
System.out.print ("|");
for (j=0; j<8; j++)
if (j==x) System.out.print ("<>"); else System.out.print (" ");
System.out.print ("|\n");
System.out.print ("+----------------+\n\n");
// tests, whether (ix, iy) is beaten by queens 0...(iy-1)
static boolean is_free (int ix, int iy)
int i;
for (i=0; i<iy; i++)
if ((x[i]==ix) || (Math.abs(x[i]-ix)==Math.abs(i-iy))) return false;
return true;
// tries to place queen n on row n
static void _try () {
int i = 0, n = 0;
call:
for(;;) { // forever
if (n == N) {
print();
} else {
for (;i < N; i++) {
if (is_free(i,n)) {
x[n] = i;
System.out.print(x[n] + " ");
n++;
stack.push(i);
i = 0;
continue call; // call _try (but first save state and initiate new state)
} System.out.println();
// _try returns (check termination criterion and restore state)
n--;
if (n < 0) break; // terminate
i = stack.pop();
} class Stack {
int StackSize = 32, top = 0; int [] stack = new int[StackSize]; public Stack() {} void push(int x) { if (top < StackSize) stack[top++] = x; } int pop() { if (top >= 1) return stack[--top]; return -1; } -
How do I write this SQL command in Oracle
Hi all
I wriote this SQ L statement in Ms SQL Server. How do I write this sql command in Oracle?
ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
I am very interested in this part:
SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007
thanks
Edited by: user631364 on Oct 27, 2008 8:25 AM
Edited by: user631364 on Oct 27, 2008 8:26 AM
Edited by: user631364 on Oct 27, 2008 8:27 AMThank you!!
Now let me aslk the second part of my question.
This sql command:
ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
was created with this query in SQL Server and then I saved it in a store procedure, that I scheduled to run montlhy
SET ANSI_NULLS ON
DECLARE @SQLString NVARCHAR(4000)
/* Build the SQL string once.*/
SET @SQLString = 'ALTER VIEW dbo.Consumption AS SELECT TOP 100 PERCENT ID, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
"'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 12) +
"'" +
' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
dbo.CONMonthInEnglish(getdate(), month(getdate()) - 12) +
… (GOES FROM current month -12 to current month -1)
, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
"'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 1) +"'" +
' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
dbo.CONMonthInEnglish(getdate(), month(getdate()) - 1) +
' FROM dbo.MasterConsumption WHERE YEAR_MONTH >= ' +
"'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-12 ) +"'" +
' AND YEAR_MONTH <= ' +
"'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-1 ) +"'" +
' GROUP BY ID ORDER BY ID '
EXEC sp_executesql @SQLString
Is that something that can be done in Oracle in the same way?
Do you use another approach?
please advice
Edited by: user631364 on Oct 27, 2008 10:19 AM
Edited by: user631364 on Oct 27, 2008 10:21 AM
Edited by: user631364 on Oct 27, 2008 10:21 AM
Edited by: user631364 on Oct 27, 2008 10:22 AM
Edited by: user631364 on Oct 27, 2008 10:23 AM
Edited by: user631364 on Oct 27, 2008 10:23 AM
Edited by: user631364 on Oct 27, 2008 10:24 AM -
Hi, Could you please let me know what is the EQUIVALENT for this code. This code replace 2 number of 0s or 1s to Just one 0 or 1. The code is very very slow when the input string is very big. Is there any way to replace it with something faster.
Thanks
Attachments:
Untitled 1.vi 7 KBThis code takes 1ms to run on a string of 60,000 characters (one continuous string of 0's and 1's). Whereas using your code, it takes about 900ms for the same string.
-
Migration map from DB2 MVS to oracle
Hi there,
I am looking for more details for OMWB,
if it could be used to migrate from DB2 MVS to oracle,
and especially concerned about the mapping procedure,
also concerned about volume and speed as for about millions of records /rows are involved.
How much the OMWB can help?
Please help.......:~
Thanks
and regards.Hi there,
Thank you very much for your reply,
also,
can the OMWB for DB2/400 also works for DB2/MVS?
is there utility in OMWB exists for the mapping procedure?
thanks a lot.
Maybe you are looking for
-
How do I move Lookout 5 w/ Fieldpoint 3 to a new PC
I want to move my install of Lookout 5 from an old, slow computer to a newer, faster one. Both machines run Windows 2000 SP4. I have a clean install of Lookout 5 and Fieldpoint 3 on the new machine, and the old machine still works and is running on t
-
BPM - Unable to generate message from BPM in PI
Hello Experts, I am using a test scenario using BPM which has only two steps Receive and Send step. The scenario flow looks like File-> BPM-> ECC. File posted from the external file system is picked up by PI processed successfully and sent to teh In
-
hi i am trying to digitise some footage off a hi 8 camera through a canopus device and it has stopped capturing the audio for some reason, it did do with and earlier batch, but for some reason it has stopped? Is there any settings i could look at? ch
-
If I understand it correctly, to use contains(text_col, ...) or catsearch(text_col, ...) in a WHERE clause, the "text_col" column must first carry an index on it. Is this correct? Another thing, this source:"http://www.dba-oracle.com/oracle_tips_like
-
Error in web reports (Report 10g r2)
Hi, I am working on Developer 6i and has started learning 10g. I created a web report.If i run it in there is an error in web report. 500 Internal Server Error OracleJSP: oracle.jsp.provider.JspCompileException: Errors compiling:C:\Users\USER\AppData