Problem to get count from resultset with select count(1) like query
Hi,
The snippet of code is like this ...!
preparedStatement = connection.prepareStatement("select count(1) as count from acf_users where acf_user_name like ? and acf_user_password like ?");
preparedStatement.setString(1,stringUsername);
preparedStatement.setString(2,stringPassword);
resultSet = preparedStatement.executeQuery() ;
System.out.println("The ResultSet Count checkUser() : "+resultSet.getString("count"));
preparedStatement.close();
But there is a SQLException like :
java.sql.SQLException: ResultSet.next was not called
I want to extract and check the count in the program..
Does anyone has the solution, comments on this.
Thanks in Advance,
-Sachin
Thanks a lot to have a look on it :
I got the solution on it as :
preparedStatement = connection.prepareStatement("select count(*) as total from acf_users where acf_user_name like ? and acf_user_password like ?");
preparedStatement.setString(1,stringUsername);
preparedStatement.setString(2,stringPassword);
resultSet = preparedStatement.executeQuery() ;
resultSet.next();
System.out.println("The ResultSet checkUser() : "+resultSet.getInt("total"));
The important line is :
resultSet.next()
Thanks once again,
Sachin !
Similar Messages
-
Load from Infoprovider with selection package error
Hello,
Requirement: Data transfer from one application to another application in BPC
Version: BPC 7.5 NW SP08
Source application: MGMT
Target Application: LEGAL
Transformation File: Yes
Conversation File: Yes for Location Dimension
Source records: 103 (The data is for only one Location)
When I run Load from Infoprovider with selection Package (/CPMB/LOAD_INFOPROV_UI package) i am able to load 99 records loading and 4 records are getting error.
Error Message: 121 ,41513000,,N,AVER,Y,2011,,1030,1030,,,0.0000000
Line 121 :Dimension:LOCATION member: convert failed in line 121; rejected
Analysis: Location conversion is already in place and other 99 records are able to success on the same conversion rule. I have checked transformation, Conversion files. When I validate the transformation file with data then also i am seeing same error.
Note: I am using same package to load data from BW Cube to MGMT application that time i am able to load without error, When I load the same data from MGMT to LEGAL then this error is coming.
I appreciate any clue on this error.
Thanks,
Sri
Edited by: sribpc on Oct 10, 2011 8:02 PMWe are able to solve the problem,
In the Account Dimension for one of the property we maintained some value with comma in it. That created a bad data and system throwing error.
After changing Account dimension attribute then the package is working fine.
Thanks for the support. -
How can I fill a table of objects from cursor with select * bulk collect???
Hi All, I have a TYPE as OBJECT
create or replace type dept2_o as object (
deptno NUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(13));
I can fill a table of objects from cursor with out select * bulk collect...., row by row
declare
TYPE dept2_t IS TABLE of dept2_o;
dept_o_tab dept2_t:=dept2_t();
i integer;
begin
i:=0;
dept_o_tab.extend(20);
for rec in (select * from dept) loop
i:=i+1;
dept_o_tab(i):=dept2_o(
deptno => rec.deptno,
dname => rec.dname,
loc =>rec.loc
end loop;
for k IN 1..i loop
dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
end loop;
end;
RESULT
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
But I can't fill a table of objects from cursor with select * bulk collect construction ...
declare
TYPE dept2_t IS TABLE of dept2_o;
dept_o_tab dept2_t:=dept2_t();
begin
dept_o_tab.extend(20);
select * bulk collect into dept_o_tab from dept;
end;
RESULT
ORA-06550: line 6, column 39;
PL/SQL: ORA-00947: not enough values ....
How can I fill a table of objects from cursor with select * bulk collect???create or replace type dept_ot as object (
deptno NUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(13));
create table dept
(deptno number
,dname varchar2(14)
,loc varchar2(13)
insert into dept values (10, 'x', 'xx');
insert into dept values (20, 'y', 'yy');
insert into dept values (30, 'z', 'zz');
select dept_ot (deptno, dname, loc)
from dept
create type dept_nt is table of dept_ot
declare
l_depts dept_nt;
begin
select dept_ot (deptno, dname, loc)
bulk collect
into l_depts
from dept
for i in l_depts.first .. l_depts.last
loop
dbms_output.put_line (l_depts(i).deptno);
dbms_output.put_line (l_depts(i).dname);
dbms_output.put_line (l_depts(i).loc);
end loop;
end;
/ -
How did my stored files get converted from 'open with Adobe READER' to 'open with Adobe ACROBAT'? How can I get them re-set to open with 'Adobe Reader'?
Please reply to my e-mail: [email protected]It sounds as if you downloaded Adobe Acrobat Pro. If you did, uninstall it. Then repair Adobe Reader.
The free Acrobat account has no connection to any of this. -
Not able to get mail from windows live account.
Firefox can find plugins in several locations, but Firefox 21 changed the location of the "shared" plugin folder so older installers like the Microsoft Windows Media Plugin no longer drop the DLL file in the correct location.
There apparently are two ways to address this:
(1) Change a Firefox preference so that Firefox checks the old location. Here's how:
(i) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
(ii) In the filter box, type or paste '''plugins''' and pause while the list is filtered
(iii) Double-click '''plugins.load_appdir_plugins''' to switch its value from false to true.
This will take effect after you restart Firefox.
(2) Copy the plugins folder to the new location. Here's how on Win 7 64-bit:
Open a Windows Explorer window to:
C:\Program Files (x86)\Mozilla Firefox
Right-click and copy the '''Plugins''' folder
Double-click the '''browser''' folder to open it
Right-click and paste
Right-click the new copy of '''Plugins''' and rename it to '''plugins'''
After restarting Firefox, the plugins in that folder should now be available.
''Edit: I suggest just doing #1.'' -
Problem with different resultset with same data and same query in Oracle 8.1.7 and 9i
Hello,
I have been using this query in oracle 8.1.7
SELECT
ID,
AREA_NO
FROM MANAGER_AREA MGR
WHERE COMPANY_ID = :id AND
(:value < (SELECT COUNT(ROWID)
FROM MANAGER_WORK MW
WHERE MW.AREA_ID = MGR.ID AND
(MW.END_WORK IS NULL OR MW.END_WORK >= SYSDATE)))
order by AREA_NO;
In the above query I want to see rows from MANAGER_AREA table depending upon date criteria in the table MANAGER_WORK and also upon the parameter :value i.e if I pass a value as 0 I get to see records for which their is atleast 1 record in MANAGER_WORK with the date criteria and if I pass -1 then I get all the records because minimum value that count(*) would give is 0. The resultset was as expected in 8.1.7.
A couple of days back I installed PERSONAL 9i to test for testing the basic functionality of our program with the same data. This query fails and irrespective whether I pass -1 or 0 it returns me same dataset which I would have got in case if I pass 0.
I do not know whether this is a bug that has got introduced in 9i. Can anybody help me with this problem. It would be difficult for me to change the parameter send to this query as the Query is called from many different places.
Thanks in advance
Amol.I cannot use a Group by and a having statement over here. The problem with 'Group by' and 'having' clause is If I have to make a join between the two tables. When I use join then I get only rows that are linked to each other in the table.
If I use outer join to solve that problem then I have to take in consideration the other date condition. My previous query use to virtually discard the corelated query result by using -1 as the value. This will not happen in the join query.
Amol. -
A problem to get the value of a selected cell
Hi all,
I am trying to get the value of a cell in JTable. The problem that I have is ListSelectionListener only listens if the selection changes(valueChanged method).
It means that if I select apple then rum, only rowSelectionModel is triggered, which means I do not get the index of the column from selectionModel of ColumnModel.
apple orange plum
rum sky blue
This is a piece of code from JTable tutorial that I modified by adding
selRow and selCol variables to keep track of the location so that I can get the value of the selected cell.
Thank you.
if (ALLOW_ROW_SELECTION) { // true by default
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
System.out.println("No rows are selected.");
} else {
int selectedRow = lsm.getMinSelectionIndex();
selRow = selectedRow;
System.out.println("Row " + selectedRow + " is now selected.");
else {
table.setRowSelectionAllowed(false);
if (ALLOW_COLUMN_SELECTION) { // false by default
if (ALLOW_ROW_SELECTION) {
table.setCellSelectionEnabled(true);
table.setColumnSelectionAllowed(true);
ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
colSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
System.out.println("No columns are selected.");
} else {
int selectedCol = lsm.getMinSelectionIndex();
selCol = selectedCol;
System.out.println("Column " + selCol + " is now selected.");
System.out.println("Row " + selRow + " is now selected.");
javax.swing.table.TableModel model = table.getModel();
// I get the value here
System.out.println("Value: "+model.getValueAt(selRow,selCol));
}maybe you can try with :
table.getSelectedColumn()
table.getSelectedRow()
:) -
How to get values from resultset when using subquery???
Hi ,
I have a problem in executing sql query from java.
I am executing an sql query which return a intersection of values from 3 tables.
Here is the query I am using
select id from dps_user where id in (select b.id from dps_user b,laserlink c
where c.userid='univ.'||b.login and c.status in(1,3,8,9,10)
intersect
select b.id from dps_user b,laserlink c
where c.userid=b.login and c.status in(1,3,8,9,10)).
this query is working fine from sql .
when I am trying to excute the same query from java nothing is coming into resultset.
String ISP_AND_EMAIL="select id "+
" from dps_user where id in (select b.id from dps_user b,laserlink c "+
"where c.userid='"+"univ.'"+" ||b.login and c.status in(1,3,8,9,10)"+
" intersect "+
" select b.id from dps_user b,laserlink c"+
" where c.userid=b.login and c.status in(1,3,8,9,10))";
System.out.println(ISP_AND_EMAIL);
rs=stmt.executeQuery(ISP_AND_EMAIL);
How to use concatinate string (|| ) in java.
can anyone help to retrieve the values from this resultset...
Thanksconcatnation is done using + in java.
I am doubtful about the following line where there may be error
"where c.userid='"+"univ.'"+" ||b.login and c.status in(1,3,8,9,10)"+
I don't know if the univ. is a string or some variable.I need more clarification on this line,then i may help u.
thx -
Problem to get Connection from JBoss AS
PLEASE HELP ME....
I GOT ERROR WHILE I TRYED TO GET A CONNECTION FROM JBOSS APP. SERVER.
THE CODE IS
package com.beo.atlas.common;
public final class ServiceLocator {
private static final String JBOSS_INITIAL_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
private static final String JBOSS_PROVIDER_URL = "localhost:8080";
private static final String JBOSS_URL_PKG_PREFIXES = "org.jboss.naming:org.jnp.interfaces";
public static final String ATLAS_DATASOURCE = "java://myatlasdbpool";
private static java.util.Hashtable dataSourceCache = null;
private static ServiceLocator locator = null;
static {
System.out.println("Locator Initializing");
dataSourceCache = new java.util.Hashtable();
locator = new ServiceLocator();
private ServiceLocator() { }
public static ServiceLocator newInstance() {
System.out.println("Returning the Locator Object");
return locator;
public java.sql.Connection getDBConnection() throws java.sql.SQLException,javax.naming.NamingException {
System.out.println("Getting Data base Connection....");
if(dataSourceCache.containsKey(ATLAS_DATASOURCE)) {
System.out.println("Trying to get Connection from CACHE...");
System.out.println("Returning Connection Object from cache.");
return (java.sql.Connection)dataSourceCache.get(ATLAS_DATASOURCE);
System.out.println("FAILED to get Connection from CACHE");
System.out.println("Trying to create new Connection...");
java.util.Properties props = new java.util.Properties();
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,JBOSS_INITIAL_CONTEXT_FACTORY);
props.put(javax.naming.Context.PROVIDER_URL,JBOSS_PROVIDER_URL);
props.put(javax.naming.Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIXES );
javax.naming.InitialContext context = new javax.naming.InitialContext(props);
Object o = context.lookup(ATLAS_DATASOURCE);
System.out.println("Object Created...");
javax.sql.DataSource dataSource = null;
try {
dataSource = (javax.sql.DataSource)javax.rmi.PortableRemoteObject.narrow(o,javax.sql.DataSource.class);
}catch(Exception e) {
java.sql.Connection con = dataSource.getConnection();
dataSourceCache.put(ATLAS_DATASOURCE,con);
System.out.println("Returning new Connection Object.");
return con;
ERROR
Locator Initializing
Returning the Locator Object
Getting Data base Connection....
FAILED to get Connection from CACHE
Trying to create new Connection...
Object Created...
java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown S
ource)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.beo.atlas.common.ServiceLocator.getDBConnection(ServiceLocator.ja
va:56)
at AtlasClient.printData(AtlasClient.java:16)
at AtlasClient.main(AtlasClient.java:8)
Caused by: java.lang.ClassCastException: org.jnp.interfaces.NamingContext
... 5 moreI've got the same problem. Working with JBoss 4.0.3 and Tomcat 5.5. The lookup goes fine and returns an object of type remote home, however when I perform the narrow() I get ClassCastException. I'm sure the client and the server have got the same file version as I built from the same source.
[error]
Caused by: java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
[error] -
Getting Long time to execute select count(*) statement.
Hi all,
My table have 40 columns and it doesn't have the primary key column. it contain more than 5M records. it's taking long time to execute simple sql statement.
Such as select (*) take 1min and 30 sec. If i use select count(index_colunm) then it finished with in 3s. i did the following workarounds.
Analyzed the table.
created required indexes.
yet getting the same performance issues. please help me to solve this issue
ThanksBlueDiamond wrote:
COUNT(*) counts the number of rows produced by the query, whereas COUNT(1) counts the number of 1 values.Would you care to show details that prove that?
In fact, if you use count(1) then the optimizer actually re-writes that internally as count(*).
Count(*) and Count(1) are have identical executions.
Re: Count(*)/Count(1)
http://asktom.oracle.com/pls/asktom/f?p=100:11:6346014113972638::::P11_QUESTION_ID:1156159920245 -
Want to get the list users with select access to v$ synonyms and v$ views
I've to write a sql (DB 11.1) to get the list of users who has select access to v$ synonym and v$ views. I've written the following sqls to do this but they both return the same result and I don't know how to verify it. It will be a great help if you could validate the sqls and let me know if something is wrong. Thanks for the help.
-- v$ views
select 'vview',
substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
from (select null p, view_name c
from dba_views
where view_name like ('V$%')
union all
select -- users/roles and roles granted
granted_role p,
grantee c
from dba_role_privs
where granted_role != 'DBA'
union all
select -- users/roles with select on DBA views
table_name p, grantee c
from dba_tab_privs
where privilege = 'SELECT'
and table_name like ('V$%'))
where (c = 'PUBLIC' OR c in (select username from dba_users))
AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
start with p is null connect by p = prior c
-- v$ synonyms
select 'vsynonyms',
substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
from (select null p, SYNONYM_NAME c
from ALL_SYNONYMS
where table_name like ('V$%')
union all
select -- users/roles and roles granted
granted_role p,
grantee c
from dba_role_privs
where granted_role != 'DBA'
union all
select -- users/roles with select on DBA views
table_name p, grantee c
from dba_tab_privs
where privilege = 'SELECT'
and table_name like ('V$%'))
where (c = 'PUBLIC' OR c in (select username from dba_users))
AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
start with p is null connect by p = prior cI've modified the sql to include GV$ and all select [any] privs.
select 'vview',
substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
from (select null p, view_name c
from dba_views
where view_name like ('V$%') OR view_name like ('GV$%')
union all
select -- users/roles and roles granted
granted_role p,
grantee c
from dba_role_privs
where granted_role != 'DBA'
union all
select -- users/roles with select on DBA views
table_name p, grantee c
from dba_tab_privs
where privilege like 'SELECT%'
and table_name like ('V$%') OR table_name like ('GV$%') )
where (c = 'PUBLIC' OR c in (select username from dba_users))
AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
start with p is null connect by p = prior c
union
select 'vsynonyms',
substr(SYS_CONNECT_BY_PATH(c, '->'),3,512) path, c
from (select null p, SYNONYM_NAME c
from ALL_SYNONYMS
where table_name like ('V$%') OR table_name like ('GV$%')
union all
select -- users/roles and roles granted
granted_role p,
grantee c
from dba_role_privs
where granted_role != 'DBA'
union all
select -- users/roles with select on DBA views
table_name p, grantee c
from dba_tab_privs
where privilege like 'SELECT%'
and table_name like ('V$%') OR table_name like ('GV$%') )
where (c = 'PUBLIC' OR c in (select username from dba_users))
AND c NOT IN('MDSYS','DMSYS','CTXSYS','WMSYS','ORDSYS','OLAPSYS','DBSNMP')
start with p is null connect by p = prior c -
Creating text file from SQL with adding counter in Filename.
Hi,
I have a requirement for creating the Tesxt files from Oracle DB which i can achieve by ODISQLUNLOAD.
But tricky part is that i want have a file name+ counter such that Counter should start with 1 for the first file of the day, then 2,... and reset to 1 for every new date.
e.g. file0001, file0002,file0003,file0004,.... file0100 and so on for one day.
But when i will create a file on next day it should be created as again file0001, file0002,file0003,file0004,.... file0100 and so on.
I may be able to achieve this using some variables but unable to think how could i achieve this.
Any help would be appreciated.
Thanks and Regards,
MaheshHi Mahesh,
If the files are loaded as one batch process, for instance, by executing a single package, you could perform a looping function and store the counter as a variable. It would be very similar to the blog post here: https://blogs.oracle.com/dataintegration/entry/using_variables_in_odi_creatin - but you would be using the #counter variable in your filename. Each day that the package is run, the counter starts at 1.
Hope this will fit your needs.
Enjoy!
Michael R. -
Is there an easier way to get tabular report results with select lists?
Ok, as a newbie, I have gotten this query to work in my report region but I figure if I am doing something this convoluted then I am not letting a wonderful feature of HTML DB do its job.
I have 3 select lists that I want to "AND" together to filter the result list. Two of the selected items to filter could have null values.
I want to have the entire results to appear when the list is reset (clear cache is working and sets each select list value to null). However, it appears to me, if one select list is used and the others are not, the other select lists by default have %null% (Null return value setting left blank) which isn't really null.
Well if that wasn't confusing so far. Here is the select:
select [my columns]
from my_table
where (instr(upper("COL1"),upper(
decode(:P1_FILTER_COL1,'%null%',"COL1",
null,"COL1",:P1_FILTER_COL1))) > 0 -- COL1 is mandatory
AND
(instr(upper("COL2"),upper(
decode(:P1_FILTER_COL2,'%null%',"COL2",
null,"COL2",:P1_FILTER_COL2))) > 0 OR "COL2" IS NULL)
AND
(instr(upper("COL3"),upper(
decode(:P1_FILTER_COL3,'%null%',"COL3",
null,"COL3",:P1_FILTER_COL3))) = 1 OR "COL3" IS NULL)
Do I have to use decode for the select values being reset, selected/not selected? Is there some way for the Null return value setting to really be null not %null%?
Thanks,
KellyRather than creating your report directly from a SQL statement use the "Sql Query (PL/SQL Function Body returning Sql Query)" option and re-write your code in PL/SQL. PL/SQL gives you greater control and allows you to test the "null" values and add where clauses to your SQL query based on whether or not a value was selected in the SELECT list.
For example, I have a report parameter screen that has a state drop down list that returns a value of -1 if no state is selected. I can, therefore, code:
IF :P6_STATE_CODE != -1 THEN
query := query + " WHERE state_code = ' ||
:P6_STATE_CODE ;
END IF ;
I have a more complete example if you would like to send me an email ([email protected])
Jeff -
WPF - Get files from directory with a shorter path
Hello,
I want to list the files in a combobox. My main question is how to get those files? I saw Directory.GetFiles(path), but I have to write the whole path (C:\Folder1\Folder2\Folder3\Folder4). How will this work on an other PC? Is somehow possible to write
the path beginning just form the app's folder? For example: the .exe is in "C:\Folder1\Folder2", and now the path what I have to write is just ":\Folder3\Folder4".
Thanks!I may be misunderstanding; please correct me if I am. It sounds like you want to get a list of the files in the same directory as the program that's executing.
//A few ways to get files from the same location as the code that is executing:
//Enumerate through each file
foreach(var fileInfo in new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory.EnumerateFiles())
//Get a collection of file information objects
System.IO.FileInfo[] fileInfos = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory.GetFiles();
//Get the name of the directory
string directoryName = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName;
WinSDK Support Team Blog: http://blogs.msdn.com/b/winsdk/ -
Case with select into and sub query
hi im trying to use case and select with sebqueries, but my beginer like understanding of syntax fails me. can someone point out what im doing wrong in the case select below. im using select into, as i ultimatly need to load a ref cursor for use with crystal reports.
thanks
james
ps if anyone is london based, and would like to spend a day or two teaching me how to be a bit better at PL/SQL (can aford to pay a little bit) please get in touch!!
SELECT
Case (select kind_code from event where
event.event_id = event.container_event_id)
when 1094006
then promo_name
end
into result
FROM promo, promo_plan , event_promotion
WHERE promo.promo_id = promo_plan.promo_id
AND promo_plan.promo_plan_id = event_promotion.promo_plan_id
AND event_promotion.detail_id = '33532282'
when blah then 'blah';Hello
AH i see what you are driveing at, yes i am just using case slect to determin which >routine to run, as the name is stored in a diferent location depending on the event kind >code. are are you saying i need multiple selects within the case statment? one for each >type of kind code?Well it depends really. If the select
select kind_code from event where
event.event_id = event.container_event_idIs going to return more than one row for any given run, you're going to need to take a bit of a different approach. Is it the case that this query will return more than one row which would mean that you want value X and value Y for each row?
Using the test data and everything from before:
SQL> CREATE OR REPLACE PROCEDURE p_GetStuff(ac_Result OUT sys_refcursor)
2 IS
3
4 BEGIN
5 /*
6 This uses a cartesian product i.e. repeat every row in
7 dt_test_data against every row in dt_test_event
8 */
9 OPEN Ac_Result FOR
10 SELECT
11 CASE dt_test_event.kind_code
12 WHEN 1 THEN
13 dt_test_data.object_name
14 WHEN 2 THEN
15 dt_test_data.object_type
16 END
17 FROM
18 dt_test_data,
19 dt_test_event;
20
21 END;
22 /
Procedure created.
SQL> var x refcursor
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
TABLE
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
TABLE
TABLE
TABLE
TABLE
INDEX
INDEX
INDEX
INDEX
INDEX
20 rows selected.Or an alternative to that would be, if you have a fixed number of event ids and they relate to a fixed number of attributes you could use something like:
CREATE OR REPLACE PROCEDURE p_GetStuff3(ac_Result OUT sys_refcursor)
IS
BEGIN
The SUBSTR
is just there to make sure the data fit on screen, my SQL*Plus
is a bit weird!
OPEN Ac_Result FOR
SELECT
SUBSTR(MAX(DECODE(dt_test_event.kind_code,1,dt_test_data.object_name,NULL)),1,30) attribute_1,
SUBSTR(MAX(DECODE(dt_test_event.kind_code,2,dt_test_data.object_type,NULL)),1,30) attribute_2
FROM
dt_test_data,
dt_test_event
GROUP BY
object_name;
END;
SQL> delete from dt_test_event where kind_code=2;
1 row deleted.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC TABLE
ABC4 TABLE
AD1 TABLE
AD2 TABLE
ADHOC_CONTACT_LOG TABLE
AK_CD_CLAIM_VALIDATION_SOURCE INDEX
AK_CD_CLAIM_VALIDATION_TYPE INDEX
AK_CLAIM_ACTION_ROWSOURCE INDEX
APPROVAL_LIST_MEM_IE INDEX
APPROVE_GRP_HIST_IE INDEX
10 rows selected.Message was edited by:
david_tyler
Oops, copy + pasted the wrong comments for the 2nd proc.
Maybe you are looking for
-
How to merge 2 timestamps into one??
Hi, Say I have two timestamps (oracle.jbo.domain.Timestamp) ts1 and ts2. what is the best way to create third timestamp object, ts, where ts would take: - date portion from ts1 - time portion from ts2 Any help is highly appreciated.
-
There is a specific website that does not download, but it is not the site since it can be viewed on my iphone and imac. Does somebody know what to do?
-
Problem between SSMS and Report ! Filter query not showing data or showing wrong data
Hi all, In short: I have a report with multiple values such as name of shop, postal code etc. The parameters have no default value and act as "like". If someone enters "krant" he'll get all the shop names that contain "krant" in their name etc. Same
-
Hi, What is the object link to t- code CG02 substance master. There is screen number 231 for Substance master not sure how it works. Thanks. Anirudh,
-
Error Starting Database after Installation and reboot
Hi all, After installing Oracle 10g on Redhat and restarting the system i am getting the following message where i try to start the database: "SP2-0642:SQL*PLUS internal error state 2165, context 4294967295:0:0 Unable to procced Database <database na