DATABASE LOGIC Probelm
Hi all,
I am working vehicle management application if the vehicle get late for more than 7 days it will get violated this is what i did as database job,my system will calculate the expected ou date time but i want to modify the job so that when the vehicle exceeds the seven days +1 hour then he will get violated as one day late
the same thing with the others violation additional hour in the next day it will be calculated as new violation
how can i do this ??
please help me ?
Ahmed
Something to play with
with
vehicles as
(select trunc(dbms_random.value(100,900),0) vehicle,
trunc(sysdate + dbms_random.value(5,15),'MI') expected_out_date
from dual
connect by level <= 20
violations_by_job_run as
(select vehicle,
ltrim(ltrim(to_char(numtodsinterval(expected_out_date - trunc(sysdate,'HH24'),'HOUR')),'+'),'0') violation,
trunc(sysdate,'MI') job_invocation
from vehicles
where expected_out_date < trunc(sysdate,'HH24') + 7
select vehicle,
substr(violation,1,instr(violation,'.') - 4) violation,
job_invocation
from violations_by_job_run
order by violationRegards
Etbin
job_invocation added
Message was edited by: Etbin
user596003
Similar Messages
-
Anyone know online documentation that explains database logical structure ?
The relationships between database, tablespace, datafile, segment, extent, and blocks ... storage structure.
In an easy to understand document :)
I am learning Oracle 9i, any helps are really appreciated.
Thanks in advance.I'd start with [url http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/toc.htm] Oracle9i Database Concepts
-
Sql for database logical segment details...
db: 11g
OS: unix
friends.. I am trying to get database logical segment details along with datafile id and tablespace name...
just want to confirm I'm progressing in right direction...
trying to get following
1. owner,
2. segment_name,
3. partition_name,
4. file_id (datafile id)
5. segment_type
6. extent_ct (number of extents occupies in datafile)
7. size_k (space in kb occupy in datafile)
I have come up with below sql... is it correct or more changes required?
I have got feeling I'm missing something for 6 & 7
SELECT
dbs.owner, dbs.segment_name, dbs.partition_name, df.file_id, dbs.segment_type, dbs.extents, (dbs.bytes)/1024 size_k
FROM
dba_data_files df,
dba_tablespaces tbs,
dba_segments dbs
WHERE
df.tablespace_name = tbs.tablespace_name
and tbs.tablespace_name = dbs.tablespace_name
and tbs.contents = 'PERMANENT'
order by 1,2
/thanks,posted in correct segment...
-
Database logical segment details..
db: 11g
OS: unix
friends & gurus,
I am trying to get database logical segment details along with datafile id and tablespace name...
just want to confirm I'm progressing in right direction...
trying to get following
1. owner,
2. segment_name,
3. partition_name,
4. file_id (datafile id)
5. segment_type
6. extent_ct (number of extents occupies in the datafile)
7. size_k (space in kb occupy that this obect is occupying in the datafile)
I have come up with below sql... is it correct or more changes required?
I have got feeling that I'm missing something for 6 & 7
SELECT
dbs.owner, dbs.segment_name, dbs.partition_name, df.file_id, dbs.segment_type, dbs.extents, (dbs.bytes)/1024 size_k
FROM
dba_data_files df,
dba_tablespaces tbs,
dba_segments dbs
WHERE
df.tablespace_name = tbs.tablespace_name
and tbs.tablespace_name = dbs.tablespace_name
and tbs.contents = 'PERMANENT'
order by 1,2
/ thank you...This is not exactly what you want but is maybe close enough: to get extent numbers and extents size per owner, segment_name, segment_type and datafile:
set echo on
set linesize 132
spool tes.log
column owner format a10
column segment_name format a40
select owner, segment_name, segment_type, file_id, count(*) as ext_nb, sum(bytes/1024/1024) as ext_mb
from dba_extents
group by owner, segment_name, segment_type, file_id
order by 1,2,3,4;
OUTLN OL$ TABLE 1 1 .0625
OUTLN OL$HINTS TABLE 1 1 .0625
OUTLN OL$HNT_NUM INDEX 1 1 .0625
OUTLN OL$NAME INDEX 1 1 .0625
OUTLN OL$NODES TABLE 1 1 .0625
OUTLN OL$NODE_OL_NAME INDEX 1 1 .0625
OUTLN OL$SIGNATURE INDEX 1 1 .0625
OWNER SEGMENT_NAME SEGMENT_TYPE FILE_ID EXT_NB EXT_MB
OUTLN SYS_IL0000000453C00021$$ LOBINDEX 1 1 .0625
OUTLN SYS_LOB0000000453C00021$$ LOBSEGMENT 1 1 .0625
SCOTT BONUS TABLE 4 2 .125
SCOTT DEPT TABLE 4 1 .0625
SCOTT EMP TABLE 4 1 .0625
SCOTT EMP_RANGE TABLE PARTITION 4 5 .3125
SCOTT PK_DEPT INDEX 4 1 .0625
SCOTT PK_EMP INDEX 4 1 .0625
SCOTT SALGRADE TABLE 4 1 .0625
SYS ACCESS$ TABLE 1 18 3
SYS ALERT_QT TABLE 3 3 .1875
OWNER SEGMENT_NAME SEGMENT_TYPE FILE_ID EXT_NB EXT_MB
SYS APPLY$_CONF_HDLR_COLUMNS TABLE 1 1 .0625
SYS APPLY$_CONF_HDLR_COLUMNS_UNQ1 INDEX 1 1 .0625
SYS APPLY$_CONF_HDLR_COLUMNS_UNQ2 INDEX 1 1 .0625
SYS APPLY$_CONSTRAINT_COLUMNS TABLE 1 1 .0625
SYS APPLY$_CONSTRAINT_COLUMNS_IDX1 INDEX 1 1 .0625
SYS APPLY$_CONSTRAINT_COLUMNS_UIX1 INDEX 1 1 .0625
SQL> -
How would I unit test database logic?
I am still having a issue getting over a small issue when it comes to TDD.
I need a method that will get a certain record set of filtered data from the data layer (linq2SQL). Please note that i am using the linq generated classes from that are generated from the DBML. Now the problem is that i want to write a test for this.
do i:
a) first insert the records in the test and then execute the method and test the results
b) use data that might be in the database. Not to keen on this logic cause it could cause things to break.
c) what ever you suggest?Variation on (a).
Have a test db or subsection of the db that can be used for testing. When you are setting up your tests, have a routine that initializes the DB as you need it to begin testing (this can be done before each test, as appropriate). This may include deleting data,
inserting data, etc. Then run your tests. In the Teardown phase, clean up after yourself. Can be repeated as much as is needed, without risk of disrupting live system (not a good idea to test using data in the database that is needed for anything else).
Really, all one has to do is use System.Transactions and Rollback the transactions at the end of each tests. That's what I have seen done in integration testing, which UT does not apply in testing DB transactions. -
Master database logical file names are different - Please Help!
Today I noticed that one of the server in our environment,
when i run
SELECT *
FROM sys.database_files
i got results
data_space_id name
1 master2
0 master_Log2
Please note logical name of the master database files.
But, in SSMS if i right click and choose properties for master database, it shows logical file names are master, mastlog.
How can this be happened? How can i fix this issue and make it both same names for master database?
Please help!Today I noticed that one of the server in our environment,
when i run
SELECT *
FROM sys.database_files
i got results
data_space_id name
1 master2
0 master_Log2
Please note logical name of the master database files.
But, in SSMS if i right click and choose properties for master database, it shows logical file names are master, mastlog.
How can this be happened? How can i fix this issue and make it both same names for master database?
Please help!
Its nothing to worry about may be master was restored from backup which had logical file name as master2
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Wiki Article
MVP -
Your experience about Standby Database (Logical).
Hi,
As expressed in the subject of the thread, I'd like to get some feedback about Logical Standby.
One of the databases (A) here has a setup with a Physical Standby (B). In order to lighten the workload on A, i want to "upgrade" B to a Logical Standby. The procedure is already defined, tested and functionnal. But as I never managed a Logical Standby, it would be great if you could share your experience about:
1/ A's workload: Will there be a big overhead due to log treatments (and supplemental log data)?
2/ LAS: Will it take longer to apply an archived redo log to Logical B than it takes on the Physical B?
3/ I can't set the hardware on B's host to the same level as it's on A's host.
A has (6cpu, 20GiB RAM, half for SGA)
Physical B has (2cp, 9GiB RAM, 5GiB for SGA)
Logical B will have (3cpu, 12GiB RAM, xxxGiB SGA)
The load on B will be very very less than it is on A. Knowing A perfs is O.K., will B perf on reporting be O.K.?
4/ my target for backup is now B. When the "upgrade" will be finished, would you advise to continue the backup on the Logical Standby, or to switch to a backup via (RMAN/HotBackup/...) ?
5/ Any other advice you could give :-)
Thanks,
Yoann.Hi Yoann,
Some time ago I created a logical database for Oracle 9.2.0.4 db on RH Linux then on 9.2.0.6 ver (same OS). It was very tempting to decrease loading on primary database through using logical standby, but It was not moved to production. I stuck with some problems when transactions stopped because of some inconsistency (I used transaction consistency set to NONE because of performance) and there were a couple of them between a hundred of tables. After that I tried to create a database link upon the primary database, but it was not apt to use with the same procedures to execute.
Regarding questions:
1. I did not find the big overhead, but a lot of additional actions should be done due to maintenance tables w/o PK on LGSTBY
2. Difficult to say ...
3. I had LGSTBY half of power of primary
4. I will not you advise to backup LGSTBY because of some possible problems with transactions, maintenance etc. better to use RMAN on primary or physical standby
5. Try to test 10g logical standby (I have read that there is no need to freeze the primary database during logical standby creation)
Hope this helps,
Andrey -
hii all,
I want to keep locks(logically) to the existing database records as my ztables(3 tables with 1 parent table,containing header data and 2 line item tables having the foreign key relationships with header table) are accessed at time by many users(different users might try to change the same record).what is the best way to go ahead.
with regards,
sandeep akella.Hi,
check the following link
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm
Regards,
Madhu -
Data block corrupted on standby database (logical corruption)
Hi all,
we are getting the below error on our DRSITE,it is MANUAL PHYSCIAL STANDBY DATABSE...
The following error has occurred:
ORA-01578: ORACLE data block corrupted (file # 3, block # 3236947)
ORA-01110: data file 3: '/bkp/oradata/orcl_raw_cadata01'
ORA-26040: Data block was loaded using the NOLOGGING option
I have checked in the Primary database, that there are some object which are not being logged into the redo logfiles.....
SQL> select table_name,INDEX_NAME,logging from dba_indexes where logging='NO'
TABLE_NAME INDEX_NAME LOG
MENU_MENUS NUX_MENU_MENUS_01 NO
MENU_USER_MENUS MENU_USER_MENUS_X NO
OM_CITY IDM_OM_CITY_CITY_NAME NO
OM_EMPLOYER EMPLR_CODE_PK NO
OM_EMPLOYER IDM_EMPLR_EMPLR_NAME NOOM_STUDENT_HEAD OM_STUDENT_HEAD_HEAD_UK01 NO
OT_DAK_ENTRY_DETL DED_SYS_ID_PK NO
OT_DAK_ENTRY_HEAD DEH_SYS_ID_PK NO
OT_DAK_ENTRY_HEAD IDM_DEH_DT_APPL_REGION NO
OT_DAK_ENTRY_HEAD IDM_DEH_REGION_CODE NO
OT_DAK_REFUNDS_DETL DRD_SYS_ID_PK NO
TABLE_NAME INDEX_NAME LOG
OT_MEM_FEE_COL_DETL IDM_MFCD_MFCH_SYS_ID NO
OM_STUDENT_HEAD IDM_STUD_COURSE NO
13 rows selected.
so the main problem is in the OM_EMPOYER tables if i would delete the indexes from that table recreate it again with the logging clause,and then apply the archvied logs to the DRSITE.WILL THE problem will resolve.
Pls suggest me...Hi..
Firstly how did you confirm that it was that index only.Can you post the output of
SELECT tablespace_name, segment_type, owner, segment_name
FROM dba_extents WHERE file_id = 3 and 3236947 between block_id
AND block_id + blocks - 1;
This query can take time, if are sure that its the index don't fire this command .
Secondly, when you will drop and recreate the index, it will be logged into the redo logfile.This information will be be logged in to an the archivelog file as its the replica of the redo logfile. Then when you apply this archive log maually, it will drop that index and then recreate it using the same sql.
HTH
Anand -
Database logic problems.. very urgent
HI im having problems doing something that is quite possibly very easy..
i have written a few queries using JDBC
anyway the problem is hwo can i see if no records have been returned? using the ResultSet...
i have tried if Resultset == null
but it doesnt work
please help meTHNx alot it werks perfectly.... i guess i should read my API's more carefully ni teh future
thnx foir teh help -
Hi,
What is the logical database. I know how to create.
I think it is useful for dynamic selections of parameters.
This logical databases use by HR ABAP. Is it right?
But i heard that these will increase performnace of ur coding. How can u justify these doubts.
rgds
p.kpHi paluri,
1. What is the logical database
Logical database is nothing
but a program only,
which provides the facility of
a)pre-defined seleciton secreen
b) facility for GETting records
(without knowint the databse tables)
2. logical databases use by HR ABAP. Is it right?
Yes, absolutely right. Its mostly used
in HR.
But it is also used now a days in other modules
like FI, SD.
3. But i heard that these will increase performnace of ur coding
Yes, it will increase the performanc,e
in the sense, that,
the SQL, FMs used for fetching from the database
is already fine tuned and written
into the already tested program of logical database.
regards,
amit m. -
Hi,
Is it common to use logical database for HR report?? How about other module such as SD/MM??
Regards,
KitHi,
Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
Logical Databases - Views of Data
A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
The diagram illustrates how the R/3 System might represent the structure of a company. A logical database can read the lines of these tables one after the other into an executable program in a sequence which is normally defined by the hierarchical structure. The term logical database is sometimes used to mean not only the program itself, but also the data that it can procure.
Tasks of Logical Databases
As well as allowing you to read data from the database, logical databases also allow you to program other tasks centrally, making your application programs less complicated. They can be used for the following tasks:
Reading the same data for several programs.
The individual programs do not then need to know the exact structure of the relevant database tables (and especially not their foreign key relationships). Instead, they can rely on the logical database to read the database entries in the right order during the GET event.
Defining the same user interface for several programs.
Logical databases have a built-in selection screen. Therefore, all of the programs that use the logical database have the same user interface.
Central authorization checks
Authorization checks for central and sensitive data can be programmed centrally in the database to prevent them from being bypassed by simple application programs.
Improving performance
If you want to improve response times, logical databases permit you to take a number of measures to achieve this (for example, using joins instead of nested SELECT statements). These become immediately effective in all of the application programs concerned and save you from having to modify their source code
Reward Points if useful
Raghunath.S
9986076729 -
hi,
what is LDB....its benefit
and how to to it for multiple tables ......
.... i want to use LDB instead of table joins...... there are abt 20 tables..... using joins , the performance is slow ...
..... please advise..
thanksLOGICAL DATABASES:
Logical Databases are used to generate report.
It is a repository object, not a data dictionary object.
Under one logical database, a node is created first for the corresponding table in the database.
A logical database can have any number of related nodes in the hierarchical manner.
First node of the logical database is called as ROOT NODE.
SLDB or SE36 to create logical databases.
Navigations to Create Logical Database:
SLDB -> Specify LDB name starting with Z or Y -> Click on Create -> Opens an interface -> Enter short description
-> Create -> Save under a package and assign request number -> Opens an interface
-> Specify Root Node name (MARA) -> Enter short description for the Root node
-> Specify Database Table name (MARA) -> Create -> Opens an interface
-> Select the Root Node (KNA1) -> Click on SELECTIONS pushbutton from Appn.
Toolbar -> Click on Yes to generate Selection Screens from the Structure
-> Click on No to Search Help -> Opens an Interface
-> Select the checkboxes to create Field Selections and Free Selections
-> TRansfer -> Opens an Include Program -> Decomment Select-Options statement and specify range variable as follows:
SELECT-OPTIONS : MATNUM FOR MARA-MATNR.
-> Save -> Activate -> Come back.
Select the Node -> Click on SOURCE CODE pushbutton
-> Click on Yes to generate source code from Structure and Selections -> Opens a report with two Include Files :
include DBZLOGICAL_DATABASE1TOP . " header
include DBZLOGICAL_DATABASE1NXXX . " all system routines
-> Double click on Header File to declare global variables -> Specify Following code:
TABLES : MARA * Autogenerated
DATA IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
-> Save -> Activate -> Come back -> Double click on System Routine file, where the fetching operations are done
-> Opens an Include File with three subfiles as follows:
include DBZLOGICAL_DATABASE1N001 . " Node MARA
include DBZLOGICAL_DATABASE1FXXX . " init, PBO, PAI
include DBZLOGICAL_DATABASE1SXXX . " search help
-> Double click on the first file -> Specify SELECT operation statement as follows:
select * from mara into table it_mara where matnr in MATNUM.
PUT MARA. * AUTOGENERATED CODE
loop at it_mara.
write :/ it_mara-matnr, it_mara-mtart, it_mara-mbrsh, it_mara-meins.
endloop.
-> Save -> Activate.
To Access LDB node, create SE38 PROGRAM, Specify LDB name in ATTRIBUTES section -> Specify following code in SE38:
NODES MARA.
GET MARA.
-> Save -> Activate -> Execute. -
hi friends,
plz explain me how to call logical database in a report program?hi,
Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
Logical Databases - Views of Data
A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
Advantages of Logical database -
1) No need of programming for retrieval , meaning for data selection
2) Easy to use standard user interface, have check completeness of user input.
Disadvantages
1) Fast in case of lesser no. of tables But if the table is in the lowest level of hierarchy, all upper level tables should be read so performance is slower.
GO THROUGH THE LINKS
http://www.sap-basis-abap.com/saptab.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
Re: **LDB**
www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html
www.sap-img.com/abap/abap-interview-question.htm
www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm
Use Tcode SE36 For creating Logical Database.
Here is a simple Program on Logical database.
NODES: spfli,sflight.
START-OF-SELECTION.
WRITE 'Test Program for GET'.
*Fetching SPFLI table
GET spfli.
WRITE: / 'Carrid:', spfli-carrid,
'Connid:', spfli-connid.
*Fetching SFLIGHT table
GET sflight.
SKIP 5.
WRITE: / 'Carrid:', sflight-carrid,
'Connid:', sflight-connid.
logical database
logical database
http://help.sap.com/saphelp_nw04/helpdata/en/60/183d78163011d2953c0000e8353423/frameset.htm
general
example program
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/frameset.htm
regards,
pavan
REWARD POINTS IF USEFUL -
STRUCTURES of LOGICAL DATABASE?
STRUCTURES of LOGICAL DATABASE?
please explainhi,
Logical Databases
Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.
Logical Databases - Views of Data
A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
Maybe you are looking for
-
SAP GUI installation issue.
Hi All, I am trying to install SAP GUI640v16 on my machine (Windows XP). In the middle of the installation, I'am getting an error like: Your computer needs to be restarted due to pending system changes. It is not safe to continue without a reboot. Ho
-
Adobe acrobat x and 9 professional convert landscape to portrait in Mac 10.6
Dear all, 1) I have using MAC 10.6 with Adobe 10 prof . My problem is even i print the landscape document in to my application the preview switched to portrait. 2) Even i print the pdf document through adobe pdf printer.But i couldnot save the pdf fi
-
Hi I am developing a site with Dreamweaver CS3. My problem is that I need to define certain words in the site which when clicked, open a seperate browser window that shows the definition of the word. The new window that opens contains all the definit
-
Many problems and Apple Support isn't coming up with answers
Bought an apple tv yesterday. Am not happy. I was on the phone with a tech for 2 hours yesterday. He had to guide me through upgrading it's software. But he couldn't resolve the problem I have with renting a movie on apple tv. Had me send an email to
-
Analysis Authorization questions
How does Analysis Authorizations work in below cases 1)Infoobject "A" set as Authorization relevant (In Bex explorer tab) 2)Infoobject "B" which is ATTRIBUTE of infooobject "A" set as Authorization relevant 3)Infoobject "A" and "B" both set as Author