Please Help in SQL
Hi All,
I need to create a hierarchial query with following expected output
Expected output
E1 E2 E3
Anuj Sharma
Anuj Sharma Ram Krishna Mishra
Anuj Sharma Ram Krishna Mishra Amit Garg
Anuj Sharma Ram Krishna Mishra Atul Gupta
Anuj Sharma Abnish Kumar Agarwal
Anuj Sharma Anonymous Pool
Anuj Sharma Sunil Sharma
Anuj Sharma Sunil Sharma Nimish Garg
Anuj Sharma Sunil Sharma Rahul Sharma
Anuj Sharma Sunil Sharma Satya Ranjan
Anuj Sharma Lalit Mohanso far I have done this and stuck on it, plz guide me
SELECT
DECODE(LEVEL,1,EMPLOYEENAME) E1,
DECODE(LEVEL,2,EMPLOYEENAME) E2,
DECODE(LEVEL,3,EMPLOYEENAME) E3
FROM
EMPLOYEE
CONNECT BY PRIOR
EMPLOYEEID=MANAGERID
START WITH EMPLOYEEID=1113 2 3 4 5 6 7 8 9 ;
E1 E2 E3
Anuj Sharma
Ram Krishna Mishra
Amit Garg
Atul Gupta
Abnish Kumar Agarwal
Anonymous Pool
Sunil Sharma
Nimish Garg
Rahul Sharma
Satya Ranjan
Lalit MohanThanks & Regards
Nimish Garg
is this what your after ?
select connect_by_root(employeename), lpad(' ',2*level,' ')||employeename
from employee
start with managerid is null
connect by prior employeeid = managerid;
Anuj Sharma Anuj Sharma
Anuj Sharma Lalit Mohan
Anuj Sharma Sunil Sharma
Anuj Sharma Nimish Garg
Anuj Sharma Satya Ranjan
Anuj Sharma Rahul Sharma
Anuj Sharma Ram Krishna Mishra
Anuj Sharma Amit Gupta
Anuj Sharma Atul Gupta
Anuj Sharma Ram Krishna Mishra
Anuj Sharma Amit Gupta
Anuj Sharma Atul Gupta
Anuj Sharma Abnish Kumar Agarwal
Anuj Sharma Abnish Kumar Agarwal
Anuj Sharma Anonymous Pool
Anuj Sharma Anuj Sharma
Anuj Sharma Lalit Mohan
Anuj Sharma Sunil Sharma
Anuj Sharma Nimish Garg
Anuj Sharma Satya Ranjan
Anuj Sharma Rahul Sharma
Anuj Sharma Ram Krishna Mishra
Anuj Sharma Amit Gupta
Anuj Sharma Atul Gupta
Anuj Sharma Ram Krishna Mishra
Anuj Sharma Amit Gupta
Anuj Sharma Atul Gupta
Anuj Sharma Abnish Kumar Agarwal
Anuj Sharma Abnish Kumar Agarwal
Anuj Sharma Anonymous Pool
Similar Messages
-
Hello please help me with an sql, I have a table with 2 fields, I want to check if one of the field is blank, mining that it dosn't contain anything.
if table called Test has 2 fields name ,age.
how do I check in sql if age is blank.
thanksAre you trying to do this through mSQL in Lite?
- Junius -
Hi, I want to search for account balance that is less than $10.00 from my database. My account balance is in 'varchar'.
I try to use the following sql statemennt but it's not working, can anybody tell me the correct sql statement?
String balance="10.00";
SELECT * FROM ACCOUNT WHERE balance < '"+balance+"'Hi, thanks mohan for answering my question. I solve my problem in another way. Bu now , I have problem with the following sql statement, please check for me.
I want to display the account info where the account balance is less than 10.00.
my ACCCOUNT table
account number customer_id admin_id balance interest_rate start_date
123456 1234 1 5.00 3.21 5/11/2001
<%@ page import="java.sql.*"%>
<%try
String url = "jdbc:jrun:sqlserver://127.0.0.1:1433;databaseName=bank";;;
Class.forName("allaire.jrun.jdbc.JRunDriver").newInstance();
Connection conn=
DriverManager.getConnection(url,"sa","bepyng");
String sql = "SELECT customer_id,account_num,balance,start_date,interest_rate FROM ACCOUNT WHERE balance < 10.00";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
String id = rs.getString(1);
%>
<%=id%>
<table width="63%" border="0" align="center" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td>Customer ID</td>
<td><%=rs.getString("customer_id")%></td>
</tr>
<tr>
<td width="42%">Account Number</td>
<td width="58%"><%=rs.getString("account_num")%></td>
</tr>
<tr>
<td>Balance</td>
<td><%=rs.getString("balance")%></td>
</tr>
<tr>
<td>Start Date</td>
<td><%=rs.getDate("start_date")%></td>
</tr>
<tr>
<td>Interest Rate</td>
<td><%=rs.getString("interest_rate")%></td>
</tr>
</table>
<%}
catch(Exception e)
System.out.println("An error occurred while connecting to onlinebanking database!"+e.getMessage());
%>
but I don't get anything, why?
Thanks in advance. -
I have a table named MEAL which contains a foreign key STU_NUM from
STUDENT table so i want to insert two values into MEAL table using the criteria of STU_NUM.
I have tried this code but it gives me Exception which says:
Failed to insertjava.sql.SQLException[Microsoft]
[ODBC Microsoft Access Driver]Missing semicolon(;)at the end of SQL
statement
String query = "INSERT INTO MEAL(MEAL_REL_MADE,MEAL_AMT_LOADED)VALUE("+
"'" + jtfAmLd.getText().trim() +"'" + "," +
"'" + jtfRM.getText().trim()+ "'" + ") WHERE MEAL.STU_NUM ='" + jtfStNo.getText().trim() + "'";
I'll glad if someone can help me with this kind of errorDrClap
I think this is the second time you have replied to
this question with the same answer.
rykkReally? I don't remember doing that. The other question must have been a cross-post, then, because I only have one answer in this thread. And I must have thought it was a good answer. -
Please Help with sql.Date problem
I have spent alot of time on what I thought would be an otherwise simple task, and I beleive I am close to completion but I need some much needed help. I have posted various forms of my code to try and acheive the solution but the responses received have been limited.
I am trying to delete a record from a MS Access database where a Date/Time field in the database (Err_Date) equals a date entered by the user via a textbox.
I finally have gotten the correct record to delete from the database, but what is very strange is that Tomcat is throwing a 'java.lang.NullPointerException' error. Then when I re-open the database the correct record is deleted.
Here is my code:
<%@page import="java.sql.*"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Date"%>
<%
Connection con = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
catch(Exception e){
out.println(e.getMessage());
ResultSet rs=null;
Statement stmt=null;
try {
stmt=con.createStatement();
String end = request.getParameter("To");//FROM TEXTBOX
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat ("dd/MM/yyyy");
java.util.Date d2 = df.parse(end);//CONVERT STRING TO UTIL DATE
java.sql.Date date2 = new java.sql.Date(d2.getTime());//CONVERT TO SQL
PreparedStatement stmnt = con.prepareStatement("DELETE FROM tblError WHERE Err_Date = ?");
stmnt.setDate(1, date2);
stmnt.executeUpdate();
stmnt.close();
//CLOSE RESULT SET
rs.close();
stmt.close();
con.close();
//CATCH EXCEPTIONS
catch (SQLException e) {
out.println(e.getMessage());
%>well, in case anyone ever runs into a problem this stupid again the solution is as follows.
the code to:
1. retrieve date from text box
2. covert string into util date
3. convert util date into sql date
4. delete from database
is all correct.
the problem is that I previously used String sql="SOME SQL DELETE" and then executed the result set, which of course I then had to close. This wasn't working so I switched to a Prepared Statement. I forgot to remove the 'rs.close()' statement in my code. So Tomcat was trying to close a result set that was never opened... -
Please help with SQL amount calulation
-- Results
with t as (
select 'P11877' Mstr_Program, 1 Year_of_study, 'BUSI1490' program_module, 20 no_of_stud, 1 rank, 30 program_credits, 30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 30, 60 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 90 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 30, 120 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 15, 45 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 75 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 15, 90 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 120 from dual)
select * from t;-- Each MSTR_PROGRAM can have 1 or many program_module
-- MSTR_PROGRAM's can run for 1 or 2 years (case above is two years) so some modules run in year 1 and some in year 2
-- NO_OF_STUD is the number of students on the module
-- RANK basically ranks the modules by the number of students on them grouped by program and year
-- e.g.row_number() OVER (PARTITION BY Mstr_Program, Year_of_study) ORDER BY COUNT(STUDENT_ID) DESC) rank
-- PROGRAM_CREDITS: each module has a fixed number of credits
-- CUMM_CREDITS: Increments the credit count of modules
-- SUM(program_credits * 10) OVER (PARTITION BY Mstr_Program, Year_of_study
-- ORDER BY count(STUDENT_ID) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
-- I want to trim of any modules once the CUM_CREDITS hits 120. As seen above. I achieve this by wrapping the main query is another SELECT then LIMIT
-- that WHERE cum_credit <=120.
-- But what I need is:
-- In some cases the the cumm_credit maybe on lets say 90credits then the next module is worth 40 credits. This next module will not show as it
-- will be greater than 120 credits, so i need to pro-rata it:
-- So if credit_count > 120, then the last module is counted pro-rata as follows: 1- ((credit count - 120) / credits from last module
-- Can anyone help with how I can incorporate this into my current code: The SELECT portion of the Original SQL is below: I simplified column names
-- e.t.c in the above so they wont be the same
SELECT * FROM (
SELECT
,SR_PROGRAM Mstr_Program
,DECODE (SORLCUR_YEAR, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) year_of_study
,SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module
,COUNT(student_ID) no_of_stud
,row_number() OVER (PARTITION BY sr_program,
DECODE (sr_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) ORDER BY COUNT(student_id) DESC, scbcrse_title asc) rank
,(SCT_CREDIT_HRS * 10) program_credits
,SUM(SCT_CREDIT_HRS * 10) OVER (PARTITION BY sr_program, DECODE (sorlcur_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR)
ORDER BY count(student_id) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE cumm_credit <=120
ORDER BY Mstr_Program, YEAR_OF_STUDY, RANK asc;Maybe
SELECT Mstr_Program,year_of_study,program_module,no_of_stud,rank,program_credits old_program_credits,cumm_credits old_cumm_credits,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
FROM (SELECT SR_PROGRAM Mstr_Program,
DECODE(SORLCUR_YEAR,1,1,2,2,3,3,4,3,SR_YEAR) year_of_study,
SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module,
COUNT(student_ID) no_of_stud,
row_number() OVER (PARTITION BY sr_program,DECODE(sr_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY COUNT(student_id) DESC,scbcrse_title) rank,
10 * SCT_CREDIT_HRS program_credits,
10 * SUM(SCT_CREDIT_HRS) OVER (PARTITION BY sr_program,DECODE(sorlcur_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY count(student_id) desc
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end
ORDER BY Mstr_Program,YEAR_OF_STUDY,RANKRegards
Etbin
Edited by: Etbin on 16.12.2011 8:50
with
t as /* simulating the result achieved */
(select 'P11877' Mstr_Program,1 Year_of_study, 'BUSI1490' program_module,20 no_of_stud,1 rank,30 program_credits,30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 40, 70 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 100 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 40, 140 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 50, 80 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 110 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 50, 160 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 190 from dual
select Mstr_Program,Year_of_study,program_module,no_of_stud,rank,program_credits old_credits,cumm_credits old_cumm,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
from t
where 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end -
Hi,
I'm trying to update a record but I don't know how to update one field in this record. This is my code so far
private void updateProcess() {
int nrows;
String sql = "UPDATE student SET s_first = '" + txtS_first.getText()
+ "', s_mi = '" + txtS_mi.getText()
+ "', s_last = '" + txtS_last.getText()
+ "', s_dob = TO_DATE('" + txtS_dob.getText() + "', 'MM/DD/YYYY')"
/* In a database table, after the s_dob column is f_id column, but a user will see info of this field by f_first and f_last instead of f_id. How can I update this column with f_id if a user's input is f_first and f_last? What if f_first and f_name that a user enters doesn't exist in the database, is there anyway to display an error for this case?
+ "', f_first = '" + txtF_first.getText()
+ "', f_last = '" + txtF_last.getText()
+ "' WHERE s_id = " + txtS_id.getText();
try {
nrows = stmt.executeUpdate(sql);
// I think this part I'm doing wrong because the text area doesn't display these strings
if(nrows > 0) {
lblShowResult.setText("Update successed");
lblShowResult.setVisible(true);
} // end if
else {
lblShowResult.setText("Update failed");
lblShowResult.setVisible(true);
} // end else
rset.close();
} // end try
catch (SQLException e) {}
catch (NullPointerException e){}
} // end updateProcessIf you read the docs for executeUpdate, you'll see that it returns the number of rows affected. So if it returns zero, then no rows matched.
Also, you should be using PreparedStatement rather than Statement. Then you won't have to worry about weird characters in strings or formatting dates (you can just give it a java.sql.Date object). -
Please help oracle sql counts question
Hi,
I am trying to get some counts on a client list where l count those clients who are getting the program
2353335 ONLY (which may be none of the cases in the example below but this is an obviously smaller subset of these data).
How can I count all the client ids where program = 2353335 but not where program = 2340845 or program =2353340?
Thanks in advance
Client_id Program
260 2340845
260 2353340
510 2353340
510 2353335
510 2340845
520 2340845
520 2353340
525 2340845
525 2353335
765 2353340
1260 2340845
1260 2353335
1595 2353340
1595 2340845
1615 2340845
1835 2353340
1840 2353340
1840 2353335
1840 2340845
1845 2353335
1845 2340845Hi,
if you want to select clients that only have program 2353335 and no other, the query below would help:
select client_id
from mytab m
where program = 2353335
and not exists (select 1 from mytab where client_id = m.client_id and program != 2353335);Just replace select client_id with select count(*) if you want just to count rows.
Best regards,
Nikolay
Edited by: Nikolay Savvinov on Jan 26, 2012 11:24 PM -
Hi All,
For some reason, adding the second if wont allow the query to parse. The bind variable and collum names are correct. Any other ideas. Thanks
John
declare
q varchar2(32767);
begin
q:=' select FK_FISH_LOT_ACC_NUM as ACCESSION_NUMBER, ';
q:=q||' PK_LOTGN_FISH_CATNO as FISH_CATALOG_NUMBER, ';
q:=q||' PHYL_CLASS as CLASS, ';
q:=q||' PHYL_ORDER as "ORDER", ';
q:=q||' PHYL_FAMILY as FAMILY, ';
q:=q||' PHYL_GENUS as GENUS, ';
q:=q||' PHYL_SPECIES as SPECIES, ';
q:=q||' PHYL_AUTH_DISPLAY as SPECIES_AUTHOR, ';
q:=q||' PHYL_COM_NAME_ENGLISH as COMMON_ENGLISH_NAME, ';
q:=q||' PHYL_COM_NAME_SPANISH as COMMON_SPANISH_NAME, ';
q:=q||' FLDGN_VESSEL as COLLECTION_VESSEL, ';
q:=q||' FLDGN_CRUISE as COLLECTION_CRUISE, ';
q:=q||' FLDGN_STATION as COLLECTION_STATION, ';
q:=q||' FLDGN_SAMPLENO as COLLECTION_SAMPLENO, ';
q:=q||' HAB_HABITAT as HABITAT, ';
q:=q||' FLDGN_GEAR_CATAGORY as GEAR_TYPE, ';
q:=q||' FLDGN_BOTM_TYPE_PRIMARY as Primary_BOTTOM_TYPE, ';
q:=q||' FLDGN_OCEAN as OCEAN, ';
q:=q||' FLDGN_GULF_SEA as GULF_SEA, ';
q:=q||' FLDGN_RIVER_LAKE as FRESH_WATER_BODIES, ';
q:=q||' FLDGN_BAY_STRAIT as BAY_STRAIT_HARBOR, ';
q:=q||' FLDGN_ISLAND_GROUP as ISLAND_GROUP, ';
q:=q||' FLDGN_STATE_PROV as STATE_PROVINCE, ';
q:=q||' FLDGN_COUNTY_PARISH as COUNTY_PARISH, ';
q:=q||' FLDGN_CITY as CITY, ';
q:=q||' FLDGN_REEF as REEF, ';
q:=q||' FLDGN_IFLDNO as IFLDNO, ';
q:=q||' FLDGN_VFLDNO as VFLDNO, ';
q:=q||' FLDGEO_LAT_DN_DEGREES as STARTING_LATITUDE_DEGREES, ';
q:=q||' FLDGEO_LAT_DN_MM_MMM as STARTING_LATITUDE_MM_MMM, ';
q:=q||' FLDGEO_LAT_DN_DDDDDD as STARTING_LATITUDE_DDDDDD, ';
q:=q||' FLDGEO_LAT_DN_HEAD_MM as STARTING_LATITUDE_HEAD_MM, ';
q:=q||' FLDGEO_LAT_UP_DEGREES as ENDING_LATITUDE_DEGREES, ';
q:=q||' FLDGEO_LAT_UP_MM_MMM as ENDING_LATITUDE_MM_MMM, ';
q:=q||' FLDGEO_LAT_UP_DDDDDD as ENDING_LATITUDE_DDDDDD, ';
q:=q||' FLDGEO_LAT_UP_HEAD_MM as ENDING_LATITUDE_HEAD_MM, ';
q:=q||' FLDGEO_LON_DN_DEGREES as STARTING_LONGITUDE_DEGREES, ';
q:=q||' FLDGEO_LON_DN_MM_MMM as STARTING_LONGITUDE_MM_MMM, ';
q:=q||' FLDGEO_LON_DN_DDDDDD as STARTING_LONGITUDE_DDDDDD, ';
q:=q||' FLDGEO_LON_DN_HEAD_MM as STARTING_LONGITUDE_HEAD_MM, ';
q:=q||' FLDGEO_LON_UP_DEGREES as ENDING_LONGITUDE_DEGREES, ';
q:=q||' FLDGEO_LON_UP_MM_MMM as ENDING_LONGITUDE_MM_MMM, ';
q:=q||' FLDGEO_LON_UP_DDDDDD as ENDING_LONGITUDE_DDDDDD, ';
q:=q||' FLDGEO_LON_UP_HEAD_MM as ENDING_LONGITUDE_HEAD_MM, ';
q:=q||' FLDGN_START_YEAR as START_YEAR, ';
q:=q||' FLDGN_START_MONTH as START_MONTH, ';
q:=q||' FLDGN_START_DAY as START_DAY, ';
q:=q||' FLDGN_END_YEAR as END_YEAR, ';
q:=q||' FLDGN_END_MONTH as END_MONTH, ';
q:=q||' FLDGN_END_DAY as END_DAY, ';
q:=q||' FLDGN_MINBDM as MINIMUM_BOTTOM_DEPTH, ';
q:=q||' FLDGN_MAXBDM as MAXIMUM_BOTTOM_DEPTH, ';
q:=q||' FLDGN_MFLD_NEW as MFLD_NEW ';
q:=q||' from fish ';
q:=q||' where FK_FISH_LOT_ACC_NUM = FK_FISH_LOT_ACC_NUM ';
if :P21_PHYL_CLASS != '-- ALL --' then
q:=q||' and PHYL_CLASS = :P21_PHYL_CLASS ';
end if;
if :P21_PHYL_FAMILY != '-- ALL --' then
q:=q||' and PHYL_FAMILY = :P21_PHYL_FAMILY ';
end if;
return q;
end;Try:
if :P21_PHYL_CLASS != '-'||'-'||' ALL '||'-'||'-' then
q:=q||' and PHYL_CLASS = :P21_PHYL_CLASS ';
end if;
if :P21_PHYL_FAMILY != '-'||'-'||' ALL '||'-'||'-' then
q:=q||' and PHYL_FAMILY = :P21_PHYL_FAMILY ';
end if;Felipe -
Please help with dbms_fga?
hi all,
audit event handler doesn't work. please help
test: SQL>show user
USER is "HR"
test: SQL>--on user hr
drop table aud_emp
creattest: SQL> 2 e table aud_emp (aud_time date)
create or replace procedure p_aud_emp as
begin
insert into aud_emp values (sysdate);
commit;
--do other thing later;
end;
Table dropped.
test: SQL> 2
Table created.
test: SQL> 2 3 4 5 6 7
Procedure created.
test: SQL>
test: SQL>show user
USER is "SYS"
test: SQL>--on user sys
begin
dbms_fga.drop_politest: SQL> 2 cy (
object_schema => 'hr',
object_name => 'employees',
policy_name => 'audit_emps_salary');
end;
/ 3 4 5 6 7
PL/SQL procedure successfully completed.
test: SQL>begin
dbms_fga.add_policy (
object_sche 2 3 ma => 'hr',
object_name => 'employees',
policy_name => 'audit_emps_salary',
audit_condition=> 'department_id=10',
audit_column => 'SALARY',
handler_schema => 'hr',
handler_module => 'p_aud_emp',
enable => TRUE,
statement_types=> 'select' );
end;
/ 4 5 6 7 8 9 10 11 12 13
PL/SQL procedure successfully completed.
test: SQL>
test: SQL>-- on user hr
select first_name,salary
test: SQL> 2 from employees
where department_id=10; 3
FIRST_NAME SALARY
Jennifer 4400
--it should call hr.p_aud_emp,but it didn't.
test: SQL>
test: SQL>select * from aud_emp;
no rows selected --it should insert one row here
test: SQL>
-- on user sys
col object_schema forma a10
col object_name form a15
col policy_name form a20
col sql_text form a40
set lines 120
select OBJECT_SCHEMA, OBJECT_NAME, POLICY_NAME,SQL_TEXT
from DBA_FGA_AUDIT_TRAIL
OBJECT_SCH OBJECT_NAME POLICY_NAME SQL_TEXT
HR EMPLOYEES AUDIT_EMPS_SALARY select * from employees
HR EMPLOYEES AUDIT_EMPS_SALARY select *
FROM employees
WHERE
department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
OBJECT_SCH OBJECT_NAME POLICY_NAME SQL_TEXT
from employees
where department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
OBJECT_SCH OBJECT_NAME POLICY_NAME SQL_TEXT
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id = 10
OBJECT_SCH OBJECT_NAME POLICY_NAME SQL_TEXT
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id=10
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id=10
OBJECT_SCH OBJECT_NAME POLICY_NAME SQL_TEXT
HR EMPLOYEES AUDIT_EMPS_SALARY select first_name,salary
from employees
where department_id=10
13 rows selected.Any ideas will be greatly appreciated.
Help to find out what issues in it please. -
Please help me to tune this PL/SQL...
Hi everyone,
I have a SQL query which runs ok when i run it individually but the same query if
i use it in a procedure.The procedure is hanging up.Could someone please help to tune this
SQL query and please check my procedure why is it hanging up.
SQL Query
=========
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
Taking around 6 minute to run and it returns """"268267"""" records
Explain Plan for the above SQL:
===============================
"PLAN_TABLE_OUTPUT"
"Plan hash value: 379550299"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 1 | HASH UNIQUE | | 1 | 16 | | 54461 (2)| 00:10:54 |"
"|* 2 | COUNT STOPKEY | | | | | | |"
"|* 3 | TABLE ACCESS FULL | MEMBER_SPAN | 12891 | 201K| | 54459 (2)| 00:10:54 |"
"| 4 | HASH UNIQUE | | 1 | 16 | 2424K| 54736 (2)| 00:10:57 |"
"|* 5 | COUNT STOPKEY | | | | | | |"
"|* 6 | TABLE ACCESS FULL | MEMBER_SPAN | 51541 | 805K| | 54459 (2)| 00:10:54 |"
"| 7 | HASH UNIQUE | | 1 | 50 | | 64 (4)| 00:00:01 |"
"|* 8 | COUNT STOPKEY | | | | | | |"
"|* 9 | TABLE ACCESS FULL | AV_MEM_EMAIL | 1 | 50 | | 63 (2)| 00:00:01 |"
"|* 10 | TABLE ACCESS FULL | DIVISION | 1 | 14 | | 3 (0)| 00:00:01 |"
"|* 11 | HASH JOIN | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 12 | VIEW | | 581 | 12782 | | 8184 (4)| 00:01:39 |"
"| 13 | HASH UNIQUE | | 581 | 26145 | | 8184 (4)| 00:01:39 |"
"| 14 | TABLE ACCESS BY INDEX ROWID| CONTRACT | 1 | 14 | | 2 (0)| 00:00:01 |"
"| 15 | NESTED LOOPS | | 581 | 26145 | | 8183 (4)| 00:01:39 |"
"|* 16 | TABLE ACCESS FULL | CONTRACT_SPAN | 581 | 18011 | | 7019 (5)| 00:01:25 |"
"|* 17 | INDEX RANGE SCAN | CONTRACT_IX1 | 1 | | | 1 (0)| 00:00:01 |"
"|* 18 | HASH JOIN | | 449K| 104M| 39M| 83466 (2)| 00:16:42 |"
"|* 19 | TABLE ACCESS FULL | MEMBER_SPAN | 449K| 34M| | 54964 (3)| 00:11:00 |"
"| 20 | TABLE ACCESS FULL | MEMBER | 1436K| 221M| | 14664 (2)| 00:02:56 |"
"Predicate Information (identified by operation id):"
" 2 - filter(ROWNUM=1)"
" 3 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SP')"
" 5 - filter(ROWNUM=1)"
" 6 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SE')"
" 8 - filter(ROWNUM=1)"
" 9 - filter("AV_MEM_EMAIL"."MEMBER_NBR"=:B1)"
" 10 - filter(TRIM("DIV"."DIVISION_NBR")=TRIM(:B1))"
" 11 - access(TRIM("MB_ACTIVE"."CONTRACT_NBR")=TRIM("ACTIVE_CONTRACTS"."CONTRACT_NBR"))"
" 16 - filter("CONTRACT_SPAN"."YMDEFF"<=20090707 AND TRIM("CONTRACT_SPAN"."VOID") IS NULL AND "
" "CONTRACT_SPAN"."YMDEND">=20090707)"
" 17 - access("CONTRACT"."CONTRACT_NBR"="CONTRACT_SPAN"."CONTRACT_NBR")"
" 18 - access("MB_ACTIVE"."MEMBER_NBR"="MS_ACTIVE"."MEMBER_NBR")"
" 19 - filter(TRIM("MS_ACTIVE"."VOID") IS NULL AND "MS_ACTIVE"."YMDEFF"<=20090707 AND "
" "MS_ACTIVE"."YMDEND">=20090707)"
SAME SQL IN A PROCEDURE..IT IS HANGING UP
========================================
create or replace PROCEDURE TEST_CURRENT_PCP_SPAN is
EXTRACTED_STRING VARCHAR2(32767);
FILEHANDLER UTL_FILE.FILE_TYPE;
test_str varchar2(100);
pcp_eff_date number(10);
file_name varchar2(50);
CURSOR MEMBERS
IS
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
TYPE MEM IS TABLE OF MEMBERS%ROWTYPE INDEX BY PLS_INTEGER;
TABLE_MEM MEM;
MEMBER_ADDR MGONZALEZ.CPKG_UTIL.ADDR;
BEGIN
test_str := '''A10000213'''||','||'''A10000213''';
insert into test_number_char(str) values ('start time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
file_name := 'member_load'||to_char(sysdate,'YYYYMMDDHH24MI')||'.txt';
FILEHANDLER := UTL_FILE.FOPEN('AVMED_UTL_FILE',file_name, 'W',10000);
insert into test_number_char(str) values ('start time of opening members cursor(before open members command) '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
OPEN MEMBERS;
LOOP
FETCH MEMBERS
BULK COLLECT INTO TABLE_MEM LIMIT 1000 ;
EXIT WHEN TABLE_MEM.COUNT = 0;
insert into test_number_char(str) values ('start time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
FOR i IN 1 .. TABLE_MEM.COUNT
LOOP
EXTRACTED_STRING := TRIM(TABLE_MEM(i).MEMBER_NBR)||'| '||
TRIM(TABLE_MEM(i).NAME_LAST)||'| '||
TRIM(TABLE_MEM(i).NAME_FIRST)||'| '||
TRIM(TABLE_MEM(i).NAME_MIDDLE)||'| '||
TRIM(TABLE_MEM(i).ssn)||'| '||
TABLE_MEM(i).subsciber_nbr||'| '||
TRIM(TABLE_MEM(i).class_x)||'| '||
TRIM(TABLE_MEM(i).DOB)||'| '||
TRIM(TABLE_MEM(i).SEX)||'| ' ;
EXTRACTED_STRING :=
EXTRACTED_STRING ||
TRIM(TABLE_MEM(i).aff_nbr)||'| '||
pcp_eff_date||'| '||
TABLE_MEM(i).actual_ymd_enddt||'| '||
TRIM(TABLE_MEM(i).division_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TABLE_MEM(i).network_id||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).name_suffix)||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).spouse_member_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).email_id)||'| '||
TABLE_MEM(i).Insurance_company_code||'| '||
TABLE_MEM(i).group_nbr||'| '||
TABLE_MEM(i).language_x||'| '||
TABLE_MEM(i).region||'| '||
TABLE_MEM(i).corp_nbr||'| '||
TABLE_MEM(i).non_erisa_status||'| '||
TABLE_MEM(i).cob_flag||'| '||
TABLE_MEM(i).pre_x_flag||'| '||
TABLE_MEM(i).vip_flag
EXTRACTED_STRING := rtrim(EXTRACTED_STRING,' ');
UTL_FILE.PUT_LINE(FILEHANDLER,EXTRACTED_STRING,TRUE);
EXTRACTED_STRING := NULL;
pcp_eff_date := NULL;
END LOOP;
insert into test_number_char(str) values ('end time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
END LOOP;
close members;
insert into test_number_char(str) values ('end time of opening members cursor '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
commit;
UTL_FILE.FCLOSE(FILEHANDLER);
insert into test_number_char(str) values ('End time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line( 'ERROR getting members '
|| SQLCODE
|| ' '
|| SQLERRM);
END ;
In my Test table which i am inserting to check the times...
I am geting on these 2 records after that it hangs up...
start time of MEMBER_LOAD_CURRENT_PCP_SPAN 07/08/2009 11:41:21
start time of opening members cursor(before open members command) 07/08/2009 11:41:21I have to call some other functions for each member to get additional details thats the reason i am going for Procedure.Instead it is just a simple SQL
Thanks in advanceIt is taking lot of timeYou could perhaps split it up in smaller, isolated parts.
Running certain steps separate.
..is it possible to find out the issues without running the proc?Other than have other people on OTN give their ideas/share experiences?
Not that I'm aware of.
There are lots of statistical views, you might be able to deduct from their data, but I personally prefer running the procedure and just trace it. But I'm always willing to learn new approaches, btw.
Still, you have 2 things to look at, at least:
- avoid loops in loops if possible
- check your predicates, if you apply a function, you lose the index, unless you create a function based index.
edit
One more thing (how could I overlook that):
You commit your instrumentation code ( insert into test_number_char(str) ) IN the loop.
Please remove commit in your loops...
Commit only once, at the end of your transaction.
Never commit in a loop.
(Preferrably the client commits)
And remove every commit in your loop...
Edited by: hoek on Jul 8, 2009 8:03 PM -
My First while loop inside PL/SQL block not working , please help
Hi ,
I am new to PL/sql and struck at PL SQL blocks , please help to solve this .
declare
v_A number constant :=10 ;
j number constant := 3 ;
BEGIN
WHILE j < v_A
LOOP
DBMS_OUTPUT.PUT_LINE('Hai');
END LOOP;
END;
please help as how to resolve this .
Thanks in advance .btw it's a useful habit to use indentation to highlight the block structure. Also it's worth deciding what your convention will be for keywords (I use uppercase, lowercase is also fine as far as I'm concerned but I've set up my editor to uppercase them) and variables, database object names etc (I use lowercase), e.g:
DECLARE
v_a CONSTANT PLS_INTEGER := 10;
j CONSTANT PLS_INTEGER := 3;
i PLS_INTEGER := j;
BEGIN
WHILE i <= v_a LOOP
DBMS_OUTPUT.PUT_LINE(i);
i := i +1;
END LOOP;
END;or perhapsdeclare
v_a constant pls_integer := 10;
j constant pls_integer := 3;
i pls_integer := j;
begin
while i <= v_a loop
dbms_output.put_line(i);
i := i +1;
end loop;
end;When I see "declare" and "BEGIN" in the same block of code I worry about the standard of code I'm going to see... -
I want to submit a concurrent program from pl/sql. Please help me.
Dear all,
I want to submit a concurrent program from pl/sql. But I failed. Please help me.
Detail:
I create a concurrent program in 'Cash Management, Vision Operations (USA)' responsibility. <strong>And it be submitted success in EBS</strong>.
Then
I create a test script in pl/sql. And use 'FND_GLOBAL.APPS_INITIALIZE' to initialize ebs, then use 'FND_REQUEST.SUBMIT_REQUEST' to submit
the consurrent program, But the procedure aways return <strong>0</strong>.
I cannot found the reason. Please help me.Thanks.
<em>Attached informations may describe the problem:
1.The concurrenct submitted success in EBS.</em>
request_id = 4750655 (Sorry, I dont know how to add pictures.)
<em>2.The initialize informations which from SQL</em>.
SELECT FCR.REQUESTED_BY USER_ID
,FCR.RESPONSIBILITY_ID
,FCR.RESPONSIBILITY_APPLICATION_ID
,FA.APPLICATION_SHORT_NAME
,FCP.CONCURRENT_PROGRAM_NAME
FROM FND_CONCURRENT_REQUESTS FCR
,FND_APPLICATION FA
,FND_CONCURRENT_PROGRAMS FCP
WHERE FCR.PROGRAM_APPLICATION_ID = FA.APPLICATION_ID
AND FCR.CONCURRENT_PROGRAM_ID = FCP.CONCURRENT_PROGRAM_ID
AND FCR.REQUEST_ID = 4750655;
Result: user_id = 1318;
responsibility_id = 50579;
application_id = 260;
application_short_name = 'CE';
program_short_name = 'CALLK009';
<em>3.The test script code.</em>
<p>
-- Created on 2008/10/22 by ERIC
declare
-- Local variables here
Wv_conc_req_id VARCHAR2(10) DEFAULT NULL;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(
1318
,50579
,260
Wv_conc_req_id := FND_REQUEST.SUBMIT_REQUEST(
'CE'
,'CALLK009'
,NULL
,SYSDATE
,FALSE
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
DBMS_OUTPUT.PUT_LINE(Wv_conc_req_id);
COMMIT;
end;
<em>4.The concurrent program code.</em>
create or replace package body CALLTEST is
PROCEDURE T1(PvO_errbuf OUT VARCHAR2
,PvO_retcode OUT VARCHAR2)
IS
BEGIN
FND_FILE.PUT_LINE(fnd_file.log, 'TEST');
END;
end CALLTEST;
</p>Can you check from which schema you are executing FND_REQUEST? You can try as follows;
Connect to your required schema, create a synonym on apps.fnd_request, connect from apps and finally execute grant all on apps.fnd_request to all.
You can check for relevance from Doc ID: Note:147495.1
Please do keep in the mind the soultion above should be applied to a test/dev EBS instance first.
I hope this would be of help.
Saad -
Please help with an sql to show more than one records into single row for each student
From the following data I would like to create an sql to get the information as the following layout
studentid, firstTerm, EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
Example
1 First, 30,40,20,Sec,30,40,20, simillarly next row for next row for another sudent. Please help to generate the sql for the same.
Please help it would be very appreciate.
With Thanks
Pol
polachancreate table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
insert into yourdata values
(1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
(2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
(3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
(1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
(2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
(3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
Select studentid
,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
,max(case when term='First' and section='Math' Then Mark End) as MathMark1
,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
From yourdata
Group by studentid
drop table yourdata -
Java and MS SQL Server 2000 problem, please help
please help me. I am using java and MS SQL Server 2000, and I'm trying to access and verify the login. I'm getting the following error message: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
Can any please help in this regard.
String userNumber = (String)userNumField.getValue();
char[] userPasswordArray = userPasswordField.getPassword();
String userPassword = new String(userPasswordArray);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:Dikolobe_Data");
java.sql.PreparedStatement statement = connection.prepareStatement(
"SELECT USER_NUMBER, USER_PASSWORD, USER_CLASS, USER_STATUS " +
"FROM SYS_USER " +
"WHERE (USER_NUMBER = ? AND USER_PASSWORD = ?);");
statement.setString(1, userNumber);
statement.setString(2, userPassword);
java.sql.ResultSet result = statement.executeQuery();
if(result.next()) {
String userStatus = result.getString(4);
if(userStatus.equals("logged on")) {
String loginErrorMessage = "User with number: " + userNumber + " is already logged on.";
javax.swing.JOptionPane loginErrorPane = getNarrowOptionPane(72);
loginErrorPane.setMessage(loginErrorMessage);
loginErrorPane.setMessageType(javax.swing.JOptionPane.ERROR_MESSAGE);
javax.swing.JDialog loginErrorDialog = loginErrorPane.createDialog(null, "Login Error");
loginErrorDialog.setVisible(true);
else {
String userClassification = result.getString(3);
if(userClassification.equals("Administrator")) {
AdminHomePage newAdminHomePage = new AdminHomePage();
newAdminHomePage.setVisible(true);
else if(userClassification.equals("Educator")) {
EduHomePage newEduHomePage = new EduHomePage();
newEduHomePage.setVisible(true);
statement = connection.prepareStatement(
"UPDATE SYS_USER SET USER_STATUS = ? " +
"WHERE USER_NUMBER = ?");
statement.setString(1, "logged on");
statement.setString(2, userNumber);
statement.executeUpdate();
dispose();
}Doesn't the following link give you enough information?
http://www.google.com/search?q=invalid+descriptor+index
Anyway .. This error means that the given ResultSet column index which you're trying to retrieve the value from is out of the range.
Maybe you are looking for
-
How do I use my mid 2010 iMac as display with mid 2011 macbook pro?
I have a mid 2010 iMac and I want to use it as a display for my mid 2011 macbook pro. The iMac has a mini display port and the macbook has a thunderbolt port. Does anyone know if this is possible and what I need to make it possible? Cheers! -Sean
-
Macbook aluminum 2008 convert to 2009?
I have a Macbook 2008 aluminum , and was wondering if i buy the casings for the early 2009 models can somehow convert it into one? Such as Would i be able to use the same battery as the one in 2009? and could i install an sd card reader in it? also a
-
I Cloud for PC, Ipad and Iphone.
I have multiple email addresses on sites that I host. I'd like to know if I can run all of the addresses through ICloud along with my calendar so that my devices (PC, IPad and IPhone) all sync and so that I can add calendar items and invite others t
-
Create Shopping Cart to ref Price Conditions in SRM5 ECS
Hi there I have a question about pricing conditions for ( my systems are MDM2.0, SRM5.0 , ECC 6, Extended classic ) Price conditions has a limitation for ECS..meaning? Does this mean we cannot use pricing conditions on the shopping cart level for
-
Where to download the GettingStarted application from?
Hello All, I am very new to Endeca and so this question might be very trivial, but I was following the Oracle Endeca Information Discovery 3.0 Screencast Series - YouTube and trying to create the bikestore application as given over there. But the ins