Plz help me with this query
i need to get each manager name, his department name and for each year that is for 81,82,83,84 count of employee's under that manager from emp and dept tables .
thanks in advance
select distinct deptno, TO_CHAR (HIREDATE, 'YY'), count(*) from emp group by TO_CHAR(HIREDATE, 'YY'), DEPTNO ORDER BY TO_CHAR(HIREDATE, 'YY'), DEPTNO;
the above query returns me count of employees ,year and deptno
SELECT DISTINCT E2.ENAME , E1.ENAME, E1.DEPTNO, E1.MGR, E1.EMPNO, E1.SAL, D.DNAME, D.LOC FROM EMP E1, EMP E2, DEPT D WHERE E1.MGR = E2.EMPNO AND E1.DEPTNO = D.DEPTNO ORDER BY E1.DEPTNO;
this query returned me manager names and employees under them
Message was edited by:
user450660
At that point you're not too far off, you have most of what you need. In general, any time you see the use of DISTINCT it's a sign that either your query or your data model isn't designed quite right.
SELECT m.ename,
d.dname,
TO_CHAR (e.hiredate, 'YY') AS hire_year,
COUNT(*) AS emp_count
FROM emp e, emp m, dept d
WHERE e.mgr = m.empno
AND m.deptno = d.deptno
GROUP BY
m.ename,
d.dname,
TO_CHAR (e.hiredate, 'YY');
Similar Messages
-
Hi,
Can you’ll please help me with this query.
Here is a little bit of background:
One title can have multiple items associated with it.
Table: TITLE has the master list of titles. TITLE_ID is the primary key.
Table: ITEM has the master list of all items. ITEM_ID is the primary. This table also has the TITLE_ID which stores title for this item.
Table: ITEM_STATUS has fields ITEM_ID and STATUS_ID. This field contains statuses for items. But not all items contained in the table ITEM are in this table.
I want to find TITLE_ID’s whose all items (all ITEM_ID in table ITEM having same value for TITLE_ID) have a particular status (for example STATUS_ID = 2) in table ITEM_STATUS.
Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and only 4 items out of it in table ITEM_STATUS with STATUS_ID = 2, then this TITLE_ID should not come. OR
Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and all these 5 items are in table ITEM_STATUS but only 1 has STATUS_ID = 2, then this TITLE_ID should also not come
In the above case only if all 5 items are contained in table ITEM_STATUS have STATUS_ID = 2 then this TITLE_ID should be reported by the query.
What should be the query like for this one, I am fairly new to SQL so plz guide me.
Thank you,
RajaI haven't tested the query below. Try it and let me know for any issues:
SELECT DISTINCT t.title_id
FROM title t,
item i,
item_status its
WHERE t.title_id = i.title_id
AND i.item_id = its.item_id
AND NOT EXISTS (
SELECT 1
FROM item_status its1
WHERE its1.item_id = i.item_id
AND status_id <> 'YOUR_ITEM_STATUS'
) -
I would like to create a view on this table with four columns
1. PN#_EXP_DATE
2. PN#
3. PN#_EFF_DATE
4. PN#
P_S_C A_C P EXP_DT
21698 13921 1 5/29/2009 3:15:41 PM
21698 13921 1 5/29/2009 3:54:57 PM
21698 1716656 4 5/29/2009 3:15:41 PM
21698 3217 3 5/29/2009 3:15:40 PM
21698 3217 3 5/29/2009 3:54:57 PM
21698 60559 2 5/29/2009 3:15:41 PM
21698 60559 2 5/29/2009 3:54:57 PM
I have a trigger on A, which inserts the DML records into B. (Table A and B structure is the almost the same,
where table B will have one extra column exp_dt)
NOw Table B can have records with same P_S_C and A_C columns and exp_dt will capture the history.
for example: from the above sample data, let us take first two records..
P_S_C A_C P EXP_DT
21698 13921 1 5/29/2009 3:15:41 PM --- Record 1
21698 13921 1 5/29/2009 3:54:57 PM --- Record 2
from this..
Note: 1. Table A and Table C can be joined using A.P_S_C and C.R_C to get the start_date.
2. PN# comes from table D. It contains numbers for the resp. weeks.
3. PN#_EFF_DATE is the previous immediate previous date for that record in history table (Table B).
I wanted the data like..
---- this is for the second record in the above..
PN#_EXP_DATE PN# PN#_EFF_DATE PN#
5/29/2009 3:54:57 PM 214 5/29/2009 3:15:41 PM 214
---- this is for the first record in the above..
PN#_EXP_DATE PN# PN#_EFF_DATE PN#
5/29/2009 3:54:41 PM 214 ( for this we should query the table C to get the
start_date, for this combinatation of P_S_C and A_C in table B
where B.P_S_C = C.A_C
and that value should be the EFF_DT for this record)
Please help me with this....
Thanks in advance..Hi All,
select d.P# as "PN#_EXP_DATE", exp_date
from daily_prd d, cbs1_assoc_hist b
where to_char(d.day_date,'MM/DD/YYYY') = to_char(b.exp_date,'MM/DD/YYYY')
and d.period_type = 'TIMEREPORT';
This above query gives the output as follows:
pn#_exp_date exp_date
214 5/29/2009 3:15:40 PM
214 5/29/2009 3:15:41 PM
214 5/29/2009 3:15:41 PM
214 5/29/2009 3:15:41 PM
214 5/29/2009 3:54:57 PM
214 5/29/2009 3:54:57 PM
214 5/29/2009 3:54:57 PM
This below is the data from history table (Table B).
P_S_C A_C PLACE EXP_DATE
21698 3217 3 5/29/2009 3:15:40 PM
21698 13921 1 5/29/2009 3:15:41 PM
21698 1716656 4 5/29/2009 3:15:41 PM
21698 60559 2 5/29/2009 3:15:41 PM
21698 13921 1 5/29/2009 3:54:57 PM
21698 3217 3 5/29/2009 3:54:57 PM
21698 60559 2 5/29/2009 3:54:57 PM
I got the pn#_exp_date from the Table 'D', for the given exp_date from Table B.
My question is again....
CASE - 1
from the given records above, I need to look for exp_date for the given same P_S_C and A_C.
in this case we can take the example...
P_S_C A_C PLACE EXP_DATE
21698 3217 3 5/29/2009 3:15:40 PM
21698 3217 3 5/29/2009 3:54:57 PM
In this case, the
pn#_exp_date exp_date pn#_eff_date eff_date
214 5/29/2009 3:15:57 PM < PN# corresponding to the 5/29/2009 3:15:40 PM
eff_date .>
<Basically the eff_date is
nothing but the exp_date only.
we should take the immediate before one.
In this case, our eff_date is '5/29/2009 3:15:40 PM'.
but how to get this.
CASE - 2
from the above sample data, consider this
P_S_C A_C PLACE EXP_DATE
21698 1716656 4 5/29/2009 3:15:41 PM
In this case, there is only one record for the P_S_C and A_C combination.
The expected result :
pn#_exp_date exp_date pn#_eff_date eff_date
214 5/29/2009 3:15:41 PM < PN# corresponding to the 5/29/2009 3:15:40 PM
eff_date .>
<Basically the eff_date is
nothing but the exp_date only.
we should take the immediate before one.
In this case to get the eff_date, we should query the Table 'C', to get the eff_date, which is START_DT column in this table.
for this join B.P_S_C and C.R_C.
Hope I am clear now..
Thanks in advance..... -
Hi Everyone...Please help me with this query...!
Please Help me with this doubt as I am unable to understand the logic...behind this code. It's a begineer level code but I need to understand the logic so that I am able to grasp knowledge. Thank you all for being supportive. Please help me.
//Assume class Demo is inherited from class SuperDemo...in other words class Demo extends SuperDemo
//Volume is a method declared in SuperDemo which returns an integer value
//weight is an integer vairable declared in the subclass which is Demo
class Example
public static void main(String qw[])
Demo ob1=new Demo(3,5,7,9);
//Calling Constructor of Demo which takes in 4 int parameters
SuperDemo ob2=new SuperDemo();
int vol;
vol=ob1.volume();
System.out.println("Volume of ob1 is " + vol);
System.out.println("Weight of ob1 is " + ob1.weight);
System.out.println();
ob2=ob1;
}Can someone please make me understand --- how is this possible and why !
If the above statement is valid then why not this one "System.out.println(ob2.weight);"
Thanks Thanks Thanks!u see the line wherein I am referencing the objectof
a subclass to the superclass...right? then why we
can't do System.out.println(ob2.weight)?You need to distinguish two things:
- the type of the object, which determines with the
object can do
- the type of the reference to the object, which
determines what you see that you can do
Both don't necessarily have to match. When you use a
SuperDemo reference (obj2) to access a Demo instance
(obj1), for all you know, the instance behind obj2 is
of type SuperDemo. That it's in reality of type Demo
is unknown to you. And usually, you don't care -
that's what polymorphism is about.
So you have a reference obj2 of type SuperDemo.
SuperDemo objects don't have weight, so you don't see
it - even though it is there.So from ur explanation wat I understand is - Even though u reference a subclass object to a superclass, u will only be able to access the members which are declared in the superclass thru the same...right
? -
Plz help in tuning this query......
SELECT "LAN","VEF_REF_NO","VF_TYPE_CODE","APPLICANT_TYPE","MANDATORY","OPTIONAL","COMPLETE","DT_COMPLETED","REFIRENO","ROLE","USER_ID","DT_LASTUPDATED","TEMPLATEFIRED"
FROM T_VER_STRATEGY_DETAILS M
WHERE VF_TYPE_CODE =1 AND
APPLICANT_TYPE ='A' AND
DT_LASTUPDATED=
(SELECT MAX(DT_LASTUPDATED)
FROM T_VER_STRATEGY_DETAILS
WHERE LAN = M.LAN AND
VF_TYPE_CODE =1 AND APPLICANT_TYPE ='A')
This seems to be a correlated query.
i tried using combined index on
(VF_TYPE_CODE ,APPLICANT_TYPE ,DT_LASTUPDATED)
and another index on
(LAN,VF_TYPE_CODE ,APPLICANT_TYPE ) but the plan or cost remains unchained.
plz help[url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long...
-
Plz help prob with a query and.. a trigger
hi..
1)i've created a view.gave the commit..
now when i execute this query i get no rows selected...
sql>select text from user_views where view_name='d1_v';even when i give sql>select * from user_views; all i see are column names and nothing else..
do i need to grant my user any privilige. my user has create any view privilige.
2)
is it possible for me to create a trigger that updates records by itself for every 6 months by adding 1000 to the sal field
i tried
create or replace trigger after logon on emp ..............like that
but i receive an error saying system triggers cannot be based on tables or views..
plz help me out..
thank u
rajiv1. Try "select text from user_views where view_name='D1_V';
BTW, no need to use "commit", CREATE VIEW is a DDL command, and DDLs do implicit commit.
2. Why do you want to use triggers ? You can do that in at least two other ways : cron jobs and Oracle jobs. -
Plz help to make this query......very urgent
I ve two tables <br>
<br>
First one is <b>grn_dtl</b> containing following fields <br> <br> <br>
<u><b>
item_code ent_dt qty doc_no </u></b><br>
11001318 09/09/2003 5 56300501 <br>
11001318 11/09/2004 9 56300502 <br>
11001318 12/05/2005 2 56300503 <br>
11001319 22/06/2004 0 56300504 <br>
11001320 09/06/2005 0 56300505 <br>
11001320 11/08/2004 8 56300506 <br>
11001320 30/05/2005 4 56300507 <br>
11001320 21/06/2003 1 56300508 <br>
11001321 25/09/2004 1 56300509 <br>
11001321 15/07/2004 1 56300510 <br>
11001321 01/08/2004 2 56300511 <br>
11001322 02/06/2004 1 56300512 <br>
11001322 22/06/2004 2 56300513 <br>
11001323 12/09/2004 1 56300514 <br>
11001323 08/05/2004 4 56300515 <br>
11001323 17/08/2004 5 56300516 <br>
11001323 28/06/2004 2 56300517 <br>
<br><br>
second one is <b>item_mst</B> containing following fields <br>
<br>
<u><b>
item_code description leadtim kanbandate</u></b><br>
11001318 aaaaaaaaaaa 15 22/04/2004<br>
11001319 aaaaaaaaaaa 15 02/12/2004<br>
11001320 aaaaaaaaaaa 15 14/07/2005<br>
11001321 aaaaaaaaaaa 15 23/02/2004<br>
11001322 aaaaaaaaaaa 15 05/10/2004<br>
11001323 aaaaaaaaaaa 15 17/05/2004<br>
11001324 aaaaaaaaaaa 15 27/12/2004<br>
11001325 aaaaaaaaaaa 15 07/08/2004<br>
<br><br><br><b>
From the above two tables I want the combine SQL query which will display item_code its description ,kanbandate from item_mst table and will also display the minimum ent_dt of each corresponding item_code alongwith the qty and doc_no.the item_code should not be repeated .<br>
I want to run the query from sql query analyzer</b><br><br>
the result should be like this<br><br>
<b></u>item_code desc ent_dt qty doc_no</b></u>
<br>
11001318 aaaaaaaaaaa 09/09/2003 5 56300501<br>
11001319 aaaaaaaaaaa 22/06/2004 0 56300504<br>
11001320 aaaaaaaaaaa 21/06/2003 1 56300508<br>
11001321 aaaaaaaaaaa 15/07/2004 1 56300510<br>
11001322 aaaaaaaaaaa 02/06/2004 1 56300513<br>
11001323 aaaaaaaaaaa 08/05/2004 4 56300515<br>
<br>
<br>
plz help me out ASAP
null
Message was edited by:
aanchal_2008can you try this,
SELECT DISTINCT im.item_code,
im.descR,
gd.ent_dt,
gd.qty,
gd.doc_no
FROM item_mst im,
grn_dtl gd
WHERE im.item_code = gd.item_code (+)
AND NOT EXISTS (
SELECT 'later detail'
FROM grn_dtl gd2
WHERE gd2.item_code = gd.item_code
AND gd2.ent_dt > gd.ent_dt)
ITEM_CODE DESCR ENT_DT QTY DOC_NO
11001318 aaaaaaaaaaa 2/12/2005 6 563005
11001319 aaaaaaaaaaa 6/22/2004 0 563005
11001320 aaaaaaaaaaa 6/9/2005 0 563005
11001321 aaaaaaaaaaa 12/5/2005 5 563005
11001322 aaaaaaaaaaa 6/22/2004 2 563005
11001323 aaaaaaaaaaa 9/12/2004 1 563005
11001324 aaaaaa
11001325 aaaaaa
8 rows selected -
Plz help me in this query for the tree
hi All
I want to bulid tree that start with for example
schema name "scott"
then table "dept,emp
then ename in table emp
root scott
parent dept
child emp_name
please help me in the query ?user222 wrote:
any help my dearsIf you can draw one simple tree example. Then it will be easy to create query. Because i am confuse about the output. Just draw one example of your desired output tree. Then it will help to find solution.
And while writing query or any example so use the 6 digit before and after your query or example to keep the formatting in orignal format. Otherwise it becomes hard to read.
For more information see FAQ on right corner for page.
-Ammad -
hello plz help me wat i can do for this error and plz also tell me where to place the POI api in tomcat directory.........
The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 22 in the jsp file: /HSSFExample.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:13: ';' expected
import org.a
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:8: package org.apache.poi.poifs.filesystem does not exist
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:9: package org.apache.poi.hssf.record does not exist
import org.apache.poi
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:11: package org.apache.poi.hssf.model does not exist
import org.apache.poi.hssf.model.*;
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:12: package org.apache.poi.hssf.usermodel does not exist
import org.apache.poi.hssf.usermodel.*;
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:13: cannot resolve symbol
symbol : class a
location: package org
import org.a
^
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:74: cannot resolve symbol
symbol : class POIFSFileSystem
location: class org.apache.jsp.HSSFExample_jsp
POIFSFileSystem fs =
^
An error occurred at line: 22 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:75: cannot resolve symbol
symbol : class POIFSFileSystem
location: class org.apache.jsp.HSSFExample_jsp
new POIFSFileSystem(new FileInputStream(filename));
^
An error occurred at line: 22 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:76: cannot resolve symbol
symbol : class HSSFWorkbook
location: class org.apache.jsp.HSSFExample_jsp
HSSFWorkbook wb = new HSSFWorkbook(fs);
^
An error occurred at line: 22 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:76: cannot resolve symbol
symbol : class HSSFWorkbook
location: class org.apache.jsp.HSSFExample_jsp
HSSFWorkbook wb = new HSSFWorkbook(fs);
^
An error occurred at line: 35 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:89: cannot resolve symbol
symbol : class HSSFSheet
location: class org.apache.jsp.HSSFExample_jsp
HSSFSheet sheet = wb.getSheetAt(k);
^
An error occurred at line: 35 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:94: cannot resolve symbol
symbol : class HSSFRow
location: class org.apache.jsp.HSSFExample_jsp
HSSFRow row = sheet.getRow(r);
^
An error occurred at line: 48 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:108: cannot resolve symbol
symbol : class HSSFCell
location: class org.apache.jsp.HSSFExample_jsp
HSSFCell cell = row.getCell(c);
^
An error occurred at line: 48 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:115: cannot resolve symbol
symbol : variable HSSFCell
location: class org.apache.jsp.HSSFExample_jsp
case HSSFCell.CELL_TYPE_FORMULA :
^
An error occurred at line: 48 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:119: cannot resolve symbol
symbol : variable HSSFCell
location: class org.apache.jsp.HSSFExample_jsp
case HSSFCell.CELL_TYPE_NUMERIC :
^
An error occurred at line: 48 in the jsp file: /HSSFExample.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\examples\HSSFExample_jsp.java:125: cannot resolve symbol
symbol : variable HSSFCell
location: class org.apache.jsp.HSSFExample_jsp
case HSSFCell.CELL_TYPE_STRING :
^
16 errors
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:445)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)You can put the POI jar file in the WEB-INF/lib directory of your application, or if you want to use it in multiple applications you can put it in the tomcat 4.1/shared/lib directory.
-
Plz help me with this data insertion code
Hi,
I am listing a code below ,I am able to insert only one row of value.
Then i get SQLException.General Exception and a Lock record MSAccess file is generated where .mdb file is stored.
public void throwtodatabase()
String gameid;
ResultSet rs=null;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
con=DriverManager.getConnection ("jdbc:odbc:MyData","","");
Statement stat3=con.createStatement();
rs=stat3.executeQuery("select * from sudoko");
while (rs.next()) {
pctr=pctr+1;
stat3.close();
con.close();
catch(Exception g)
JFrame ob2=new JFrame();
JOptionPane.showMessageDialog(ob2,g.toString(), "Message", JOptionPane.INFORMATION_MESSAGE);
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
con=DriverManager.getConnection ("jdbc:odbc:MyData","","");
gameid="G00"+String.valueOf(pctr);
PreparedStatement stat=null;
for (int t1=1;t1<=9;t1++) {
for (int t2=1;t2<=9;t2++) {
stat=con.prepareStatement("Insert into Sudoko(gameid,row,col,val) values(?,?,?,?)");
stat.setString(1,gameid);
stat.setString(2,String.valueOf(t1));
stat.setString(3,String.valueOf(t2));
stat.setString(4,String.valueOf(array_map[t1][t2]));
stat.execute();
con.close();
catch(Exception xd)
JFrame ob2=new JFrame();
JOptionPane.showMessageDialog(ob2,xd.toString(), "Message", JOptionPane.INFORMATION_MESSAGE);
}Plz help.Thanx in advance.Have this stacktrace
java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(Unknown Source)
at Sudoko.throwtodatabase(Sudoko.java:1120)
at Sudoko.generate_random_boards(Sudoko.java:1064)
at Sudoko.actionPerformed(Sudoko.java:205)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
n Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source) -
Accent insensitive Search - plz help me correcting this query
Hello,
I just realized that with that query, if I search for "Montreal" (without the accent), I have all the following results, which is what I want
SELECT
"ID","TIT"
from "REGDOSSIERS" "RDO"
where
TRANSLATE(UPPER("TIT"),'ÀÂÉÈÊÎÔÛÙÜ','AAEEEIOUUU')
like upper(nvl(replace('%' || "P1_REPORT_SEARCH || '%',' ','%'),"TIT"))
RESULTS
TIT
Annuaires Lovell (Montréal et banlieue)
Juridiction royale de Montréal. Dossiers, 1677-1769
Montreal Witness, 1845-1938
{code}
But how to change it so when I look for: "Montréal" (with the accent) , I have also the same results? Right now, with Montréal, I have nothing
thanks,
Roseline
Edited by: Roseline on 2009-10-01 18:58
Edited by: Roseline on Oct 1, 2009 7:34 PMIf you are on Oracle 10g you can use regexp expressions to do the search.
Example
with testdata as (select 'Montreal' txt from dual
union all select 'Montréal' txt from dual
union all select 'Montreâl' txt from dual
union all select 'Montreaux' txt from dual)
/* end of test data creation */
select txt from testdata
where regexp_like (txt, 'Montr[[=e=]]al');
txt
Montreal
Montréal[[=e=]] would be an equivalence class for the letter "e" and includes also searches for é, è, ê etc.
The best solution mainly depends how your search string is build.
If you just want to sort, then the nlssort function would be useful.
Mentioning Nlssort I remembered there is a much better way to implement Accent insensitive search. You just need to set your NLS_SORT parameter correctly. Either to BINARY_AI (the AI means accent and case insensitiv) or add _AI to your nls langage.
example
ALTER SESSION SET NLS_COMP=LINGUISTIC;
alter session set nls_sort = 'FRENCH';
with testdata as (select 'Montreal' txt from dual
union all select 'Montréal' txt from dual
union all select 'Montreâl' txt from dual
union all select 'Montreaux' txt from dual)
/* end of test data creation */
select txt from testdata
where txt = 'MONTREAL';
no rows selects
/* now change the nls sorting */
alter session set nls_sort = 'FRENCH_AI';
with testdata as (select 'Montreal' txt from dual
union all select 'Montréal' txt from dual
union all select 'Montreâl' txt from dual
union all select 'Montreaux' txt from dual)
/* end of test data creation */
select txt from testdata
where txt = 'MONTREAL';
txt
Montreal
Montréal
MontreâlEdited by: Sven W. on Oct 2, 2009 8:34 AM
Edited by: Sven W. on Oct 2, 2009 10:22 AM - corrected misleading regexp example. -
Dear experts. help me with this query plz.
i am generating a report in dev6i.
the following query is working properly. and also fetching the data with outer(+) join.
select i.itemcode,sum(gs.approved)-sum(iss.issuedqty)
from ims_itemcode i,ims_issues iss, ims_grns gs
where i.itemcode=gs.itemcode and gs.itemcode=iss.itemcode(+) group by i.itemcode;
but i have to join two more tables (ims_issuem,ims_grnm)
after adding these two tables the query will be
select i.itemcode,sum(gs.approved)-sum(iss.issuedqty)
from ims_itemcode i,ims_issues iss, ims_grns gs, ims_issuem im, ims_grnm gm
where i.itemcode=gs.itemcode and gs.itemcode=iss.itemcode(+) and gm.grnmserial=gs.grnsserial and
im.issuemserial=iss.issuesserial group by i.itemcode;
now the query works but doesn't fetch the results with outer(+) join. it just picks the results which are matching in both the tables but i want the results along with the outer(+) join.
what is the problem in the second query please help.You need to add more outer join.
Try this..
select i.itemcode,sum(gs.approved)-sum(iss.issuedqty)
from ims_itemcode i,ims_issues iss, ims_grns gs, ims_issuem im, ims_grnm gm
where i.itemcode=gs.itemcode (+)
and gs.itemcode=iss.itemcode(+)
and gm.grnmserial(+)=gs.grnsserial
and im.issuemserial(+)=iss.issuesserial
group by i.itemcode;if not work, try a trick. After your first query work. add one table and check if need add outer join.
Hope this helps
Hamid -
Plz help me rectify this query
Hi,
I am trying to use a OR condition in NOT IN clause, is the SQL statement correct way:
select name from master_list where ((id not in (select id from deleted_list)) OR (id not in (select id from inactive_list)))
I there are two tables which contain ids which should be in not in clause.
Thanks,
RajaHi,
Whenever you post fomatted text on this site (and code should always be formatted), type these 6 characters:
{code}
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
What is the problem?
Are you getting an error message?
Why not post the error message?
Are you getting the wrong results?
Post some sample data, and the results you want to get from that data.
NOT IN will never be TRUE if the sub-query includes any NULL rows. I can't tell if that's possible with your tables or not.. -
Please help me with this query -- i am trying with Dense rank
version 10g
i received a quote for an account. if the same quote is received under different account then i should mark the previous account received as deleted.
please help me .
/* Formatted on 2010/06/28 14:13 (Formatter Plus v4.8.8) */
WITH temp AS
(SELECT '1-11TWQL' quote_id, 'COPS' ACCOUNT, 'Ordered' status,
TO_DATE ('12/23/2009 3:37:54',
'mm/dd/yyyy hh:mi:ss PM'
) captured_date
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'RFS',
TO_DATE ('12/23/2009 3:37:50', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'Rejected',
TO_DATE ('12/23/2009 3:37:52', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:51', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Ordered',
TO_DATE ('12/23/2009 3:04:24', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'RFS',
TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Rejected',
TO_DATE ('12/23/2009 3:04:22', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Validated',
TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'RFS',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'RFS',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8Z', 'COPS', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL
UNION ALL
SELECT '1-249A8Z', 'COPS', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
FROM DUAL)
SELECT quote_id, ACCOUNT, status, captured_date,
DENSE_RANK () OVER (PARTITION BY quote_id ORDER BY quote_id,
ACCOUNT) rn
-- ,CASE DENSE_RANK () OVER (PARTITION BY quote_id ORDER BY quote_id,
-- ACCOUNT)
-- WHEN 1
-- THEN 'Y'
-- ELSE 'N'
-- END deleted_flag
FROM temp
ORDER BY quote_id, captured_date;output required
WITH temp AS
(SELECT '1-11TWQL' quote_id, 'COPS' ACCOUNT, 'Ordered' status,
TO_DATE ('12/23/2009 3:37:54',
'mm/dd/yyyy hh:mi:ss PM'
) captured_date, 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'RFS',
TO_DATE ('12/23/2009 3:37:50', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'Rejected',
TO_DATE ('12/23/2009 3:37:52', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:51', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Ordered',
TO_DATE ('12/23/2009 3:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'RFS',
TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Rejected',
TO_DATE ('12/23/2009 3:04:22', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-11TWQL', 'D1', 'Validated',
TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'RFS',
TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Rejected',
TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'COPS', 'Validated',
TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM'), 'Y' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'RFS',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'RFS',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8X', 'D1', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8Z', 'COPS', 'Validated',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL
UNION ALL
SELECT '1-249A8Z', 'COPS', 'Ordered',
TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM'), 'N' deleted_flag
FROM DUAL)
SELECT quote_id, ACCOUNT, status, captured_date, deleted_flag
FROM temp
ORDER BY quote_id, captured_date;try to wrap your query to become an in-line view. use a case statement or decode to your derived column RN from the analytic query of DENSE RANK. either way they both will work.
SQL> WITH temp AS
2 (SELECT '1-11TWQL' quote_id, 'COPS' ACCOUNT, 'Ordered' status,
3 TO_DATE ('12/23/2009 3:37:54',
4 'mm/dd/yyyy hh:mi:ss PM'
5 ) captured_date
6 FROM DUAL
7 UNION ALL
8 SELECT '1-11TWQL', 'COPS', 'RFS',
9 TO_DATE ('12/23/2009 3:37:50', 'mm/dd/yyyy hh:mi:ss PM')
10 FROM DUAL
11 UNION ALL
12 SELECT '1-11TWQL', 'COPS', 'Rejected',
13 TO_DATE ('12/23/2009 3:37:52', 'mm/dd/yyyy hh:mi:ss PM')
14 FROM DUAL
15 UNION ALL
16 SELECT '1-11TWQL', 'COPS', 'Validated',
17 TO_DATE ('12/23/2009 3:37:51', 'mm/dd/yyyy hh:mi:ss PM')
18 FROM DUAL
19 UNION ALL
20 SELECT '1-11TWQL', 'D1', 'Ordered',
21 TO_DATE ('12/23/2009 3:04:24', 'mm/dd/yyyy hh:mi:ss PM')
22 FROM DUAL
23 UNION ALL
24 SELECT '1-11TWQL', 'D1', 'RFS',
25 TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
26 FROM DUAL
27 UNION ALL
28 SELECT '1-11TWQL', 'D1', 'Rejected',
29 TO_DATE ('12/23/2009 3:04:22', 'mm/dd/yyyy hh:mi:ss PM')
30 FROM DUAL
31 UNION ALL
32 SELECT '1-11TWQL', 'D1', 'Validated',
33 TO_DATE ('12/23/2009 3:04:23', 'mm/dd/yyyy hh:mi:ss PM')
34 FROM DUAL
35 UNION ALL
36 SELECT '1-249A8X', 'COPS', 'RFS',
37 TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
38 FROM DUAL
39 UNION ALL
40 SELECT '1-249A8X', 'COPS', 'RFS',
41 TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
42 FROM DUAL
43 UNION ALL
44 SELECT '1-249A8X', 'COPS', 'RFS',
45 TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
46 FROM DUAL
47 UNION ALL
48 SELECT '1-249A8X', 'COPS', 'Rejected',
49 TO_DATE ('3/5/2010 12:04:24', 'mm/dd/yyyy hh:mi:ss PM')
50 FROM DUAL
51 UNION ALL
52 SELECT '1-249A8X', 'COPS', 'Rejected',
53 TO_DATE ('3/16/2010 7:55:50', 'mm/dd/yyyy hh:mi:ss PM')
54 FROM DUAL
55 UNION ALL
56 SELECT '1-249A8X', 'COPS', 'Rejected',
57 TO_DATE ('3/16/2010 7:55:51', 'mm/dd/yyyy hh:mi:ss PM')
58 FROM DUAL
59 UNION ALL
60 SELECT '1-249A8X', 'COPS', 'Validated',
61 TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
62 FROM DUAL
63 UNION ALL
64 SELECT '1-249A8X', 'COPS', 'Validated',
65 TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
66 FROM DUAL
67 UNION ALL
68 SELECT '1-249A8X', 'COPS', 'Validated',
69 TO_DATE ('12/23/2009 3:37:54', 'mm/dd/yyyy hh:mi:ss PM')
70 FROM DUAL
71 UNION ALL
72 SELECT '1-249A8X', 'D1', 'Ordered',
73 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
74 FROM DUAL
75 UNION ALL
76 SELECT '1-249A8X', 'D1', 'Ordered',
77 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
78 FROM DUAL
79 UNION ALL
80 SELECT '1-249A8X', 'D1', 'RFS',
81 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
82 FROM DUAL
83 UNION ALL
84 SELECT '1-249A8X', 'D1', 'RFS',
85 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
86 FROM DUAL
87 UNION ALL
88 SELECT '1-249A8X', 'D1', 'Validated',
89 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
90 FROM DUAL
91 UNION ALL
92 SELECT '1-249A8X', 'D1', 'Validated',
93 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
94 FROM DUAL
95 UNION ALL
96 SELECT '1-249A8Z', 'COPS', 'Validated',
97 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
98 FROM DUAL
99 UNION ALL
100 SELECT '1-249A8Z', 'COPS', 'Ordered',
101 TO_DATE ('3/26/2010 12:32:27', 'mm/dd/yyyy hh:mi:ss PM')
102 FROM DUAL)
103 select vt.quote_id,
104 vt.account,
105 vt.status,
106 vt.captured_date,
107 case when vt.rn = 1 then 'N'
108 else 'Y'
109 end deleted_flag
110 from (SELECT quote_id, ACCOUNT, status, captured_date,
111 DENSE_RANK () OVER (PARTITION BY quote_id ORDER BY quote_id, ACCOUNT) rn
112 FROM temp
113 ORDER BY quote_id, captured_date) vt;
QUOTE_ID ACCOUNT STATUS CAPTURED_DATE DELETED_FLAG
1-11TWQL D1 Rejected 23-Dec-2009 3 Y
1-11TWQL D1 RFS 23-Dec-2009 3 Y
1-11TWQL D1 Validated 23-Dec-2009 3 Y
1-11TWQL D1 Ordered 23-Dec-2009 3 Y
1-11TWQL COPS RFS 23-Dec-2009 3 N
1-11TWQL COPS Validated 23-Dec-2009 3 N
1-11TWQL COPS Rejected 23-Dec-2009 3 N
1-11TWQL COPS Ordered 23-Dec-2009 3 N
1-249A8X COPS Validated 23-Dec-2009 3 N
1-249A8X COPS Validated 23-Dec-2009 3 N
1-249A8X COPS Validated 23-Dec-2009 3 N
1-249A8X COPS RFS 05-Mar-2010 1 N
1-249A8X COPS Rejected 05-Mar-2010 1 N
1-249A8X COPS RFS 16-Mar-2010 7 N
1-249A8X COPS Rejected 16-Mar-2010 7 N
1-249A8X COPS Rejected 16-Mar-2010 7 N
1-249A8X COPS RFS 16-Mar-2010 7 N
1-249A8X D1 Ordered 26-Mar-2010 1 Y
1-249A8X D1 Ordered 26-Mar-2010 1 Y
1-249A8X D1 RFS 26-Mar-2010 1 Y
1-249A8X D1 RFS 26-Mar-2010 1 Y
1-249A8X D1 Validated 26-Mar-2010 1 Y
1-249A8X D1 Validated 26-Mar-2010 1 Y
1-249A8Z COPS Validated 26-Mar-2010 1 N
1-249A8Z COPS Ordered 26-Mar-2010 1 N
25 rows selected
SQL> -
Plz help me with this requirement
hi to all,
i have designed a module pool program
in first screen i have 2 pushbutton (screen no 100)
when i click on first button i will goto screen 1001 i.e vendor details
when i click on second button i will goto screen 2001 where i get vendor bank details
my requirement is that in second screen when i click a button. it display TABLE CONTROL with all the bank details for that vendor
how to implement it
help me out
here is my code
INCLUDE ZB14HAI_MP1_TOP . " global Data
INCLUDE ZB14HAI_MP1_O01 . " PBO-Modules
INCLUDE ZB14HAI_MP1_I01 . " PAI-Modules
INCLUDE ZB14HAI_MP1_F01
*& Include ZB14HAI_MP1_TOP Module pool ZB14HAI_MP1
PROGRAM ZB14HAI_MP1 MESSAGE-ID MSGCLASS.
tables: lfa1,lfbk.
data:ok_code type sy-ucomm.
data : it_bank type table of lfbk,
wa_bank like line of it_bank.
CONTROLS TBCL_4000 TYPE TABLEVIEW USING SCREEN 4000.
*& Include ZB14HAI_MP1_O01
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZBPF_STATUS1'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module STATUS_2001 OUTPUT
text
MODULE STATUS_2001 OUTPUT.
SET PF-STATUS 'ZBPF_STATUS2'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_2001 OUTPUT
*& Module STATUS_4000 OUTPUT
text
MODULE STATUS_4000 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_4000 OUTPUT
*& Module DISPLAY_TBCL_4000 OUTPUT
text
MODULE DISPLAY_TBCL_4000 OUTPUT.
LFBK-LIFNR = WA_BANK-LIFNR.
LFBK-BANKS = WA_BANK-BANKS.
LFBK-BANKL = WA_BANK-BANKL.
LFBK-KOINH = WA_BANK-KOINH.
LFBK-EBPP_ACCNAME = WA_BANK-EBPP_ACCNAME.
ENDMODULE. " DISPLAY_TBCL_4000 OUTPUT
*& Include ZB14HAI_MP1_I01
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN'VEND'.
CALL SCREEN 1001.
WHEN 'BANK'.
CALL SCREEN '2001'.
ENDCASE.
ENDMODULE.
" USER_COMMAND_0100 INPUT
*& Module USER_COMMAND_1001 INPUT
text
MODULE USER_COMMAND_1001 INPUT.
CASE OK_CODE.
WHEN 'BACK'.
CALL SCREEN 0100.
WHEN 'DISP'.
PERFORM F_VEND_DISPLAY USING LFA1
CHANGING SY-DBCNT.
WHEN 'CHAN'.
PERFORM F_UPDATE CHANGING LFA1.
WHEN 'REFR'.
PERFORM F_REFRESH CHANGING LFA1.
WHEN 'CREA'.
PERFORM F_CREATE USING LFA1.
WHEN 'DELE'.
PERFORM F_DELETE CHANGING LFA1.
WHEN 'BNKD'.
PERFORM F_BANK USING LFA1-LIFNR CHANGING IT_BANK.
CALL SCREEN 4000.
ENDCASE.
ENDMODULE. " USER_COMMAND_1001 INPUT
*& Module USER_COMMAND_2001 INPUT
text
MODULE USER_COMMAND_2001 INPUT.
CASE OK_CODE.
WHEN 'BACK'.
CALL SCREEN '1001'.
CLEAR LFA1.
WHEN 'DISP'.
PERFORM F_GET_BANK USING LFBK
CHANGING SY-DBCNT.
WHEN 'CHAN'.
PERFORM F_UPDATE1 CHANGING LFBK.
WHEN 'REFR'.
PERFORM F_REFRESH1 CHANGING LFBK.
WHEN 'CREA'.
PERFORM F_CREATE1 USING LFBK.
WHEN 'DELE'.
PERFORM F_DELETE1 CHANGING LFBK.
ENDCASE.
ENDMODULE. " USER_COMMAND_2001 INPUT
" USER_COMMAND_4000 INPUT
*& Include ZB14HAI_MP1_F01
*& Form F_VEND_DISPLAY
text
-->P_LFA1 text
<--P_DBCNT text
FORM F_VEND_DISPLAY USING P_LFA1 LIKE LFA1
CHANGING P_DBCNT LIKE SY-DBCNT.
SELECT SINGLE * FROM LFA1 WHERE
LIFNR EQ LFA1-LIFNR.
IF SY-DBCNT EQ 0.
MESSAGE E001(ZMSGCLASS).
ENDIF.
ENDFORM. " F_VEND_DISPLAY
*& Form F_GET_BANK
text
-->P_LFB1 text
<--P_SY_DBCNT text
FORM F_GET_BANK USING P_LFB1 LIKE LFBK
CHANGING P_SY_DBCNT LIKE SY-DBCNT.
SELECT SINGLE * FROM LFBK WHERE LIFNR EQ LFBK-LIFNR.
IF P_SY_DBCNT EQ 0.
MESSAGE E002(ZMSGCLASS).
ENDIF.
ENDFORM. " F_GET_BANK
*& Form F_UPDATE
text
<--P_LFA1 text
FORM F_UPDATE CHANGING P_LFA1 LIKE LFA1.
UPDATE LFA1.
IF SY-SUBRC EQ 0.
MESSAGE I000(ZHNC) WITH 'RECORDS UPDATED SUCESSFULLY'.
ENDIF.
ENDFORM. " F_UPDATE
*& Form F_REFRESH
text
<--P_LFA1 text
FORM F_REFRESH CHANGING P_LFA1 LIKE LFA1.
CLEAR LFA1.
ENDFORM. " F_REFRESH
*& Form F_CREATE2
text
-->P_LFA1 text
FORM F_CREATE USING P_LFA1 LIKE LFA1.
INSERT INTO LFA1 VALUES P_LFA1.
IF SY-SUBRC EQ 0.
MESSAGE S000(ZHNC) WITH 'VENDOR SUCESSFULLY CREATED'.
ELSE.
MESSAGE E000(ZHNC) WITH 'VENDOR ALREADY EXIST'.
ENDIF.
ENDFORM. " F_CREATE
*& Form F_DELETE
text
<--P_LFA1 text
FORM F_DELETE CHANGING P_LFA1 LIKE LFA1.
DELETE FROM LFA1 WHERE LIFNR EQ LFA1-LIFNR.
IF SY-SUBRC EQ 0 .
MESSAGE S000(ZHNC) WITH 'RECORD SUCESSFULLY DELETED'.
ENDIF.
ENDFORM. " F_DELETE
*& Form F_UPDATE1
text
<--P_LFA1 text
FORM F_UPDATE1 CHANGING P_LFBK LIKE LFBK.
UPDATE LFBK.
IF SY-SUBRC EQ 0.
MESSAGE I000(ZHNC) WITH 'RECORDS UPDATED SUCESSFULLY'.
ENDIF.
ENDFORM. " F_UPDATE1
*& Form F_REFRESH1
text
<--P_LFA1 text
FORM F_REFRESH1 CHANGING P_LFBK LIKE LFBK.
CLEAR LFBK.
ENDFORM. " F_REFRESH1
*& Form F_CREATE1
text
-->P_LFA1 text
FORM F_CREATE1 USING P_LFBK LIKE LFBK.
INSERT INTO LFBK VALUES P_LFBK.
IF SY-SUBRC EQ 0.
MESSAGE S000(ZHNC) WITH 'VENDOR SUCESSFULLY CREATED'.
ELSE.
MESSAGE E000(ZHNC) WITH 'VENDOR ALREADY EXIST'.
ENDIF.
ENDFORM. " F_CREATE1
*& Form F_DELETE1
text
<--P_LFA1 text
FORM F_DELETE1 CHANGING P_LFBK LIKE LFBK.
ENDFORM. " F2_DELETE1
*& Form F_BANK
text
-->P_LFA1_LIFNR text
<--P_IT_BANK text
FORM F_BANK USING P_LFA1_LIFNR LIKE LFA1-LIFNR
CHANGING P_IT_BANK LIKE IT_BANK.
SELECT * FROM LFBK INTO CORRESPONDING FIELDS OF TABLE IT_BANK
WHERE LIFNR EQ P_LFA1_LIFNR.
ENDFORM. " F_BANK
full points to be awardedhi ,
try this code
*& Module pool SAPMZ50818_MODUL_TABLECNTRL *
PROGRAM TITLE : SALES ORDER LINE ITEM DESPLAY *
AREA : SD *
AUTHOR : Fareeda .s *
CREATED ON : 24/10/2007 *
OBJECT TYPE : MODULE POOL *
DESCRIPTION : The objective of this module pool is to display*
the list of sales orders within a given range *
of customers entered on the selection screen. *
Modification Log *
Author : FAREEDA *
Date of Change : 25/10/07 *
Functional Specs # : *
Correction Request # : *
Description of Change : PF_STATUS *
PROGRAM SAPMZ50818_MODUL_TABLECNTRL MESSAGE-ID ZFAR.
TABLES KNA1.
First internal table for screen 200
DATA: BEGIN OF IT_TAB OCCURS 0,
CHK,
VBELN TYPE VBAK-VBELN,
KUNNR TYPE VBAK-KUNNR,
ERNAM TYPE VBAK-ERNAM,
AUDAT TYPE VBAK-AUDAT,
VBTYP TYPE VBAK-VBTYP,
END OF IT_TAB.
Second internal table for screen 300
DATA: BEGIN OF IT_TAB1 OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
PSTYV TYPE VBAP-PSTYV,
POSAR TYPE VBAP-POSAR,
END OF IT_TAB1.
ok_code declaration
DATA OK_CODE TYPE SY-UCOMM.
DATA: V_Kna1 LIKE KNA1.
*& Module STATUS_0100 OUTPUT
PF-STATUS FOR SCREEN 0100
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'FAR'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'DISP' OR SPACE.
SELECT SINGLE *
FROM KNA1
INTO KNA1
WHERE KUNNR = KNA1-KUNNR.
SELECT *
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE IT_TAB
WHERE KUNNR = KNA1-KUNNR.
IF SY-SUBRC <> 0.
MESSAGE 'NO RECORDS FOUND' TYPE 'E'.
ENDIF.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module USER_COMMAND_0200 INPUT
MODULE USER_COMMAND_0200 INPUT.
CONTROLS TC1 TYPE TABLEVIEW USING SCREEN 200.
SET PF-STATUS 'ZFAR'.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 100.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'DISP'.
CLEAR IT_TAB.
READ TABLE IT_TAB WITH KEY CHK = 'X'.
IF NOT IT_TAB-CHK IS INITIAL.
SELECT VBELN POSNR PSTYV POSAR
FROM VBAP
INTO TABLE IT_TAB1
WHERE VBELN = IT_TAB-VBELN.
*------Processing error
IF SY-SUBRC <> 0.
MESSAGE 'NO ITEMS FOUND' TYPE 'E'.
ENDIF.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Module STATUS_0200 OUTPUT
PF-STATUS FOR SCREEN 0200
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'ZFAR'.
ENDMODULE. " STATUS_0200 OUTPUT
**& Module STATUS_0300 OUTPUT
PF-STATUS FOR SCREEN 0300
*MODULE STATUS_0300 OUTPUT.
SET PF-STATUS 'FAR2'.
SET TITLEBAR 'TITLE'.
*ENDMODULE. " STATUS_0300 OUTPUT
*& Module MODIFY INPUT
modifying table input
MODULE MODIFY INPUT.
MODIFY IT_TAB INDEX TC1-CURRENT_LINE.
ENDMODULE. " MODIFY INPUT
*& Module USER_COMMAND_0300 INPUT
table control for third screen
MODULE USER_COMMAND_0300 INPUT.
CONTROLS TC2 TYPE TABLEVIEW USING SCREEN 300.
SET PF-STATUS 'FAR2'.
*------case
CASE OK_CODE.
leave to previous screen.
WHEN 'DISP'.
LEAVE TO SCREEN 200.
WHEN 'EXIT'.
LEAVE PROGRAM.
error record no existing sales item found
IF SY-SUBRC <> 0.
MESSAGE 'NO SA_ITEMS FOUND' TYPE 'E'.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0300 INPUT
*& Module VALIDATE_KUNNR INPUT
validating kunnr
MODULE VALIDATE_KUNNR INPUT.
V_KNA1 = KNA1.
SELECT SINGLE *
FROM KNA1
INTO KNA1
WHERE KUNNR = KNA1-KUNNR.
*------Process information
IF SY-SUBRC <> 0.
CLEAR KNA1.
KNA1-KUNNR = V_KNA1-KUNNR.
CASE OK_CODE.
leave program
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
raises an error that no customers found.
MESSAGE 'NO CUSTOMER FOUND' type 'E'.
LEAVE TO SCREEN 100.
ENDIF.
ENDMODULE. " VALIDATE_KUNNR INPUT
Maybe you are looking for
-
How to change the default left alignment setting in Word 2010 professional (personal use)
Hi, I use Word 2010 Professional for my personal use at home, and somehow the default setting for the left alignment in a new Word document has been changed to a hanging indent at .25. So every time I open a new Word document, the left margin has a
-
Encrypted Live System on USB-thumb drive
Hey all, I am fed up with the different systems on various computers. So I want an Arch Linux Live System on an USB thumb drive I can carry around and plug into the computers I stumble upon. I want to be able to have some data (emails, favourites and
-
ADF-JSF: Application Performance Issue
Hello! My question or set of questions will be a bit vague...I am simply not sure where to look for problem(s). So here is what I have. Application implemented with ADF-JSF (JDEV ver:10.1.3.2.0). It basically has 5 pages. Each page containes user inp
-
Programmatically set clientAttribute
Hello I know that if you want to pass a value to a JS function, you set af:clientAttribute to a component, and then retrieve the value in JS using component.getProperty(...); I want to add the value of this attribute programmatically, but the only me
-
what the diff will make in service and _service without party_? thanq