Skip Weekends when Inserting Date Ranges
I am working on an application where I am populating a
database with a date range based on a start date and an end date.
The user enters the start and end dates, submits the form, and then
I want to populate the database with all of the dates in the range,
including the start date and the end date. This piece is working
fine. The problem I'm having is, I cannot figure out a way to skip
weekends and populate ONLY weekdays. Can anybody help???
The functions DayofWeek or DayOfWeekAsString will identify
the weekends for you.
Similar Messages
-
Error when selecting date range in query designer
hi all,
when iam trying to select date range in query designer like 01.04.2009 to 10.04.2009 it has to select only that dates where as it is selecting all the dates in between those like 010.04.2009,01.03.2009,01.02.2009.why this is happening ,iam unable to understand.plzz help me in this issue.
Vamshi D Krishnahi ,
i have created a variable as you told but no use.still i have to select the dates manuallyone after the other.for more user friendly can i have a calander where i can select date ranges.is it posible to have calander for selecting date ranges instead selecting dates one by one,if posible i request you to give the detailed steps.plzz guide me in this issue.thanks in advance.
Vamshi D Krishna -
Capture dates (other than weekends) given a date range
I have the following code where I'm trying to capture the dates, which fall within the entered range. The code in the default condition is not working. I'm trying to get the date in yyyy-MM-dd format and store it in an array. What am I going wrong ? Thanks.
int days = 1;
java.sql.Date date_array[];
while ( beginCalendar.before(endCalendar) ) {
switch(beginCalendar.get(Calendar.DAY_OF_WEEK))
case Calendar.SATURDAY:
break;
case Calendar.SUNDAY:
break;
default:
java.util.Date dt = sdf.parse(beginCalendar.get(Calendar.DATE));
java.text.SimpleDateFormat sql_sdf =
new java.text.SimpleDateFormat("yyyy-MM-dd");
java.sql.Date sql_dt = java.sql.Date.valueOf(sql_sdf.format(dt));
date_array[days] = dt;
days++;
beginCalendar.add(Calendar.DATE, 1);
}Oooops, I sent the wrong version.....sorry about that. This is what it looks like currently. What I'm doing is creating and comparing two calendars, created from a beginning and ending date range. I'm computing the number of elapsed days, not including Saturday and Sunday. I'm trying to add code, in BOLD, to capture the dates found in the range entered. I don't want to have to code three integers to pick up the year, month and day and use parseInt to concat them together...blah, blah, blah. I would like to just use SimpleDateFormat to capture the entire date in yyyy-MM-dd sql date format and load them into an array. Any suggestions ?
while ( beginCalendar.before(endCalendar) ) {
switch(beginCalendar.get(Calendar.DAY_OF_WEEK))
case Calendar.SATURDAY:
break;
case Calendar.SUNDAY:
break;
default:
int day = (beginCalendar.get(Calendar.DATE));
int month = (beginCalendar.get(Calendar.MONTH)+1);
int year = (beginCalendar.get(Calendar.YEAR));
java.text.SimpleDateFormat sql_sdf =
new java.text.SimpleDateFormat("yyyy-MM-dd");
// java.sql.Date sql_dt = java.sql.Date.valueOf(sql_sdf.format(dt));
// date_array[days] = sql_dt;
days++;
beginCalendar.add(Calendar.DATE, 1);
} -
ORA-14400 error when inserting data in partition
I have a partiotioned table with 20 columns .. out of 20, I have only one defined as not null..
So when I tried inserting the data in the column alone am getting the error :
ORA-14400: inserted partition key does not map to any partition
this is the structure of the table :
partition :
PARTITION BY RANGE (TRANSDATE)
PARTITION DEC200801 VALUES LESS THAN (TO_DATE(' 2008-12-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION DEC200802 VALUES LESS THAN (TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION JAN200901 VALUES LESS THAN (TO_DATE(' 2009-01-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION JAN200902 VALUES LESS THAN (TO_DATE(' 2009-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION FEB200901 VALUES LESS THAN (TO_DATE(' 2009-02-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION FEB200902 VALUES LESS THAN (TO_DATE(' 2009-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION MAR200901 VALUES LESS THAN (TO_DATE(' 2009-03-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION MAR200902 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
PARTITION APR200902 VALUES LESS THAN (TO_DATE(' 2009-04-30 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOGGING
NOCOMPRESS
TABLESPACE CALLST03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
What could be the reason ?
KaiFrom metalink
Oracle 9i Message~~~~~~~~~~~~~~~~~
Error: ORA-14400 (ORA-14400)
Text: inserted partition key does not map to any partition
Cause: An attempt was made to insert a record into, a Range or Composite
Range object, with a concatenated partition key that is beyond the
concatenated partition bound list of the last partition -OR- An
attempt was made to insert a record into a List object with a
partition key that did not match the literal values specified for
any of the partitions.
Action: Do not insert the key. Or, add a partition capable of accepting
the key, Or add values matching the key to a partition
specification
>
So check the date .
What is your insert statement.
Anand
Edited by: Anand... on Mar 4, 2009 5:42 PM -
Disk throughput drops when inserting data packages in write-optimized DSO
Hi all,
we are currently testing our new freshly installed SAN.
To see the performance gain in BI, I'm currently doing some test loads.
And during the monitoring of those loads, I noticed something I'd like someone to explain :-):
I execute a DTP from PSA to a write-optimized DSO.
The n° of parallel processes = 9
Update method = serial extraction, immediate parallel processing
N° of records transferred: +23.000.000
Ok, in the first phase (read the PSA) only one process is used (serial extraction). When I look in OS07, I notice we have very good throughput: +66.000 TransfKB/s. Very nice!
But as soon as BI starts inserting the data packages, and parallel processing kicks in, the throughput drops to 4K or something, and sometimes we get 20K at max. That's not too good.
We have a massive SAN , but the BI system does not seem to use it?
I was wondering why this is the case. I already toyed around with the package size, but it's always the same.
Also I noticed that the allocated processes don't seem to be active. I allocated 9 BTC processes to this load.
They are all used, but we only see 3 inserts at the same time, max. Also in the DTP-monitor, only 3 packages are processed at the same time. As it's a write-optimized DSO, RSODSO_SETTINGS does not apply I presume.
Any ideas?
tnx!Hi,
can you pls try to give some filetr in DTP and try to pull the data.
I am not sure why first data package is taking long time and otehr data package is taking less time..
Do you have any start routine..If datapak = 1.. the do this logic..
Pls check..
regards
Gopal -
ORA-30931 (again) when inserting data in XMLType table
Hi,
I've created a table by registrating an XML Schema in the database.
The schema is the following :
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xsd:element name="Customer" type="customerType" xdb:defaultTable="CUSTOMER"/>
<xsd:complexType name="customerType" xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element name="NAME" type="xsd:string" xdb:SQLName="NAME" xdb:SQLType="VARCHAR2"/>
<xsd:element name="EMAIL" type="xsd:string" xdb:SQLName="EMAIL" xdb:SQLType="VARCHAR2"/>
<xsd:element name="ADDRESS" type="xsd:string" maxOccurs="unbounded" xdb:SQLName="ADDRESS" xdb:SQLCollType="ADDRESS_TYPE" xdb:SQLType="VARCHAR2" xdb:maintainOrder="false"/>
<xsd:element name="PHONE" type="phoneType" xdb:SQLName="PHONE"/>
<xsd:element name="DESCRIPTION" type="contentType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="contentType" xdb:SQLType="CLOB" xdb:maintainDOM="true">
<xsd:sequence>
<xsd:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="phoneType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\\(\\d\{3\}\\)\\d\{3\}-\\d\{4\}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Now when I try to do an insert in the table and use mixed case in the contents of the description tag I get an ORA-30931.
Anybody got a clue why?
Thanks for your help!
KrisKris
xsd:any does not allow text() nodes outside of elements, it only allows child elements. If you want to add text() nodes outside of child elements this is mixed text. To get this you want to add mixed="true" to the complexType definition
contentType
SQL> begin
2 dbms_xmlschema.registerSchema('http://localhost:8085/public/customer_simple_ann.xsd',
3 xmltype('<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracl
e.com/xdb" xdb:storeVarrayAsTable="true">
4 <xsd:element name="Customer" type="customerType" xdb:defaultTable="CUSTOMER"/>
5 <xsd:complexType name="customerType" xdb:maintainDOM="false">
6 <xsd:sequence>
7 <xsd:element name="NAME" type="xsd:string" xdb:SQLName="NAME" xdb:SQLType="VARCHAR2"/>
8 <xsd:element name="EMAIL" type="xsd:string" xdb:SQLName="EMAIL" xdb:SQLType="VARCHAR2"/>
9 <xsd:element name="ADDRESS" type="xsd:string" maxOccurs="unbounded" xdb:SQLName="ADDRESS" xdb:S
QLCollType="ADDRESS_TYPE" xdb:SQLType="VARCHAR2" xdb:maintainOrder="false"/>
10 <xsd:element name="PHONE" type="phoneType" xdb:SQLName="PHONE"/>
11 <xsd:element name="DESCRIPTION" type="contentType"/>
12 </xsd:sequence>
13 </xsd:complexType>
14 <xsd:complexType mixed="true" name="contentType" xdb:SQLType="CLOB" xdb:maintainDOM="true">
15 <xsd:sequence>
16 <xsd:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
17 </xsd:sequence>
18 </xsd:complexType>
19 <xsd:simpleType name="phoneType">
20 <xsd:restriction base="xsd:string">
21 <xsd:pattern value="\\(\\d\{3\}\\)\\d\{3\}-\\d\{4\}"/>
22 </xsd:restriction>
23 </xsd:simpleType>
24 </xsd:schema>'));
25 end;
26 /
PL/SQL procedure successfully completed.
SQL> insert into customer
2 values (XMLTYPE('<Customer><NAME>Steve Joes</NAME><EMAIL>[email protected]</EMAIL><ADDRESS
Somewhere, Sometown, RedWood Shores, California</ADDRESS><PHONE>6505678546</PHONE><DESCRIPTION>Hes the man</DESCRIPTION></Customer>').CreateSchemaBasedXML('http://localhost:8085/public/customer_simpl
e_ann.xsd'))
3 /
1 row created.
SQL> -
when I try to insert some data using XSQL's <insert-request> I get this message:
Exception 'java.sql.SQLException:Non supported character set: oracle-character-set-170' encountered during processing ROW element 0All prior XML row changes were rolled back. in the XML document.
my database is using CROATIAN_CROATIA.EE8MSWIN1250
please tell my why?
thanks
nullsource xml
<?xml version="1.0"?>
<dokument id="">
<broj>100006</broj>
<datum>13.02.2001</datum>
<partner>
<par_id>1</par_id>
<sifra>00001</sifra>
<naziv>Ritam d.o.o.</naziv>
</partner>
<stavka id="">
<flag>
</flag>
<art_id>1</art_id>
<sifra>00001</sifra>
<barcode>1234567890123</barcode>
<naziv>phf
PHF</naziv>
<kolicina>2,00</kolicina>
<cijena>222,00</cijena>
</stavka>
<stavka id="">
<flag>
</flag>
<art_id>2</art_id>
<sifra>00002</sifra>
<barcode>12345678</barcode>
<naziv>artikal 1</naziv>
<kolicina>1,00</kolicina>
<cijena>111,00</cijena>
</stavka>
</dokument>
insert.xsql
<?xml version="1.0" encoding="windows-1250" ?>
<xsql:insert-request xmlns:xsql="urn:oracle-xsql" connection="baza817"
table="dokument_ov" transform="insert.xsl" date-format="dd.MM.yyyy"/>
insert.xsl
<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"/>
<xsl:template match="/">
<rowset>
<xsl:for-each select="//dokument">
<row>
<dok_id><xsl:value-of select="@id"/></dok_id>
<broj><xsl:value-of select="broj"/></broj>
<datum><xsl:value-of select="datum"/></datum>
<partner>
<par_id><xsl:value-of select="./partner/par_id"/></par_id>
<sifra><xsl:value-of select="./partner/sifra"/></sifra>
<naziv><xsl:value-of select="./partner/naziv"/></naziv>
</partner>
<stavke>
<xsl:for-each select="//stavka">
<stavke_item>
<kolicina><xsl:value-of select="translate(kolicina,',','.')"/></kolicina>
<cijena><xsl:value-of select="translate(cijena,',','.')"/></cijena>
<sta_id><xsl:value-of select="@id"/></sta_id>
<artikal>
<art_id><xsl:value-of select="art_id"/></art_id>
<sifra><xsl:value-of select="sifra"/></sifra>
<barcode><xsl:value-of select="barcode"/></barcode>
<naziv><xsl:value-of select="naziv"/></naziv>
</artikal>
</stavke_item>
</xsl:for-each>
</stavke>
</row>
</xsl:for-each>
</rowset>
</xsl:template>
</xsl:stylesheet>
dokument_ov
create or replace view dokument_ov as
select d.dok_id, d.broj, d.datum, partner_ty(p.sifra,p.naziv,p.par_id) partner,
cast(
multiset(select s.kolicina, s.cijena, s.sta_id,
artikal_ty(a.sifra, a.barcode, a.naziv, a.art_id) artikal
from stavke s, artikli a
where a.art_id = s.art_id and s.dok_id = d.dok_id order by sta_id) as stavke_ty
) stavke
from dokumenti d, partneri p
where d.par_id=p.par_id(+)
order by dok_id
dokument_ov_ins
create or replace trigger dokument_ov_ins
instead of insert on dokument_ov
for each row
declare
m_stavke_t stavke_ty;
m_stavka_t stavka_ty;
m_artikal_t artikal_ty;
m_partner_t partner_ty;
m_par_id NUMBER;
m_dok_id NUMBER;
m_sta_id NUMBER;
m_art_id NUMBER;
begin
if :new.dok_id < 0 then
delete from stavke where dok_id = abs(:new.dok_id);
delete from dokumenti where dok_id = abs(:new.dok_id);
else
m_partner_t := :new.partner;
--dokument
begin
select dok_id into m_dok_id from dokumenti where dok_id = :new.dok_id;
update dokumenti set broj = :new.broj, datum = nvl(:new.datum,sysdate), par_id = m_partner_t.par_id
where dok_id = :new.dok_id;
exception
when no_data_found then
insert into dokumenti(tip, broj, datum, dok_id, par_id)
values('1', :new.broj, nvl(:new.datum,sysdate), dok_seq.nextval, m_partner_t.par_id)
returning dok_id into m_dok_id;
end;
--stavke
m_stavke_t := :new.stavke;
for i in 1..m_stavke_t.count loop
m_stavka_t := m_stavke_t(i);
m_artikal_t := m_stavka_t.artikal;
begin
if m_stavka_t.sta_id < 0 then
delete from stavke where sta_id = abs(m_stavka_t.sta_id);
else
select sta_id into m_sta_id from stavke where sta_id = m_stavka_t.sta_id and dok_id = m_dok_id;
update stavke set kolicina = m_stavka_t.kolicina, cijena = m_stavka_t.cijena
where sta_id = m_stavka_t.sta_id and dok_id = m_dok_id;
end if;
exception
when no_data_found then
insert into stavke(dok_id, sta_id, kolicina, cijena, art_id)
values (m_dok_id, sta_seq.nextval, m_stavka_t.kolicina, m_stavka_t.cijena, m_artikal_t.art_id);
end;
end loop;
end if;
end dokumentview_ins;
null -
SQL API. Database corrupted when inserting data?
Hi, I have a working sqlite application I was going to migrate to BerkeleyDB to try and solve some locking issues. However I am having some trouble creating the database.
I downloaded the windows pre-built binaries and created my schema with dbsql.exe. The DDL worked fine and running db_verify reported no errors. However after I inserted about twenty rows of data using a SQL script of INSERT commands db_verify reported about ten "out-of-order key" messages. There are no INSERT triggers in the DDL. I tried running the INSERTs as single commands, and the out-of-order key messages appeared after about ten rows of data. A bit of googling only revealed that these errors often occur when using tools linked to different BerkelyDB versions. I have never had any version of BerkeleyDB installed before.
I then downloaded the BerkeleyDB source and built the binaries myself. I again created the schema - no problems, inserted about twenty rows - errors the same as before. When running db_recover the error messages are as below:
C:\Program Files (x86)\Oracle\Berkeley DB 11gR2 5.1.25\bin\SFTPVT.BDB-journal>..\db_recover.exe
db_recover.exe: Ignoring log file: log.0000000001: magic number 1563f1a3, not 40988
db_recover.exe: Invalid log file: log.0000000001: Invalid argument
db_recover.exe: PANIC: Invalid argument
db_recover.exe: process-private: unable to find environment
db_recover.exe: DB_ENV->open: DB_RUNRECOVERY: Fatal error, run database recovery
I thought the issues might be because I use encrypted database but the same things happen whether I use PRAGMA key="****************" in my scripts or not. I haven't played with DB_CONFIG - should I be creating a DB_CONFIG yet?
I'm using Win 7 pro (x64), i5 processor with 8GB RAM, disks are a RAID10 array formatted as NTFS. Same errors occur if I try to create the database on a FAT32 USB key so it's probably not a filesystem problem. I used Visual Studio 10 and MSVCRT version 10 when building binaries myself. I notice the downloaded binaries were built against MVCRT version 8, so the problem doesn't look tied to the version of the VC runtime as it occurs on multiple versions.
Can anybody help please? I would like to try BerkeleyDB but can't get past the first hurdle.
Edited by: 856299 on 03-May-2011 10:46Hello,
If you can provide a small stand-alone program to reproduce the problem along with the steps to reproduce it, I will give it a try.
Thank you,
Sandra -
Error Message When Inserting Data Into Table
Hi,
I am trying to insert the following value into my customer table, however i get the following error on doing so.
ERROR: date format picture ends before converting entire input string
STATEMENT:
insert into phonecall (start_date_time)
values(10-JAN-2006 11:53:09)
any ideas as to what might be wrong with my insert statement to bring up this error ??
start_date_time is a DATE field by the way.Or
SQL> alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS';
Session altered.
SQL> create table aa (test date)
2 /
Table created.
SQL> insert into aa values ('11-12-2006 12:11:22')
2 /
1 row created.
SQL> select * from aa ;
TEST
11-12-2006 12:11:22
SQL> -
Error when insert data in Sql Server table(DateTime data type)
Hello all,
I have created a database link in oracle 11g to SQL Server 2008 using Sqlserver gateway for oracle,Oracle run on Linux and SQL Server run on Windows platform.
I have queried a table and it fetches rows from the target table.
I am using this syntax for insert a row in Sql Server table.
Insert into Prod@sqlserver (NUMITEMCODE, NUMPREOPENSTOCK, NUMQNTY, NUMNEWOPENSTOCK, DATPRODDATE , TXTCOMPANYCODE, "bolstatus", NUMRESQNTY )
Values (1118 , 1390.0 , 100.0 ,1490 , '2012-06-23 12:37:58.000','SFP' ,0 , 0 );
but it give me error on DATPRODDATE,The data type of DATPRODDATE column in Sql Server is DATETIME.
My Question is how can i pass the date values in INSERT statement for Sql Server DateTime data type.
RegardsJust as with Oracle, you have to specify the date using the to_date() function or use the native date format for the target database (if you can figure out what that is). This is good practice anyway and a good habit to get into.
-
Best Practice for ViewObjects when inserting data through pl/sql procedure
My applications is oracle form based enterprise level application and we are now developing new module in ADF 11g but there is restriction that all data insertion, updation, and deletion will be through oracle pl/sql procedures. Now my question is that adf pages should be binded with ViewObjects based on Entity Object or with Viewobjects not based on Entity / sql query. Currently I have developed pages with programmatic ViewObjects which are neither based on Entity Objects nor on sql query. In those view objects, i create transient attributes and then used it to create adf pages. Then on save, i extract the data from ViewObject's current row and pass it to procedure. This is working fine but just wondering whether this approach is ok or there is better alternative for that. Ideally i want to create ViewObjects based on EntityObject but don't finding any way to synchronize entityObjects with data inserted through procedures.
Hi,
I create a EO for the Database-View and override the doDML()-Method. For insert/update and delete I call the pl/sql-functions.
See "38.5 Basing an Entity Object on a PL/SQL Package API" in Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development
Framework. -
Poor query performance when using date range
Hello,
We have the following ABAP code:
select sptag werks vkorg vtweg spart kunnr matnr periv volum_01 voleh
into table tab_aux
from s911
where vkorg in c_vkorg
and werks in c_werks
and sptag in c_sptag
and matnr in c_matnr
that is translated to the following Oracle query:
SELECT
"SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN 20101201 AND 20101231 AND "MATNR" BETWEEN 000000000100000000 AND 000000000999999999;
Because the field SPTAG is not enclosed by apostropher, the oracle query has a very bad performance. Below the execution plans and its costs, with and without the apostrophes. Please help me understanding why I am getting this behaviour.
##WITH APOSTROPHES
SQL> EXPLAIN PLAN FOR
2 SELECT
3 "SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN '20101201' AND '20101231' AND "MATNR" BETWEEN '000000000100000000' AND '000000000999999999';
Explained.
SQL> SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
PLAN_TABLE_OUTPUT
Id
Operation
Name
Rows
Bytes
Cost (%CPU)
0
SELECT STATEMENT
932
62444
150 (1)
1
TABLE ACCESS BY INDEX ROWID
S911
932
62444
149 (0)
2
INDEX RANGE SCAN
S911~VAC
55M
5 (0)
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("VKORG"='D004' AND "SPTAG">='20101201' AND
"SPTAG"<='20101231')
2 - access("MANDT"='003' AND "MATNR">='000000000100000000' AND
"MATNR"<='000000000999999999')
##WITHOUT APOSTROPHES
SQL> EXPLAIN PLAN FOR
2 SELECT
3 "SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" , "PERIV" , "VOLUM_01" ,"VOLEH" FROM SAPR3."S911" WHERE "MANDT" = '003' AND "VKORG" = 'D004' AND "SPTAG" BETWEEN 20101201 AND 20101231 AND "MATNR" BETWEEN '000000000100000000' AND '000000000999999999';
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
Explained.
SQL>
PLAN_TABLE_OUTPUT
Id
Operation
Name
Rows
Bytes
Cost (%CPU)
0
SELECT STATEMENT
2334
152K
150 (1)
1
TABLE ACCESS BY INDEX ROWID
S911
2334
152K
149 (0)
2
INDEX RANGE SCAN
S911~VAC
55M
5 (0)
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("VKORG"='D004' AND TO_NUMBER("SPTAG")>=20101201 AND
TO_NUMBER("SPTAG")<=20101231)
2 - access("MANDT"='003' AND "MATNR">='000000000100000000' AND
"MATNR"<='000000000999999999')
Best Regards,
Daniel G.Volker,
Answering your question, regarding the explain from ST05. As a quick work around I created an index (S911~Z9), but still I'd like to solve this issue without this extra index, as primary index would work ok, as long as date was correctly sent to oracle as string and not as number.
SELECT
"SPTAG" , "WERKS" , "VKORG" , "VTWEG" , "SPART" , "KUNNR" , "MATNR" ,
"PERIV" , "VOLUM_01" , "VOLEH"
FROM
"S911"
WHERE
"MANDT" = :A0 AND "VKORG" = :A1 AND "SPTAG" BETWEEN :A2 AND :A3 AND "MATNR"
BETWEEN :A4 AND :A5
A0(CH,3) = 003
A1(CH,4) = D004
A2(NU,8) = 20101201 (NU means number correct?)
A3(NU,8) = 20101231
A4(CH,18) = 000000000100000000
A5(CH,18) = 000000000999999999
SELECT STATEMENT ( Estimated Costs = 10 , Estimated #Rows = 6 )
5 3 FILTER
Filter Predicates
5 2 TABLE ACCESS BY INDEX ROWID S911
( Estim. Costs = 10 , Estim. #Rows = 6 )
Estim. CPU-Costs = 247.566 Estim. IO-Costs = 10
1 INDEX RANGE SCAN S911~Z9
( Estim. Costs = 7 , Estim. #Rows = 20 )
Search Columns: 4
Estim. CPU-Costs = 223.202 Estim. IO-Costs = 7
Access Predicates Filter Predicates
The table originally includes the following indexes:
###S911~0
MANDT
SSOUR
VRSIO
SPMON
SPTAG
SPWOC
SPBUP
VKORG
VTWEG
SPART
VKBUR
VKGRP
KONDA
KUNNR
WERKS
MATNR
###S911~VAC
MANDT
MATNR
Number of entries: 61.303.517
DISTINCT VKORG: 65
DISTINCT SPTAG: 3107
DISTINCT MATNR: 2939 -
Error when inserting data .. to check the functionality of a trigger .
hallo,
im trying to write a trigger like that :
CREATE OR REPLACE TRIGGER raum_besetzt
BEFORE DELETE OR UPDATE OR INSERT ON BUCHUNGEN
FOR EACH ROW
DECLARE
v_p NUMBER;
v_t NUMBER;
BEGIN
SELECT ANzahl_plaetze into v_p
FROM RAEUME;
SELECT ANzahl_teilnehmer into v_t
FROM BUCHUNGEN;
INSERT INTO BUCHUNGEN VALUES (:NEW.BUCH_ID, :NEW.RAUM_ID, :NEW.MITA_ID, :NEW.VON, :NEW.BIS, :NEW.ANZAHL_TEILNEHMER, :NEW.VART_ID);
IF (v_t > v_p) THEN RAISE_APPLICATION_ERROR (-20001, ' diesen RAUM ist leer ');
END IF;
END;the trigger have to check that all participants will be booked in the room can be accommodated. On error, the reservation is cancel.
so i implemented it the way that number of participants ( anzahl_teilnehmer ) in the Table Reservations ( Buchungen ) is greater than the number of places ( Anzahl_plaetze ) in the table Rooms ( Raeume )
so now i want to add some data to the table BUCHUNGEN ( Reservations ), so i can see if the trigger works!
What i get is the Error below !! :
Fehler beim Start in Zeile 56 in Befehl:
INSERT INTO BUCHUNGEN (BUCH_ID, RAUM_ID, MITA_ID, VON, BIS, ANZAHL_TEILNEHMER, VART_ID)
VALUES (5, 5, 5, '', '', 30, 3)
Fehlerbericht:
SQL-Fehler: ORA-01422: Exakter Abruf gibt mehr als die angeforderte Zeilenzahl zurück
ORA-06512: in "RAUM_BESETZT", Zeile 5
ORA-04088: Fehler bei der Ausführung von Trigger 'RAUM_BESETZT'
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requestedcan anyone help :)
thank you ..Logic such as this should be written in a little api. A trigger is possible, but it might be pretty difficult to implement the full solution in a trigger which has several restrictions. An api usually doesn't have the same technical restrictions (trigger need to prevent endless loops, therefore they will raise an mutating table error if you insert into the same table)
The main issue is that during the execution of your trigger, another process might add a booking without commiting it yet. But your trigger can't see this new booking from the different session. This has to be solved on a logical level first before solving it on database level. How do you want to handle such a situation? -
If you have a table with a unique index and ignore_dup_key = on and you INSERT rows into that table with an ORDER BY clause (because you want to control which of the duplicate
key rows gets inserted), the wrong row gets inserted in SQL2012. It works correctly in SQL 2008.
We have recently migrated a database from SQL 2008 to SQL 2012. We do have few other dbs which are in compatability mode 100. The above operation works fine
in SQL 2008 dbs but not SQL 2012.
I've even tried applying the latest patch for SQL 2012 SP2 with CU2. Still the problem exists. I'm going to call MS support, but want to know if anyone has come across this problem ?The MS documentation doesn't guarantee that the first row of the duplicates will always be inserted and the next duplicate row(s) get(s) ignored. Where did you find it in the MS documentation? I think you were just lucky that it was always inserting the
first row in SQL 2008 (and ignoring the rest of the duplicates) - I don't think this is guaranteed
Satish Kartan http://www.sqlfood.com/ -
SSIS package takes longer time when inserting data into temp tables
querying records from one server and inserting them into temp tables is taking longer time.
are there any setting in package which enhance the performance .will local temp table (#temp ) enhance the performance ..
If you're planning to use # tables in ssis make sure you read this
http://consultingblogs.emc.com/jamiethomson/archive/2006/11/19/SSIS_3A00_-Using-temporary-tables.aspx
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
IPhone calendar sync w Windows 8 Outlook 2013
I am using the Outlook 2013 calendar. I want my iPhone to sync up with this Outlook 2013 client-(not cloud) based calendar, but during an iTunes sync, it seems to pick up the Win8 Calendar app instead. Any advice? I'm at my wit's end. Thanks (and y
-
Problem in Creating data for HCM Talent management System Risk of Loss data
Hello there, I am trying to enter data for Risk of Loss in HR HCM TMS. Does anybody know in which SAP portal Release this functionality is delivered i have SAP portal 7.00 with JEECOR and JEE and with SP 16. i think all the new functionality delive
-
How can i cancel long running queries (red x doesnt work)
hi there i am trying to work with some long running queries - it would be very nice to be able to cancel them (like toads cancel button) I have tried the red X in the circle but it doesnt seem to work - it appears to have cancelled it (the cylon-eye
-
HT203521 Outlook says iCloud calendars are invalid
Has something changed on the iCloud service? We use the iCloud calendar service to share calendars as internet calendars via MS Outlook in the office with each other (out of office, delivery schedules, etc). It used to work fine up until NOV 12/2014,
-
Apps won't open unless I open a second app...
Anyone had this problem? I've beed using Leopard (10.5.5) with Adobe CS for ages and had no problem, then I started my work Mac on Monday, went to launch PShop and the icon just bounced forever - no message - then stopped, so I tried Illustrator - sa