Formatting output from a select statement?
Hi: a trivial question.
When I run a select on four fields, it prints the first field in one line and the rest in the second line.
TYPE
PROTO CLASS_ID DSTPORT
BUILT_INBOUND_UDP
17 50007 53
Is there a any variable I can configure so that all four fields are printed in the same line?
TYPE PROTO CLASS_ID DSTPORT
BUILT_INBOUND_UDP 17 50007 53Thanks
Ray
SQL> SELECT a.owner from all_all_tables a WHERE rownum = 1;
OWNER
SYS
SQL> column owner format a15;
SQL> SELECT a.owner from all_all_tables a WHERE rownum = 1;
OWNER
SYS
SQL> column owner format a5;
SQL> SELECT a.owner from all_all_tables a WHERE rownum = 1;
OWNER
SYS
SQL>
Similar Messages
-
How to pass output from one selection-as input to another selectiion??
From a user prompt will iniate many user table selections. And the outputs of each table selection will be used as inputs for the next table selection
I reviewed variable Scope and inner and outer Declare—it would be a great help if some one could give me a example of the right approach??
see sample script :
Thank you so much for your help
---------------------------- Section_01_UserInput.sql -------------------------
-- THIS SECTION OF THE SCRIPT IS TO PROMPT THE USER FOR THE MODEL NAME AND THE ORGANIZATION CODE (e.I...M1,M2,M3...._)
-- THE ORGANIZATION WHERE MODEL WAS CREATED IS THE ONLY PLACE WHERE YOU WOULD FIND THE BILL_SEQUENCE_ID
-- THE COMMON ORGANIZATIONS DO NOT HAVE COMPONETS THEY JUST REFERENCE TO THE ORHANIZATION THAT MODEL WAS CREATED
SET VERIFY OFF
SET ECHO OFF
ACCEPT v_assemblyName CHAR DEFAULT myDefaultAssemblyName PROMPT 'Enter Assembly name:'
ACCEPT v_OrganizationCode CHAR DEFAULT myDefaultOrganizationCode PROMPT 'Enter the Org where the MODEL WAS CREATED :'
SELECT a.organization_code, a.organization_id, b.inventory_item_id, b.segment1, b.description
FROM mtl_parameters a, mtl_system_items_b b
WHERE a.organization_code = '&v_OrganizationCode'
AND
b.segment1 ='&v_assemblyName'
AND
b.organization_id = a.organization_id;
SET VERIFY ON
SET ECHO ON
----OUTPUT of the Section_01_UserInput.sql QUERY---
ORGANIZATION_CODE ORGANIZATION_ID INVENTORY_ITEM_ID SEGMENT1 DESCRIPTION
M1, 207, *[225957]* , CN927779, Sentinel Custom Desktop
----------------------------- Section_02_bom_structures_b.sql ------------------
-- List all option class Bill of Materials for a single ATO or PTO model
-- List of bill_sequence_id and all component_item_id's that belong to that
-- bill_sequence_id
SELECT a.assembly_item_id, a.bill_sequence_id, b.bom_item_type, b.component_item_id
FROM bom_structures_b a, bom_components_b b
WHERE a.assembly_item_id = *['225957']*
AND
b.bill_sequence_id = a.bill_sequence_id
AND
b.bom_item_type = '2'; -- OPTION Class's are identified by bom_item_type
----OUTPUT of the Section_02_bom_structures_b.sql QUERY---
ASSEMBLY_ITEM_ID ORGANIZATION_ID BILL_SEQUENCE_ID BOM_ITEM_TYPE BILL_SEQUENCE_ID COMPONENT_ITEM_ID
*[225957]* , 207 , *[90754]* 2 90754 *[297]*
*[225957]* , 207 , *[90754]* 2 90754 *[299]*
*[225957]* , 207 , *[90754]* 2 90754 *[301]*
----------------------------- Section_03A_bom_structures_b.sql-------------------
-- List all the components under the option class
-- When no components are found with bom_item_type ='4' which means that this assembly has no
-- components in the bom_components_b because the assembly is a child that is a option class.
-- We need to run this script with a bom_item_type ='2' and stored the component_item_id into MEMORY_assembly_id
-- and run script again by read from MEMORY_assembly_id and bom_item_type = '4';
SELECT a.assembly_item_id, a.organization_id, a.bill_sequence_id, b.bom_item_type, b.bill_sequence_id, b.component_item_id
FROM bom_structures_b a, bom_components_b b
WHERE a.assembly_item_id = '297'
AND
b.bill_sequence_id = a.bill_sequence_id
AND
b.bom_item_type = '4';
----OUTPUT of the Section_03A_bom_structures_b.sql QUERY---
ASSEMBLY_ITEM_ID ORGANIZATION_ID BILL_SEQUENCE_ID BOM_ITEM_TYPE BILL_SEQUENCE_ID COMPONENT_ITEM_ID
*[297]* 207 *[384]* 4 384 *[185]*
*[297]* 207 *[384]* 4 384 *[241]*
*[297]* 207 *[384]* 4 384 *[249]*
*[297]* 207 *[384]* 4 384 *[4747]*
*[297]* 207 *[384]* 4 384 *[4749]*
*[297]* 207 *[384]* 4 384 *[4751]*
=================================================================================================
note output FROM EACH SELECT that needs to be passed to the next SELECT statement are *[ ]* for example *['225957'] see below:*
----OUTPUT of the Section_01_UserInput.sql QUERY---
ORGANIZATION_CODE ORGANIZATION_ID INVENTORY_ITEM_ID SEGMENT1 DESCRIPTION
M1, 207, *[225957]* , CN927779, Sentinel Custom Desktop
----OUTPUT of the Section_02_bom_structures_b.sql QUERY---
ASSEMBLY_ITEM_ID ORGANIZATION_ID BILL_SEQUENCE_ID BOM_ITEM_TYPE BILL_SEQUENCE_ID COMPONENT_ITEM_ID
*[225957]* , 207 , *[90754]* 2 90754 *[297]*
*[225957]* , 207 , *[90754]* 2 90754 *[299]*
*[225957]* , 207 , *[90754]* 2 90754 *[301]*
----OUTPUT of the Section_03A_bom_structures_b.sql QUERY---
ASSEMBLY_ITEM_ID ORGANIZATION_ID BILL_SEQUENCE_ID BOM_ITEM_TYPE BILL_SEQUENCE_ID COMPONENT_ITEM_ID
*[297]* 207 *[384]* 4 384 *[185]*
*[297]* 207 *[384]* 4 384 *[241]*
*[297]* 207 *[384]* 4 384 *[249]*
*[297]* 207 *[384]* 4 384 *[4747]*
*[297]* 207 *[384]* 4 384 *[4749]*
*[297]* 207 *[384]* 4 384 *[4751]*
Edited by: user612347 on Mar 16, 2010 4:21 PM
Edited by: user612347 on Mar 16, 2010 4:57 PMHi,
Sorry, it's unclear what you want to do.
Whenever you have a problem, it helps to be as specific as you can.
Post a little sampel data (CREATE TABLE and INSERT statements) and the results you want from that data. Since your problem involves parameters, give a couple of sets of parameters, and the results you want for each set, given the same data.
Are you saying that, after the user enters one set of parameters, you will need to run a variation of this query:
SELECT a.assembly_item_id, a.organization_id, a.bill_sequence_id, b.bom_item_type, b.bill_sequence_id, b.component_item_id
FROM bom_structures_b a, bom_components_b b
WHERE a.assembly_item_id = '303'
AND
a.organization_id = '207'
AND
b.bill_sequence_id = a.bill_sequence_id
AND
b.bom_item_type = '4';several times? What will be different each time? Will the hard-coded strings in the WHERE clause ('303', '207' and '4') be values from the earlier query?
Do you really want to run this query several times, or would you rather run one query, and have it produce results for all the relevant values? (That would probably be eaisest and less error-prone). When you post your desired results, post what you would most like to see. If something else is acceptable, describe it.
You can write SQL*Plus scripts to use parameters (substitution variables.
For example, you can write a query that says:
WHERE a.assembly_item_id = '&1'
AND a.organization_id = '&2'
AND b.bill_sequence_id = a.bill_sequence_id
AND b.bom_item_type = '&3';and call it like this
@Section_03A_bom_structures_b 303 207 4You can have a query output several such rows (for example:
@Section_03A_bom_structures_b 303 207 4
@Section_03A_bom_structures_b 304 298 3
@Section_03A_bom_structures_b 306 99 4), send all of that output to a SPOOL file, and then execute the SPOOL file. -
Count the number of rows resulting from a select statement
Hi,
Is there any way of counting the number of rows resulting from a select statement. i.e I have a select distinct statement and I then want to perform an IF statement on the number of rows resulting from the select statement.
Any help appreciated
Thanks
GaryDeclare
var1 number;
Begin
select count(distinct column_name) into
var1 from table_name;
If var1 > x Then
End IF;
End;
Hope I understood the problem correctly
null -
How to pass an array to a function from a SELECT statement
Hi all. I have a problem with passing an array to a function directly from a SELECT statement.
Here is what I want. If I have a function
function AAA(arrayVar <ArrayType>) return number;
I want to be able to call this function this way
select AAA((2,3,4))
from dual
or this way
select AAA((10,12))
from dual
In other words I want to be able to pass an arbitrary number of numbers to the function. And I want this to work in a SELECT statement.
Does anyone have any ideas how to implement this? What <ArrayType> should I use?(I've read about VARRAY, nested tables in the Oracle documentation but as far as I've understood these array types are meant to be used within PL/SQL blocks).
I found only this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:208012348074 through Google but it didn't help me.
Thank you in advance.> What <ArrayType> should I use?
SQL data types - as 3360 showed above. You cannot use PL/SQL structures and user types in the SQL Engine.
You can however use all SQL structures and types in PL/SQL.
Arrays in SQL is created as collection type - basic o-o. The collection type (or class) serve as a container for instantiated objects or scalar type.
This is covered in detail in [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm]
Oracle® Database Application Developer's Guide - Object-Relational Features -
How to get XML format output from Hyperion Financial Reporting
Dears,
We are using Hyperion Financial Reporting to replace FSG in fusion. I found that Hyperion FR report can be exported to html/excel/pdf format. However, I would like the report to export to xml format.It means I only need the xml data source.
Anyone who knows how to get the xml format output from Hyperion FR, is there any avaiable API?I think if you export the report, you will be able to open the .des file in Notepad/Wordpad and see xml content.
-
Adding count from two select statements
Hi,
How to add counts from two select statements in a single SQL statement.
For ex: I have
SELECT COUNT(DISTINCT COL1) FROM table1
and
SELECT COUNT(DISTINCT COL2) FROM table2.
I want to add the counts from these two sqls in a single select query. How to do this.
Thanks & Regards,
Sunil.select ((SELECT COUNT(DISTINCT COL1) FROM table1) + (SELECT COUNT(DISTINCT COL2) FROM table2)) as "total" from dual;
regards, -
Rerieve Duplicate Rows from a SELECT statement
Hi, I want to see all the duplicate rows from my SELECT statement. Looks like Oracle by default suppresses the duplicate rows. Here is my SQL statement.
I like to see all the 5 rows. Please help.
select a.partid, a.pdesc
from product a
where a.partid in ('10-30000-4',
'10-30000-4',
'10-30000-4',
'10-30000-4',
'10-30000-5')Looks like Oracle by default suppresses the duplicate rowsSure no, if you have duplicate rows, Oracle will show you the dup rows.
Please, paste your data and the query result.
And this is no because you'll put multiple time the same condition that Oracle will show you multiple time the same row (in case of non-duplicate).
Nicolas. -
Function output in a select statement
I have written a function(get_cols) which returns the following string (this string is created dynamically from the fuctions depending on the rows of the tables)
the output of the function is;
MAX (CASE WHEN field_code = 'test_pho' THEN VALUE END ) AS test_pho
,MAX (CASE WHEN field_code = 'ESN' THEN VALUE END ) AS ESN
,MAX (CASE WHEN field_code = 'IMSI' THEN VALUE END ) AS IMSI
,MAX (CASE WHEN field_code = 'PHONE_NO' THEN VALUE END ) AS PHONE_NO
What I need to do is to use this as it is in a another select statement like;
(1)
select
empno,
MAX (CASE WHEN field_code = 'test_pho' THEN VALUE END ) AS test_pho
,MAX (CASE WHEN field_code = 'ESN' THEN VALUE END ) AS ESN
,MAX (CASE WHEN field_code = 'IMSI' THEN VALUE END ) AS IMSI
,MAX (CASE WHEN field_code = 'PHONE_NO' THEN VALUE END ) AS PHONE_NO
from my_employee e, my_columns c
where e.emp_no = c.emp_no
and c.emp_no = '100003'
group by empno
function returns the correct output, but when i call the function in the select like below it get it as a whole string and doesn't give the correct output
(2)
select empno, get_cols('100003')
from my_employee e, my_columns c
where e.emp_no = c.emp_no
and c.emp_no = '100003'
how can i get the output of the function to the select as separate line as shown is above(1)
When I get the above output separately and give in the select as above (1) it gives the correct output I want ??
any help pleasejosleen wrote:
Hi BluShadow,
Your solution seem interesting. Can you explain how can this be used to produce the required output ? Do we need to maintain a separate my_columns table ?Not quite sure what you are asking?
As with any query, the output columns have to be defined at design time, you cannot have the number of columns dynamically generated based on the data. So, if you said you wanted to pivot data from rows to columns and the number of possible values in those rows could change, you cannot pivot those to columns unless you are expecting those values or have allowed for maximum number of values.
Basic example... Let say we have the following data:
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTONAnd we want to pivot that data to put the departments as columns rather than rows. We can simply do something like:
SQL> ed
Wrote file afiedt.buf
1 select max(decode(deptno,10,dname)) as dname_10
2 ,max(decode(deptno,10,loc)) as loc_10
3 ,max(decode(deptno,20,dname)) as dname_20
4 ,max(decode(deptno,20,loc)) as loc_20
5 ,max(decode(deptno,30,dname)) as dname_30
6 ,max(decode(deptno,30,loc)) as loc_30
7 ,max(decode(deptno,40,dname)) as dname_40
8 ,max(decode(deptno,40,loc)) as loc_40
9* from dept
SQL> /
DNAME_10 LOC_10 DNAME_20 LOC_20 DNAME_30 LOC_30 DNAME_40 LOC_40
ACCOUNTING NEW YORK RESEARCH DALLAS SALES CHICAGO OPERATIONS BOSTON
SQL>However if a further department is added:
SQL> insert into dept values (50, 'IT SUPPORT', 'LONDON');
1 row created.
SQL> select max(decode(deptno,10,dname)) as dname_10
2 ,max(decode(deptno,10,loc)) as loc_10
3 ,max(decode(deptno,20,dname)) as dname_20
4 ,max(decode(deptno,20,loc)) as loc_20
5 ,max(decode(deptno,30,dname)) as dname_30
6 ,max(decode(deptno,30,loc)) as loc_30
7 ,max(decode(deptno,40,dname)) as dname_40
8 ,max(decode(deptno,40,loc)) as loc_40
9 from dept
10 /
DNAME_10 LOC_10 DNAME_20 LOC_20 DNAME_30 LOC_30 DNAME_40 LOC_40
ACCOUNTING NEW YORK RESEARCH DALLAS SALES CHICAGO OPERATIONS BOSTON
SQL>we obviously don't get to see the new data, unless we change our query to add this expected additional column(s) in...
SQL> ed
Wrote file afiedt.buf
1 select max(decode(deptno,10,dname)) as dname_10
2 ,max(decode(deptno,10,loc)) as loc_10
3 ,max(decode(deptno,20,dname)) as dname_20
4 ,max(decode(deptno,20,loc)) as loc_20
5 ,max(decode(deptno,30,dname)) as dname_30
6 ,max(decode(deptno,30,loc)) as loc_30
7 ,max(decode(deptno,40,dname)) as dname_40
8 ,max(decode(deptno,40,loc)) as loc_40
9 ,max(decode(deptno,50,dname)) as dname_50
10 ,max(decode(deptno,50,loc)) as loc_50
11* from dept
SQL> /
DNAME_10 LOC_10 DNAME_20 LOC_20 DNAME_30 LOC_30 DNAME_40 LOC_40 DNAME_50 LOC_50
ACCOUNTING NEW YORK RESEARCH DALLAS SALES CHICAGO OPERATIONS BOSTON IT SUPPORT LONDON
SQL>Now, rather than having a messy SQL statment with lots of max(decode... statements we can provide a pipelined function to return the same thing...
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE TYPE mydepts AS OBJECT
2 ( dname_10 VARCHAR2(14),
3 loc_10 VARCHAR2(13),
4 dname_20 VARCHAR2(14),
5 loc_20 VARCHAR2(13),
6 dname_30 VARCHAR2(14),
7 loc_30 VARCHAR2(13),
8 dname_40 VARCHAR2(14),
9 loc_40 VARCHAR2(13),
10 dname_50 VARCHAR2(14),
11 loc_50 VARCHAR2(13)
12* )
13 /
Type created.
SQL> ed
Wrote file afiedt.buf
1* CREATE OR REPLACE TYPE mydepttable AS TABLE OF mydepts
SQL> /
Type created.
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE FUNCTION alldepts RETURN mydepttable PIPELINED IS
2 v_obj mydepts := mydepts(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
3 CURSOR cur_depts IS
4 select deptno, dname, loc from dept;
5 BEGIN
6 FOR i IN cur_depts
7 LOOP
8 CASE i.deptno
9 WHEN 10 THEN v_obj.dname_10 := i.dname; v_obj.loc_10 := i.loc;
10 WHEN 20 THEN v_obj.dname_20 := i.dname; v_obj.loc_20 := i.loc;
11 WHEN 30 THEN v_obj.dname_30 := i.dname; v_obj.loc_30 := i.loc;
12 WHEN 40 THEN v_obj.dname_40 := i.dname; v_obj.loc_40 := i.loc;
13 WHEN 50 THEN v_obj.dname_50 := i.dname; v_obj.loc_50 := i.loc;
14 ELSE NULL;
15 END CASE;
16 END LOOP;
17 PIPE ROW (v_obj);
18 RETURN;
19* END;
SQL> /
Function created.
SQL> select *
2 from table(alldepts());
DNAME_10 LOC_10 DNAME_20 LOC_20 DNAME_30 LOC_30 DNAME_40 LOC_40 DNAME_50 LOC_50
ACCOUNTING NEW YORK RESEARCH DALLAS SALES CHICAGO OPERATIONS BOSTON IT SUPPORT LONDON
SQL>So, now there is a single function that acts like a table and does the functionality of pivoting the data. What the function actually does to generate the data is entirely up to you whether that is obtaining data from different tables or some PL/SQL code processing to perform some complex algorithmic type thing on the data from a passed in parameter etc. The point of the pipeline function is that it can return multiple columns of data and act as if it is a table that can be queried against, however it still remains that the output columns must be known at design time. This is actually a requirement of the SQL engine, as you cannot make a dynamic function that returns X number of columns based on data.
There is however a technique that can allow you to dynamically generate a number of columns based on data, but it involves getting a little more under the hood of Oracle and interfacing with the ODCI interface, actually using a pipelined funcion technique in conjunction with, in laymans terms, stepping in at the point the query is executing and telling oracle what columns this pipelined function is going to return, but at the same time as defining the returned columns.
An example of doing this is given by AScheffer on this thread: How to pipeline a function with a dynamic number of columns?
... but you really are getting into a complex world if you try and write your queries this way, just to try and make generic queries with dynamic columns.
In essence, the actual business need to actually return a dynamic number of columns is very slim as most applications, whether that is a user facing interface or report generator etc. will be expecting certain data columns to be returned to expected columns or fields within them. If you really want to dynamically pivot data with an unknown number of columns it is usually best to let things like reporting tools deal with this area as that is what they are best at, and don't try and do it within SQL. -
How to processing the results from the select statement in SQL query?
Hi
This might be too simple, but my knowledge of the SQL is very limited...
I have table where I do have details from calls (Lync QoE).
I can take all calls from the table, but I would like to count the concurrent calls on the table. This is how I got it work on the Excel to work (but I would like to do that on the SQL statement to get it more dynamic use):
Table have these line and this is what I get out from the Select):
[callid],[start],[end]
1ABC,1.1.2014 01:00:15, 1.1.2014 01:01:00
5DEF,1.1.2014 01:00:45, 1.1.2014 01:05:00
FDE2,1.1.2014 01:03:15, 1.1.2014 01:04:00
KDJ8,1.1.2014 01:04:15, 1.1.2014 01:06:00
FDJ8,2.1.2014 01:04:15, 2.1.2014 01:06:00
KDSE,3.1.2014 01:04:15, 3.1.2014 01:06:00
The information I would like to get, is what is the maximum amount of the concurrent calls per day.
On the excel I basically count line by line how many concurrent calls each line have had, and then pickup the highest one. On above example the calls 5DEF, FDE2 and FDE2 have been active at the same time which gives 3 for the first day.
The table is ordered by the start. So let say the code is on the third line (FDE2). I need to count calls from before which end time is after the start time (of FDE2), but also I need to count calls after (FDE2) which are started before the current
call has ended.
PetriUnfortunately your post is off topic as it's not specific to SQL Server Samples and Community Projects.
This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it. The links I provide below will help you determine the right forum to ask your question in.
For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
Office, IE, and other products.
For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
search for your product name.
For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
search for your product or issue.
If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
If you think your issue is related to SQL Server Samples and Community Projects and I've flagged it as Off-topic, I apologise. Please repost your question and include as much detail as possible about your problem so that someone can assist you further.
If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
When you see answers and helpful posts, please click Vote As Helpful,
Propose As Answer, and/or Mark As Answer
Jeff Wharton
MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
Blog: Mr. Wharty's Ramblings
Twitter: @Mr_Wharty
MC ID:
Microsoft Transcript -
Querying many tables at once from a select statement for specific values
Hi all,
I'm very new to PL/SQL and have a daunting task ahead of me. I'm pretty sure our database normalization scheme is all out of whack, which I dont have the experience to fix yet, but this is the task ahead of me without getting to change or fix our structure:
in the universe has 1000+ tables.
need--> Some of those tables have fields that contain a value that has to be changed.
The only thing I have to go on is the column name will contain 'EMP'... but there is no specific naming convention for the column names.
When I search on:
select * from all_tab_columns where column_name like UPPER('%EMP%')
It returns 750 rows. (So 750 rows = 750 columns in 500 different tables (some tables have 2 or more columns in it))
tables names are random (table1, table2, etc).
columns names are random with EMP in it (column1,column2,etc).
I have 75 possible field values that I need to check each of those 750 columns for.
Maybe this is too messy, but I'm looking at subqueries, joins, arrays, cursors, etc, anything to minimize the amount of work I have to do.
I think this is too much to do a join with, but that seems to be what all the documentation is pointing me to.
can you point me to a simple example of what i could
write?
the logic i see it would be
run the select statement to grab the column names that meet EMP.
one at a time, search each column in the corresponding table for the 75 values.
return the results of rows for each column/table that meet one of the 75 unique values.
I'll have to also update each of the 75 values to (used to be values 1, 2, 3 ... to new values X1, X2, X3, etc.)
Any help at all would be very helpful,
aspiring pl/sql programmer but having a rough time of itI think you're looking to do something like the following pseudocode:
BEGIN
FOR tblrec IN (SELECT table_name, column_name
FROM all_tab_columns
WHERE column_name LIKE '%EMP%')
LOOP
FOR rec IN (SELECT ROWID
FROM tblrec.table_name
WHERE REGEXP_LIKE(tblrec.column_name, '(expr1|expr2|...)')
LOOP
DBMS_OUTPUT.PUT_LINE(
'Found expression on ROWID ' || rec.rowid
|| ' in column ' || tblrec.column_name
|| ' on table ' || tblrec.table_name);
END LOOP;
END LOOP;
END; -
Fetching a value from a select statement inside select clause
hello all,
I have a problem executing a procedure it gives me a runtime error, what am doing is i have multiple select statement inside a select clause. am using the entire select statement for a ref cursor. when running the query seperately am able to get the records but it's not getting compiled.
here is the piece of code which am working with
create or replace procedure cosd_telecommute_procedure
(p_from_date in date,
p_to_date in date,
p_rset in out sys_refcursor)
as
p_str varchar2(10000);
begin
p_str := 'select personnum, '||
'fullname, '||
'personid, '||
'hours, '||
'applydtm, '||
'paycodeid, '||
'laborlev2nm, '||
'laborlev3nm, '||
'laborlev2dsc, '||
'adjdate, '||
'timeshtitemtypeid, '||
'(select max(eff_dt) from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt between ''01-aug-2005'' and ''30-aug-2005'') thisyreffdt, '||
'(select elig_config7 from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt = (select max(eff_dt) from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt between ''01-aug-2005'' and ''30-aug-2005'')) thisyrmiles,'||
'(select max(eff_dt) from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt between trunc(p_from_date) and trunc(p_to_date)) fiscalyreffdt, '||
'(select elig_config7 from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt = (select max(eff_dt) from cosd_telecommute_info_tbl '||
'where emplid = cosd_vp_telecommute.personnum and '||
'eff_dt between trunc(p_from_date) and trunc(p_to_date))) fiscalyrmiles '||
'from cosd_vp_telecommute '||
'where trunc(applydtm) '||
'between p_from_date and p_to_date '||
'and personnum = ''029791''';
open p_rset for p_str;
end cosd_telecommute_procedure;
and here is the piece of error am getting
ERROR at line 1:
ORA-00904: invalid column name
ORA-06512: at "TKCSOWNER.COSD_TELECOMMUTE_PROCEDURE", line 40
ORA-06512: at line 5Did you run the query in SQL plus? Check whether all the column are valid in your database. Below is the query which i got from your procedure just run and check it out. It is really hard for us to tell you the problem without knowing the table structure
select personnum, fullname, personid, hours, applydtm, paycodeid, laborlev2nm, laborlev3nm,
laborlev2dsc, adjdate, timeshtitemtypeid,
(select max(eff_dt) from cosd_telecommute_info_tbl
where emplid = cosd_vp_telecommute.personnum
and eff_dt between '01-aug-2005' and '30-aug-2005') thisyreffdt,
(select elig_config7 from cosd_telecommute_info_tbl where emplid = cosd_vp_telecommute.personnum
and eff_dt = (select max(eff_dt)
from cosd_telecommute_info_tbl
where emplid = cosd_vp_telecommute.personnum
and eff_dt between '01-aug-2005' and '30-aug-2005'
) thisyrmiles,
(select max(eff_dt)
from cosd_telecommute_info_tbl
where emplid = cosd_vp_telecommute.personnum
and eff_dt between trunc(p_from_date) and trunc(p_to_date)
) fiscalyreffdt,
(select elig_config7 from cosd_telecommute_info_tbl where emplid = cosd_vp_telecommute.personnum
and eff_dt = (select max(eff_dt)
from cosd_telecommute_info_tbl
where emplid = cosd_vp_telecommute.personnum
and eff_dt between trunc(p_from_date) and trunc(p_to_date)
) fiscalyrmiles
from cosd_vp_telecommute
where trunc(applydtm) between p_from_date and p_to_date
and personnum = '029791' -
How can I call a Page Process from the Select statement for Report Page
I'm able to call a javascript using the below:
img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
But Now,
I'd like to accomplish (2) New things:
1. instead of using,....... onClick="javascript:add_connect1,
I'd like to call a Page Process, onClick=
2. I'd like to be able to call two different processes onClick.
a. onClick="javascript:passBack('||ID||')"
b. onClick= <Please see my question #1 above>
Can someone please help me with the syntax for this,
If indeed it can even be done?
Thanks- GaryGreg.
It seems that my situation is the one you describe in you second paragraph, where you mention:
you could then add the ID column value as a parameter to the javascript functionBut,
I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
Here's what I've got so far:
A. In the select statement I identify the javascript as:
onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
B. In my javascript I have this:
<script language="JavaScript" type="text/javascript">
function connect_port(ID)
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
gReturn = get.get();
get = null;
</script>
C. In my on demand function I have this:
BEGIN
INSERT INTO CCONNECTIONS_B
BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
) VALUES
:P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
END;
You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
If you can help me out with this one, Then I can imitate it for the rest.
-Gary
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:44 AM
Edited by: garyNboston on Apr 3, 2009 6:45 AM
Edited by: garyNboston on Apr 3, 2009 6:47 AM -
Output count of SELECT statement is diff from count(*) of the same query
Has this ever happened to you?
I was wondering why some of the items were not appearing in my output. I have this select query:
SELECT
bukrs
gjahr
hkont
belnr
wrbtr
dmbtr
matnr
bschl
kunnr
vbeln
shkzg
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE i_output
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
When I tried to put sample filters (bukrs: 1000; belnr 1800000016; gjahr: 2005; hkont: 4000000), I am getting 3 entries from bseg. But when I tried using SE16 or SE16N, I am getting 6 (which is the expected output). When I modify the same SELECT query to return just the output count, I AM getting 6.
SELECT count(*)
FROM bseg
INTO count
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
Do you have any idea why this happens? My internal table is a standard table with no header line and no OCCURS statement.
KyleHello Kyle,
Thats because when using FOR ALL ENTRIES, it will delete the duplicates if the records selected dont have all the primary keys specified in the select query. In your first select query, the field BUZEI is missing which makes the records unique. Change your first select query as this and try
SELECT
bukrs
gjahr
hkont
belnr
buzei -------> Add this and check
wrbtr
dmbtr
matnr
bschl
kunnr
vbeln
shkzg
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE i_output
FOR ALL ENTRIES IN i_bkpf
WHERE
bukrs EQ i_bkpf-bukrs
AND belnr EQ i_bkpf-belnr
AND gjahr EQ i_bkpf-gjahr
AND hkont IN hkont
AND hkont IN
('0004000000',
'0004000010',
'0004000020',
'0004000030',
'0004000040')
Vikranth -
A litttle help formatting output from powershell?
Hi all, I am working on a software inventory project and am (as will become obvious) a novice at powershell. I have the script running so I get what I need, but the formatting is borderline un-useable. I would like to see if anyone can point
me in the direction of creating one or two of the following: a single, collated file of all installed programs on all computers in the OU, filtered for duplicates (ie, only unique entries, not 37 instances of Office 2010 Service Pack 2), and/or an excel worksheet
with a page for each pc in the OU, and the list of installed programs on each page. This is what I have so far:
$rtn = $null
Get-ADComputer -filter '*' -searchbase 'ou=levy chd, dc=doh,dc=ad,dc=state,dc=fl,dc=us'|
ForEach-Object {
$rtn = Test-Connection -CN $_.dnshostname -Count 1 -BufferSize 16 -Quiet
IF($rtn -match 'True') {write-output $_.name | out-file C:\chd38computers_ping=true.csv -Append }
ELSE { write-output $_.name | out-file C:\chd38computers_ping=false.txt -Append }
$computers = Import-Csv "C:\chd38computers_ping=true.csv"
foreach($obj in $computers){
Get-WmiObject -Class win32reg_addremoveprograms | Select DisplayName,Publisher,Version,Installdate | Sort Publisher -Descending| Export-Csv d:\installed_apps.csv -append
Thanks in advance for the help!
adamTo filter out duplicates, you can use the -unique switch for Select here:
Get-WmiObject -Class win32reg_addremoveprograms | Select DisplayName,Publisher,Version,Installdate -unique | Sort Publisher -Descending| Export-Csv d:\installed_apps.csv -append
To manipulate excel file from Powershell you will need to use New-Object -ComObject "Excel.Application". I'd add the result of each computer into an array and then use the ComObject to add the content to a new sheet. You can read more here:
http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/03/excel-spreadsheets.aspx
tompa
http://tompaps.blogspot.com -
Formatting Output from a procedure
Hi all,
I want to format the output of this procedure
declare
cursor c1 is select tname from tab where tabtype = 'TABLE' ;
tabname varchar2(1000) ;
i number := 1;
rc number ;
str varchar2(1000) ;
begin
open c1 ;
loop
fetch c1 into tabname ;
exit when c1%notfound ;
str := 'select count(*) from ' || tabname ;
execute immediate str into rc ;
dbms_output.put_line(i || ' - ' || tabname || ' -- ' ||rc) ;
i := i + 1 ;
end loop ;
close c1 ;
end ;
The OUTPUT is like this.......
1 - asdf -- 0
2 - asdfsdafasdf -- 16
3 - asdfsaf -- 327
4 - asdfasdfasfsdafsdfs -- 27
5 - asd -- 128562
Now, I want this output should be like this
1 - asdf -- 0
2 - asdfsdafasdf -- 16
3 - asdfsaf -- 327
4 - asdfasdfasfsdafsdfs -- 27
5 - asd -- 128562
Thanks in advance,
PalUse [ pre ] and [ /pre ] with no sapce.
http://www.oracle.com/technology/forums/faq.html#q14
But,for your question, using to_char or lpad, you can format.
dbms_output.put_line(i || ' - ' || tabname || ' -- ' ||lpad(rc,20)) ;
-- Oops, I correct as following.
dbms_output.put_line(rpad(i || ' - ' || tabname || ' -- ' ,60)||lpad(rc,20)) ;
Message was edited by:
ushitaki
Maybe you are looking for
-
Year View for iCal?!
Hi, I work a lot with projects of a few weeks length and I would really like to be able to see these in a year view in iCal. Does anybody now an addon or tool which can do that for me? So far I just printed the year, several month per page, and saved
-
Payment term thread continuation with that
Thank you all.for your reply to previous thread of mine. So in relation to above my requirement is that Cash discount is based on payment term and differs from material to material. Suppose i maintain a cash discount of 1% for material x and the pay
-
Hi I just wanted to know if you could recommend me a nice method to display .jpg images on a website. I know that DW offers templates but I was wondering if there is a software package that you would recommend to me that is both easy to use and looks
-
My Java permissions are wrong can I correct this?
Ran DiskUtility and did a repair... did a restart and ran it againg, the same permissions were wrong again... can I go into 'get info' and manually reset them? Permissions differ on "System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/
-
How to manage logging in weblogic through Java Programme.
Hi Experts, I want to added logging to weblogic server(Admin Server and 3 Managered Servers) using java code.Is it possible? I have an admin server and some 3 managed servers.I want to added a logging suppose for org.springframework package to see de