Result of the COIL query SELECT UNIX - tabular format
This request of mine is an extension of my previous thread that I've marked as 'Response' (where the new position).I am now able to spool the output of the SELECT query in a file through unix shell script.
However, the output is not formatted. I tried to use options like
COLUMN column_name FORMAT A20, but this has not worked as planned.
I have 5 columns in the table and my output is to have these columns by dragging to the next line.
for example, I want something like
column1 column2 column3 column4 column5
======================================================================
value1 value2 value3 value4 value5
But I get:column1 column2
======================
value1 value2
column3 column4
======================
value3 value4
column5
===========
value5
That is to say columns are coming on a single line or header and the value are aligned.any thoughts? what I'm missing here?
Published by: Caitanya November 2, 2009 07:39
set line 12000;
set page 500;
Before you run the query, and after you connect to SQLPLUS.
See you soon!
Bhushan Salgar
Tags: Database
Similar Questions
-
Where is the result of the following query caching?
I run the following query statement:
Where is the result of the following query caching? Is cached in the PGA? What area of PGA?select * from hr.employees
By definition is not "cache". The blocks of data that are read to retrieve the results of the query are retrieved in the cache (DB_CACHE_SIZE or DB_BLOCK_BUFFERS component BMG) buffers so that they are accessible on several occasions by the same users or other users. However, because the buffer cache is limited in size, buffers are released when new blocks to be read. Buffers for a full table scan (as it would be for such a request) are released very probably earlier.
Please read the Oracle database documentation, starting with the Concepts manual for the version you are using. Starting at http://tahiti.oracle.com
Hemant K Collette
-
How to set the result of the dynamic query in a refcursor ON param.
Hello
I created the following package.
CREATE OR REPLACE package LGIS
Is
Type T_Cust_Acct_Arr is table of number;
Type Invc_Base_Rec_Type is (Record
Invoice_Control_No Customer_History.Invoice_Control_No%Type,
Billing_Cycle_Id Eb_Oor_Cust_Online.Billing_Cycle_Id%Type,
Bill_Cycl_Occr_No Eb_Oor_Cust_Online.Bill_Cycl_Occr_No%Type,
Invoice_Dt Bill_Cycl_Occr_Inf.Invoice_Date%Type,
Invc_Acct_Id Eb_Oor_Cust_Online.Customer_Acct_Id%Type,
Acct_Id Eb_Oor_Cust_Online.Customer_Acct_Id%Type
);
Type Invc_Base_Refcur_Type is Ref Cursor
Return Invc_Base_Rec_Type;
Procedure P_Get_Approved_Whole_Invcs)
In_From_Invc_Dt by Date,
In_To_Invc_Dt by Date,
In_Cust_Acct_List in T_Cust_Acct_Arr,
Out_Eb_Invcs on Invc_Base_Refcur_Type
On_Error_No number
);
End LGIS;
/
CREATE OR REPLACE PACKAGE BODY Lgis
IS
PROCEDURE P_Get_Approved_Whole_Invcs)
In_From_Invc_Dt BY DATE,
In_To_Invc_Dt BY DATE,
In_Cust_Acct_List IN T_Cust_Acct_Arr,
Out_Eb_Invcs on Invc_Base_Refcur_Type
On_Error_No NUMBER
)
IS
S_Query VARCHAR2 (4000);
Invalid_Exception EXCEPTION;
BEGIN
On_Error_No: = 0;
IF In_Cust_Acct_List.COUNT > 0 THEN
FORALL i IN 1.In_Cust_Acct_List.COUNT
INSERT INTO EB_CUST_ACCT_WHOLE_TMP (Cust_Acct_Val)
VALUES (In_Cust_Acct_List (i));
END IF;
BEGIN
S_Query: = 'Select Ch.Invoice_Control_No,';
S_Query: = S_Query | ' Eoco.Billing_Cycle_Id,';
S_Query: = S_Query | ' Eoco.Bill_Cycl_Occr_No,';
S_Query: = S_Query | ' Bcoi.Invoice_Date,';
S_Query: = S_Query | ' Eoco.Customer_Acct_Id as Invc_Acct_Id';
S_Query: = S_Query | ' Eoco.Customer_Acct_Id as Acct_Id ';
S_Query: = S_Query | "Of Eb_Oor_Cust_Online Eoco,';
S_Query: = S_Query | "Customer_History Ch';
S_Query: = S_Query | ' Bcoi Bill_Cycl_Occr_Inf,';
S_Query: = S_Query | "Audit_Var_Log Avl,';
S_Query: = S_Query | "Audit_Var_Def Avd,';
S_Query: = S_Query | "Eb_Cust_Acct_Whole_Tmp Tmp';
S_Query: = S_Query | "Where Avd.Audit_Var_Cd ="CYCLE_APPROVAL"';
S_Query: = S_Query | ' And Avl.Audit_Var_Sub_Grp_Val = 0';
S_Query: = S_Query | "And Avl.Audit_Var_Char_Val =" COMPLETE "';
S_Query: = S_Query | ' And Eoco.Customer_Acct_Id = Tmp.Cust_Acct_Val';
S_Query: = S_Query | ' And Eoco.Customer_Acct_Id = Ch.Customer_Acct_Id';
S_Query: = S_Query | ' And Eoco.Billing_Cycle_Id = Ch.Billing_Cycle_Id';
S_Query: = S_Query | ' And Eoco.Bill_Cycl_Occr_No = Ch.Bill_Cycl_Occr_No';
S_Query: = S_Query | ' And Eoco.Billing_Cycle_Id = Bcoi.Billing_Cycle_Id';
S_Query: = S_Query | ' And Eoco.Bill_Cycl_Occr_No = Bcoi.Bill_Cycl_Occr_No';
S_Query: = S_Query | ' And Avd.Audit_Var_Id = Avl.Audit_Var_Id';
S_Query: = S_Query | ' And Avl.Audit_Var_Grp_Id = Bcoi.Audit_Var_Grp_Id';
IF (In_From_Invc_Dt IS NULL AND In_To_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | "And Bcoi.Invoice_Date < = In_To_Invc_Dt';
END IF;
IF (In_To_Invc_Dt IS NULL AND In_From_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | ' And Bcoi.Invoice_Date > = In_From_Invc_Dt';
END IF;
IF (In_From_Invc_Dt IS NOT NULL AND In_To_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | ' And Bcoi.Invoice_Date > = In_From_Invc_Dt';
S_Query: = S_Query | "And Bcoi.Invoice_Date < = In_To_Invc_Dt';
END IF;
RUN IMMEDIATELY S_Query IN Out_Eb_Invcs;
EXCEPTION
WHILE OTHERS THEN
On_Error_No: = - 1;
RAISE Invalid_Exception;
END;
Exception
When Invalid_Exception then
On_Error_No: = - 1;
Return;
While others then
On_Error_No: = - 1;
END P_Get_Approved_Whole_Invcs;
Lgis END;
/
It compiles without error. But at runtime, I get the following error:
ORA-06504: PL/SQL: return variables of the game results or the query types do not match
Please help solve this problem.
Thank you
OlivierMaybe it will work for you too->
CREATE OR REPLACE Package Body Lgis Is Procedure P_Get_Approved_Whole_Invcs ( In_From_Invc_Dt In Date, In_To_Invc_Dt In Date, In_Cust_Acct_List In T_Cust_Acct_Arr, Out_Eb_Invcs Out Invc_Base_Refcur_Type, On_Error_No Out Number ) Is S_Query Varchar2(4000); Invalid_Exception Exception; Begin On_Error_No := 0; If In_Cust_Acct_List.Count > 0 Then Forall I In 1..In_Cust_Acct_List.Count Insert Into Eb_Cust_Acct_Whole_Tmp (Cust_Acct_Val) Values (In_Cust_Acct_List (I)); End If; Begin S_Query := ' Select Ch.Invoice_Control_No Invoice_Control_No, ' ||' Eoco.Billing_Cycle_Id Billing_Cycle_Id, ' ||' Eoco.Bill_Cycl_Occr_No Bill_Cycl_Occr_No, ' ||' Bcoi.Invoice_Date Invoice_Dt, ' ||' Eoco.Customer_Acct_Id As Invc_Acct_Id,' ||' Eoco.Customer_Acct_Id As Acct_Id ' ||' From Eb_Oor_Cust_Online Eoco, ' ||' Customer_History Ch, ' ||' Bill_Cycl_Occr_Inf Bcoi, ' ||' Audit_Var_Log Avl, ' ||' Audit_Var_Def Avd, ' ||' Eb_Cust_Acct_Whole_Tmp Tmp ' ||' Where Avd.Audit_Var_Cd = '||chr(39)||'CYCLE_APPROVAL'||chr(39) ||' And Avl.Audit_Var_Sub_Grp_Val = 0 ' ||' And Avl.Audit_Var_Char_Val = '||chr(39)||'COMPLETE'||chr(39) ||' And Eoco.Customer_Acct_Id = Tmp.Cust_Acct_Val ' ||' And Eoco.Customer_Acct_Id = Ch.Customer_Acct_Id ' ||' And Eoco.Billing_Cycle_Id = Ch.Billing_Cycle_Id ' ||' And Eoco.Bill_Cycl_Occr_No = Ch.Bill_Cycl_Occr_No ' ||' And Eoco.Billing_Cycle_Id = Bcoi.Billing_Cycle_Id ' ||' And Eoco.Bill_Cycl_Occr_No = Bcoi.Bill_Cycl_Occr_No ' ||' And Avd.Audit_Var_Id = Avl.Audit_Var_Id ' ||' And Avl.Audit_Var_Grp_Id = Bcoi.Audit_Var_Grp_Id ' If (In_From_Invc_Dt Is Null And In_To_Invc_Dt Is Not Null) Then S_Query:=S_Query||' And Bcoi.Invoice_Date <= In_To_Invc_Dt '; End If; If (In_To_Invc_Dt Is Null And In_From_Invc_Dt Is Not Null) Then S_Query:=S_Query||' And Bcoi.Invoice_Date >= In_From_Invc_Dt '; End If; If (In_From_Invc_Dt Is Not Null And In_To_Invc_Dt Is Not Null) Then S_Query:=S_Query||' And Bcoi.Invoice_Date >= In_From_Invc_Dt ' ||' And Bcoi.Invoice_Date <= In_To_Invc_Dt '; End If; Dbms_Output.Put_Line ('Test'); Open Out_Eb_Invcs For S_Query; Dbms_Output.Put_Line ('Test1'); Loop Fetch Out_Eb_Invcs Into Ibrt_Type; Exit When Out_Eb_Invcs%notfound; Dbms_Output.Put_Line ('Invoice_Control_No: ' || Ibrt_Type.Invoice_Control_No); Dbms_Output.Put_Line ('Billing_Cycle_Id: ' || Ibrt_Type.Billing_Cycle_Id); Dbms_Output.Put_Line ('Bill_Cycl_Occr_No: ' || Ibrt_Type.Bill_Cycl_Occr_No); Dbms_Output.Put_Line ('Invoice_Dt: ' || Ibrt_Type.Invoice_Dt); Dbms_Output.Put_Line ('Invc_Acct_Id: ' || Ibrt_Type.Invc_Acct_Id); Dbms_Output.Put_Line ('Acct_Id: ' || Ibrt_Type.Acct_Id); End Loop; Dbms_Output.Put_Line ('Test2'); Close Out_Eb_Invcs; /* Exception When Others Then On_Error_No := -1; Raise Invalid_Exception; */ End; Exception When Invalid_Exception Then On_Error_No := -1; Return; /* When Others Then On_Error_No := -1; */ End P_Get_Approved_Whole_Invcs; End Lgis;
Your problem is now fixed.
Kind regards.
LOULOU.
-
Passing the value of the SQL query select list
Hello
In my application users have in their homepage to a region which has two simple things, a part of LIST SLECT lov function and a BUTTON
There is also another page which has a normal life to report which shows the employees.
Homepage the user can select certain number of Department in its 'SLECT-LIST' and click 'open '.
For example: If the user has selected a DEP_NUM_5 and click on the BUTTON it will be redirected to the page of a report and gets only showed the employees belonging to the Department 5.
The report page contains a simple SQL query, and I understand that somehow I must pass the value in the SELECT LIST, where I now have the '?
How can I do this, where should I start?
Of course I would really appreciate an example of code, if anyone has time to do a.
select "EMP_ID", "EMP_FORNAME", "EMP_SURNAME", "DEP_NUMBER" from EMP E where E.DEP_NUMBER = ????????
Hi Sozua,
1. create an item hidden on the page where you have the report.
I say P2_DEPT_NO
2 assign to that in your sql query
select "EMP_ID", "EMP_FORNAME", "EMP_SURNAME", "DEP_NUMBER" from EMP E where E.DEP_NUMBER = :P2_DEPT_NO
below the area source ther is also an option
Elements of page to submit-> put this element in this.
for example;
Page to submit items: P2_DEPT_NO
3. change your button
Action: Redirecting to page of this application
Page: 2 / / assuming that page 2 is the report page
Place these items: P2_DEPT_NO
with these values: & P1_SELECT_LIST. assuming that selection list is on page 1
Hope this helps you,
Kind regards
Jitendra
-
result of the hierarchical query in xml format
Pls find below the example script table and the desired output format. Output XML must keep the information of hierarchy that is the requirement. Also is it possible to do it in single sql.
Thank you.
CREATE TABLE MAIN
(
IDENTIFICATION NUMBER,
NAME VARCHAR2 (20 BYTE)
);
INSERT INTO THE HAND (ID, NAME) VALUES)
1, "OS");
INSERT INTO THE HAND (ID, NAME) VALUES)
2, 'Windows');
INSERT INTO THE HAND (ID, NAME) VALUES)
3, 'BACK');
INSERT INTO THE HAND (ID, NAME) VALUES)
4, "1.x");
INSERT INTO THE HAND (ID, NAME) VALUES)
5, "1.1.x");
INSERT INTO THE HAND (ID, NAME) VALUES)
7, "1.1.1.1");
INSERT INTO THE HAND (ID, NAME) VALUES)
8, ' (1.2');
INSERT INTO THE HAND (ID, NAME) VALUES)
9, '2.x');
INSERT INTO THE HAND (ID, NAME) VALUES)
10, ' (2.1');
INSERT INTO THE HAND (ID, NAME) VALUES)
11, "2.2");
INSERT INTO THE HAND (ID, NAME) VALUES)
12, ' 2.2.1');
INSERT INTO THE HAND (ID, NAME) VALUES)
13, ' 2.2.2');
COMMIT;
CREATE TABLE RELA
(
NUMBER OF REL_ID
IDENTIFICATION NUMBER,
NUMBER OF PARENT_REL_ID
);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
1, 1, NULL);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
2, 2, 1);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
3, 4, 2);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
4, 5, 3);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
5, 7, 4);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
6, 8, 4);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
7, 9, 2);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
8, 10, 7);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
12, 7, 11);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
14, 9, 9);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
15, 10, 14);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
9, 3, 1);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
10, 4, 9);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
11, 5, 10);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
16, 11, 14);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
13, 8, 10);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
17, 12, 16);
INSERT INTO RELA (REL_ID, ID, PARENT_REL_ID) VALUES)
18, 13, 16);
COMMIT;
Example query
Select rel_id, level, lpad (' ', 5 * level) | name,
XmlElement ("rel_id", XMLAttributes (name as "name", rel_id as "rel_id")) as val
principal, rela
where main.id = rela.id
Start with parent_rel_id is null
Connect prior rel_id = parent_rel_id;
Required xml output
Required xml output
< 1 name = "OS" >
< name 2 = "Windows" >
< 3 name = "1.x" 3 > ""
< name 4 = "1.1.x" >
< name 5 = "1.1.1.1" > < / 5 >
< name 6 = "1.2" > < / 6 >
< / 4 >
< / 3 >
< name = "" 2.x 7 ">"
< name 8 = "2.1" > < / 8 >
< / 7 >
< / 2 >
< name 9 'BACK' = >
< name = "2.x 14" > "
< name 15 = "2.1" > < / 15 >
< name 16 = "2.2" >
< name 17 = '2.2.1' > < / 17 >
< name 18 = '2.2.2' > < / 18 >
< / 16 >
< / 14 >
< 10 name = "1.x" > "
< name 11 = "1.1.x" >
< name 12 = "1.1.1.1" > < / 12 >
< / 11 >
< name 13 = "1.2" >
< / 13 >
< / 10 >
< / 9 >
< 1 >
Published by: delights on September 18, 2009 16:47
Published by: delights Sep 19, 2009 09:53No string function helps eliminate r because the xml output is great (in a real scenario) which gives "buffer too small" error.
Try sth like
SQL>select replace(x.column_value.getclobval(), 'XXX') xml 2 from xmltable ('.' passing dbms_xmlgen.getxmltype (dbms_xmlgen. 3 newcontextfromhierarchy ( 4 'select level, xmlelement (evalname ''XXX'' || rel_id, xmlattributes(name "name")) name 5 from main, rela 6 where main.id = rela.id 7 start with parent_rel_id is null 8 connect by prior rel_id = parent_rel_id' 9 ))) x 10 / XML -------------------------------------------------------------------------------- <1 name="OS"> <2 name="Windows"> <3 name="1.x"> <4 name="1.1.x"> <5 name="1.1.1.1"/> <6 name="1.2"/> 4> 3> <7 name="2.x"> <8 name="2.1"/> 7> 2> <9 name="DOS"> <10 name="1.x"> <11 name="1.1.x"> <12 name="1.1.1.1"/> 11> <13 name="1.2"/> 10> <14 name="2.x"> <15 name="2.1"/> <16 name="2.2"> <17 name="2.2.1"/> <18 name="2.2.2"/> 16> 14> 9> 1> SQL>
Newcontextfromhierarchy is not a documented feature do not know if it will issue in releated support this in production code.
Oracle's recommeds to use newcontextfromhierarchy in Metalink Note 882887.1 ;)
-
Access the results of the dynamic query database...
CF colleagues:
I need to execute a loop of 4 times, to access the four distinct values a data offline in a test results table (tbl_results), where all four are in line with the student (WHERE studentid = etc.).
It looks like this...
< cfset variables. TimeTotals = 0 >
< cfloop from '1' to step "4" = = = '1' index = "timrec" >
< cfquery datasource = "MyDSN" name = "rs_time" >
SELECT Btime #timrec #.
OF tbl_results
WHERE studentid = 'jack '.
< / cfquery >
< cfset variables. TimeTotals = variable. TimeTotals + (? rs_time.) BTime #timrec # value?) >
< / cfloop >
QUESTION: How should I address this #timrec # value Btime? Not that way, I know, but how?
Looking forward to your wisdom, with gratitude,
Hans
There are two ways to attack this, but you're close enough. One way is to simply include a column alias in the query, and then use it to make reference to results:
SELECT Btime #timrec # LIKE feeling
OF tbl_results
WHERE studentid = 'jack '.
-
Why the result of the SQL query is not displayed in the HTML text box?
Hello
Under query result appears in home > workshop SQL > SQL commands.
Select t.nom
of pm_task t
where: P5_Project_id = t.project_id
and: P5_task_id = t.id
But when the same code is run through EditRegion of HTML text box > region definition > sources > Source region, the result is not displayed.
Why is this so, and what is the solution?
Thank you
GuyYou need a report from the region for this ;) A region of HTML is to display a static text or page items.
Denes Kubicek
------------------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------------------ -
Is it possible to fill a table with the result of the active query?
I try to get the content of the cursor c in the ap variable and the code I use is as follows:
BEGIN
DECLARE
TYPE cur_typ IS REF CURSOR;
c cur_typ;
query_str VARCHAR2 (1000);
work VARCHAR2 (1000);
AP varchar2 (30000);
to the varchar2 (30000);
query varchar2 (30000);
BEGIN
query_str: = ' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
query: = 'CURSOR c IS' |' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
IMMEDIATE EXECUTION of the query;
C OPEN FOR query_str;
for ap loop query_str
LOOP
Fetch c ap;
EXIT WHEN c % NOTFOUND;
DBMS_OUTPUT. Put_line(àles);
END LOOP;
C CLOSE;
END;
END;I'll show you a basic approach to the dynamic approach refcursor. But you have to do a lot of work in order to customize it to your needs.
Here is a demonstration of basic->
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for 32-bit Windows: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production Elapsed: 00:00:00.22 satyaki> satyaki> satyaki>DECLARE 2 str VARCHAR2 (30000); 3 4 cursor c1 5 is 6 select column_name 7 from all_tab_columns 8 where table_name = upper('&tab_nm') 9 and column_name = 'ENAME'; 10 11 r1 c1%rowtype; 12 BEGIN 13 str := ' declare '|| 14 ' TYPE cur_typ IS ref cursor; '|| 15 ' c cur_typ; '|| 16 ' query_str VARCHAR2 (1000); '|| 17 ' gen_rec '||upper('&tab_nam')||'%rowtype; '|| 18 ' begin '|| 19 ' query_str := '||chr(39)||'select * from emp where rownum < 10'||chr(39)||'; '|| 20 ' OPEN c FOR query_str; '|| 21 ' LOOP '|| 22 ' FETCH c INTO gen_rec; '|| 23 ' EXIT WHEN c%NOTFOUND; '; 24 for r1 in c1 25 loop 26 str := str||' DBMS_OUTPUT.put_line (gen_rec.'||r1.column_name||'); '; 27 end loop; 28 str := str||' END LOOP; '|| 29 ' CLOSE c; '|| 30 ' end; '; 31 32 execute immediate(str); 33 --dbms_output.put_line(str); 34 END; 35 / Enter value for tab_nm: emp old 8: where table_name = upper('&tab_nm') new 8: where table_name = upper('emp') Enter value for tab_nam: emp old 17: ' gen_rec '||upper('&tab_nam')||'%rowtype; '|| new 17: ' gen_rec '||upper('emp')||'%rowtype; '|| SATYAKI SOURAV WARD JONES MARTIN BLAKE CLARK SCOTT KING PL/SQL procedure successfully completed. Elapsed: 00:00:00.16
Hope this will give you a basic idea.
Kind regards.
LOULOU.
-
Format the results of the SQL query, currently, show as below.
Select license_type, correspondents of license_info where license_type in ('TEM', 'TDM') order by license_type;
TDM 1445140800000000000
TDM 1420952400000000000
TDM 1444363200000000000
TDM 1445054400000000000
TDM 1428724800000000000
TEM 1421125200000000000
TEM 1423890000000000000
TEM 1449637200000000000
TEM 1444968000000000000
TEM 1428724800000000000I need formatting like below
Expected result:
TDM 1445140800000000000 TEM 1421125200000000000
TDM 1420952400000000000 TEM 1423890000000000000
TDM 1444363200000000000 TEM 1449637200000000000
TDM 1445054400000000000 TEM 1444968000000000000
TDM 1428724800000000000 TEM 1428724800000000000I have sample data only, Blue said the change in your main table request
Try:
Select max (f1),
Max (F2),
Max (F3),
Max (F4)
de)
Select decode (license_type, 'TDM' license_type) f1,
Decode (license_type, 'TDM', expiration_date) f2,
Decode (license_type, 'TEM' license_type) f3,
Decode (license_type, 'TEM', expiration_date) f4,
ROW_NUMBER() over (partition by order correspondents license_type) r
Of
)
R group
----
Ramin Hashimzade
-
Combine two results of the query with rank
Dear all,
I'm an analyst working DB for the first time:
I have two requests:
1)
Select * (select 'CAFNo', 'ActionDate', 'ActionDetail', rank() on rnk (partition by order of 'CAFNo' through 'ActionDate'),
of 'ABC '.
where 'ActionDetail '.
as 'FIU successfully presented and routed to the fulfillment team %')
where rnk = 1
Results in
CAFNo', 'ActionDate1', 'ActionDetail '.
2)
Select * (select rank() on rnk (partition by order of "CAFNo" by "ActionDate"), 'CAFNo', 'ActionDate', 'ActionDetail'
of 'ABC '.
where 'ActionDetail '.
like '% customer ID %')
where rnk = 1
Results in
CAFNo', 'ActionDate2', 'ActionDetail '.
---------------------------------------------------------------------
I would like to combine the results of two as:
No College, Actiondate1, actiondate2, ActionDetail
I tried the full outer join and other options but without success. Help, please
Please share concept to join the two results not the actual query.with t as ( select "CAFNo", "ActionDate", "ActionDetail", case when "ActionDetail" like '%Customer ID%' then 2 else 1 end weight, rank() over( partition by "CAFNo", case when "ActionDetail" like '%Customer ID%' then 2 else 1 end order by "ActionDate" ) rnk from "ABC" where "ActionDetail" like '%Customer ID%' or "ActionDetail" like 'CRF successfully submitted and routed to Fulfillment Team%' ) select "CAFNo", max( case weight when 1 then "ActionDate" end ) "ActionDate1", max( case weight when 2 then "ActionDate" end ) "ActionDate2", max( case weight when 1 then "ActionDetail" end ) "ActionDetail1", max( case weight when 2 then "ActionDetail" end ) "ActionDetail2" from t where rnk = 1 group by "CAFNo" /
SY.
-
Results of the query variant with unused table in the from clause
Hi all
I (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.
This is the provided query
SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'
Results of the above query : 344028065018.359
SELECT
Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
sales_split PCSS
WHERE crev.order_num = '7631090072'
Results of the above query : 26463697309.1046
Someone here suggest me pls!924804 wrote:
Hi allI (processing_table2) table specified in the FROM clause in the SQL query , but I have not used any of its value in the SQL statement , but it still affects the results of the query. Please help me out here I'm naïve.
This is the provided query
SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
cssp sales_split,
processing_table2
WHERE crev.order_num = '7631090072'Results of the above query : 344028065018.359
SELECT
Sum((CREV.sadc_extd*CSSP.redit_pcnt)/100)
OF crev revenue_lines,.
sales_split PCSSWHERE crev.order_num = '7631090072'
Results of the above query : 26463697309.1046
Someone here suggest me pls!
CARTESIAN PRODUCT of the changes result set
-
Anyway, to remove the column names in the result of the query of SQLPLUS
Hello
I am using sqlplus to run a script that returns results with the column names.
Anyway is to omit the names of columns in the result of the sqlplus query?
I would like to have only results with their column names in the output.
Thanks in advance!Hello
Maybe your LINES (IZE) is not defined?
SCOTT>set lines 130 SCOTT>select status, machine, module 2 from v$session 3 where upper(username) = 'SCOTT'; STATUS MACHINE MODULE -------- ---------------------------------------------------------------- ------------------------------------------------ INACTIVE PFAE3\VPC4894-03 TOAD 9.7.2.5 ACTIVE PFAE3\VPC4894-03 SQL*Plus 2 rows selected. SCOTT>
As an alternative to the linesize parameter, you can format the columns:
SCOTT>set lines 80 SCOTT>col status for a8 SCOTT>col machine for a30 SCOTT>col module for a30 SCOTT>select status, machine, module 2 from v$session 3 where upper(username) = 'SCOTT'; STATUS MACHINE MODULE -------- ------------------------------ ------------------------------ INACTIVE PFAE3\VPC4894-03 TOAD 9.7.2.5 ACTIVE PFAE3\VPC4894-03 SQL*Plus 2 rows selected. SCOTT>
Concerning
Peter -
PLSQL function to return the result of the query
Dear all,
Oracle Database SE1 11.2.0.1
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Is this possible?
Madhu.149 wrote:
I need to create a plsql function which should accept SQL as a parameter, execute it and return the result set.
Be careful - results games indicate a set of data stored in memory. This is not what are sliders. This isn't how Oracle should be used.
Imagine that you implement such a result set function - which, on average, requires 1 MB of memory (private server) to store the results of the SQL query. A 100 users mean a 100 MB of memory required server. This is not suitable. Not at all. Never.
The correct back 'thing' is a handle to SQL cursor (called a ref cursor in this case). A SQL cursor is a "program" - that the appellant runs via the fetch command and generates one or more lines accordingly. Appellant repeatedly runs this slider through calls to fetch until this slider found and returns all rows affected (using consistent readings).
If you want an abstraction interface that the client can call via PL/SQL code in the database, so this crafting optimal SQL interface, creates the SQL cursor and returns the handle of the cursor (via the ref cursor data type) to the client.
-
ALL_PART_KEY_COLUMNS shows a wrong result in the presence of two indices the
Applies to Oracle 11.2.0.3 64-bit running on Oracle Linux.
See the example below, the partitioned table T1 is created using two indices, which is used as PK.
CREATE TABLE T1
(
DATE DATETIME,
ORDERID NUMBER (12)
)
PARTITION BY RANGE (DATETIME)
INTERVAL (NUMTODSINTERVAL (1, 'DAY'))
(
PARTITION P1 VALUES LESS THAN (TO_DATE ('2015-01-01', 'YYYY-MM-DD'))
);
CREATE INDEXES ON T1 T1_IX1
(ORDERID)
LOCAL (PARTITION P1);
CREATE A UNIQUE T1_PK ON T1 INDEX
(DATETIME, ORDERID)
LOCAL (PARTITION P1);
ALTER TABLE T1 ADD)
CONSTRAINT T1_PK
KEY ELEMENTARY SCHOOL (DATETIME, ORDERID)
WITH THE HELP OF INDEX LOCAL ENABLE);
Now if ask us ALL_PART_KEY_COLUMNS to discover objects that use DATETIME as a partitioning column, both indexes appears:
Select NAME, OBJECT_TYPE, COLUMN_NAME from ALL_PART_KEY_COLUMNS where COLUMN_NAME = 'DATETIME' AND NAME LIKE '% T1;
NAME OBJECT_TYPE COLUMN_NAME T1 TABLE DATETIME T1_IX1 INDEX DATETIME T1_PK INDEX DATETIME I think that T1_IX1 should not appear in a result of the above query. Is this a bug or feature?
Applies to Oracle 11.2.0.3 64-bit running on Oracle Linux.
See the example below, the partitioned table T1 is created using two indices, which is used as PK.
CREATE INDEXES ON T1 T1_IX1
(ORDERID)
LOCAL (PARTITION P1);
Now if ask us ALL_PART_KEY_COLUMNS to discover objects that use DATETIME as a partitioning column, both indexes appears:
Select NAME, OBJECT_TYPE, COLUMN_NAME from ALL_PART_KEY_COLUMNS where COLUMN_NAME = 'DATETIME' AND NAME LIKE '% T1;
NAME OBJECT_TYPE COLUMN_NAME T1 TABLE DATETIME T1_IX1 INDEX DATETIME T1_PK INDEX DATETIME I think that T1_IX1 should not appear in a result of the above query. Is this a bug or feature?
It is a REQUIREMENT!
You have specified a partitioned index ROOM (see code above). then the index will be partitioned on the same or the columns as the table.
What is this column? DATETIME, of course.
See the CREATE INDEX statement to local_partitioned_index API documentation
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_5011.htm#i2135151
local_partitioned_index
The
local_partitioned_index
clauses allow you to specify that the index is partitioned on the same columns, with the same number of partitions and delimits the same partition astable
. Oracle database automatically maintains local index partitioning the underlying table is repartitionnée.When you create a partitioned index, you must indicate to Oracle what columns you want to partition the index on.
You have chosen to partition of the index on the same columns that the table is partitioned on.
Which columns do you think index will be partitioned on? Post your answer.
-
Table error ' can not analyze the SQL query!
Hi all
I created a view on my database called VIEW_MEMBER_PARTIC_PROJECTS
If I run a query showing the results of the view:
SELECT * FROM VIEW_MEMBER_PARTIC_PROJECTS
I get the following data
Projects Participants 1 31 S 2 41 3 19 4 3 5 3 6 1 7 2 Now, I wanted to represent this diagram in the APEX so I created a graphic region and entered the Source query generator and the manufacturer produces the following code
Select null, label projects, value1 Participant link
of "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".
With this code, I get an error:
Cannot parse the SQL query!
Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".
Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).
The code looks OK, but I do not see to save options as the error code is mentioned.
No one knows how to fix this?
Thank you
JaReg wrote:
I finally found the problem.
I looked at the code for the view and changed the start of:
CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS "("Participant","Projects")
AS
TO
CREATE OR REPLACE VIEW "SCHEMANAME." "" VIEW_REPEAT_PARATIC ".
AS
And that seemed to fix it. I'm not entirely sure why though.
The view was created using the quoted identifiers for column names. This makes them sensitive and means that they must always be referenced using double quotes. In the absence of quotation marks, Oracle is not case insensitive and automatically converts all uppercase identifiers. The application of graph:
Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".
has therefore been interpreted by Oracle:
SELECT THE LINK NULL, LABEL, VALUE1 "SCHEMANAME PARTICIPANT PROJECTS." "" VIEW_MEMBER_PARTIC_PROJECTS ".
and PROJECTS and PARTICIPANT columns were not recognized because the columns defined for the view have been 'Participant' and 'projects '. The graphic request should have been:
Select the link null, the label of "Projects", "Participant" value1 "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".
As you have now discovered, quoted identifiers are a source of nothing but obscure bugs and should never be used for database objects. He also pointed out the reason why you should always use a standardized, form tiny, coding style as it is faster to type, easy to read and less prone to errors.
Maybe you are looking for
-
Applications Mac keep crashing
All Apple applications (Mail, Safari, calendar, etc.) do not respond. Last week he has been on and outside, will more Activity Monitor. Periods where they all do not respond have grown only more annoying and longer. Any help or advice on how to solve
-
scanning multiple pages to the single PDF using HP ENVY 4500
The guide says scan of the computer (as opposed to scanning from printer). I do that and still can't scan multiple pages into a single PDF file. Is it still possible?
-
Hello Windows vista basic color is no longer availableAfter the last update, 10/04/2014, on a desktop running Ultimate SP2, I lost the color I liked and was used to.RT click on desktop > Personalize > Windows color and appearance > color scheme:Windo
-
Why can I access is more my hotmail account using firefox?
Since this thing 'Windows Live' has been implemented, (ie: pushed to the bottom of the throat), got hurt continually access to my hotmail account using Firefox as your browser, until, from the past week or so can not access at ALL, unless I use IE. E
-
Cannot switch between windows without minimizing everything.
Recently (as of 02/10/2010 on Windows 7 x 64) when I have several windows open, whenever I click on another application open on the taskbar instead of the window popping up, the part of the taskbar just flashes orange. (This is equivalent to 'Flash'