Need to print the results of a query in a CASE statement
I want to print the results of a query in a CASE statement:
SELECT RUN_STATUS
Of
(select check BOX WHEN COUNT (ROW_WID) = 0 THEN 'NO JOBS RAN AFTER' |) (select sysdate - XXAFL_MINUTES MINUTE)
END RUN_STATUS
of W_ETL_RUN_SDTL
where START_TS >
(sélectionnez sysdate-MINUTES de XXAFL_MINUTES)) where RUN_STATUS is not null; e
The query above subtracted 5 minutes from SYSDATE and he shoots XXAFL_MINUTES. I am doing this because we could change the number of minutes in the future. I want to print the number of minutes in the case statement.
If I execute this statement, it throws an error stating:
ORA-00937: not a single group group function
00937 00000 - 'not a single-group function.
* Cause:
* Action:
Error on line: 1 column: 96
How can I include "select sysdate - MINUTES of XXAFL_MINUTES" in the CASE that it calculates the number of minutes and it prints with the results.
Thanks in advance!
Hey guys,.
I found the solution:
SELECT
RUN_STATUS | TO_CHAR ((sélectionnez sysdate-MINUTES de XXAFL_MINUTES), 'HH24:MI:SS')
Of
(select check BOX WHEN COUNT (ROW_WID) = 0
THEN "NO JOB RAN.
END RUN_STATUS
of W_ETL_RUN_SDTL
where
START_TS > (select sysdate - XXAFL_MINUTES MINUTE))
where
RUN_STATUS is not null;
The output:
NO JOBS RAN AFTER 09:07:54
Thanks to you all!
Tags: Database
Similar Questions
-
I need to return the result of a query on a stored procedure
I need to return the result of a query to a stored procedure, I mean when I run a stored procedure it returns a result set in a select statement.
Best regards...Hello.
Do you really want a stored procedure for this?
Why not just a script that contains the query?Assuming that you don't really want a stored procedure, you'll have to decide what to do with the results.
An option is a slider.For example, you can write a procedure of this type to hold the query:
CREATE OR REPLACE PROCEDURE USP_TEST ( out_cursor OUT SYS_REFCURSOR ) IS BEGIN OPEN out_cursor FOR SELECT * FROM scott.emp; END USP_TEST; / SHOW ERRORS
You can move the cursor to another procedure for handling.
You could test this in SQL * more by creating a variable blond:
VARIABLE usp_test_cursor REFCURSOR; EXEC usp_test (:usp_test_cursor); PRINT :usp_test_cursor
-
Print the results of a quiz with name included
I've seen this asked several times, but I couldn't find the answer. I'm running 7 Captivate on Windows XP. I just need to print the results of the quiz which will include the student's name. I tried the text box on the certificate widget but if I use the "print" key nothing of what has been added to the certificate (as the name) will be printed. I can do a screen capture and the data is printed, but I was wondering if there is a better way to enter the name of a student and then embed it in the results page. Looks like it would be a "no brainer" feature to have, but I'm not.
I don't want to capture results electronically. I just need to print the results that will will also show their name.
I am a new user of Captivate. Any help or pointing me in the direction to learn how to do this would be much appreciated.
You can get the learner to enter their name in a box of text at the beginning of the module, store this text in a user variable, and then display this text at the end of the lesson on the slide, you print.
-
Export the results of a query to a CSV file
Hello
My requirement is that I need to export the results of a query to a CSV file. Can someone please suggest a way to also include the names of columns in the CSV file?
Thanks in advance.
AnnieFollowing code comes from asktom. I changed to include the column header. This will get your CSV file desired for a given query.
create or replace function dump_csv( p_query in varchar2, p_separator in varchar2 default ',', p_dir in varchar2 , p_filename in varchar2 ) return number AUTHID CURRENT_USER is l_output utl_file.file_type; l_theCursor integer default dbms_sql.open_cursor; l_columnValue varchar2(2000); l_status integer; l_colCnt number default 0; l_separator varchar2(10) default ''; l_cnt number default 0; l_colDesc dbms_sql.DESC_TAB; begin l_output := utl_file.fopen( p_dir, p_filename, 'w' ); dbms_sql.parse( l_theCursor, p_query, dbms_sql.native ); for i in 1 .. 255 loop begin dbms_sql.define_column( l_theCursor, i, l_columnValue, 2000 ); l_colCnt := i; exception when others then if ( sqlcode = -1007 ) then exit; else raise; end if; end; end loop; dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 ); l_status := dbms_sql.execute(l_theCursor); dbms_sql.describe_columns(l_theCursor,l_colCnt, l_colDesc); l_separator := ''; for lColCnt in 1..l_colCnt loop utl_file.put( l_output, l_separator || '"' || Upper(l_colDesc(lColCnt).col_name) || '"'); l_separator := p_separator; end loop; utl_file.new_line( l_output ); loop exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 ); l_separator := ''; for i in 1 .. l_colCnt loop dbms_sql.column_value( l_theCursor, i, l_columnValue ); utl_file.put( l_output, l_separator || '"' || l_columnValue || '"'); l_separator := p_separator; end loop; utl_file.new_line( l_output ); l_cnt := l_cnt+1; end loop; dbms_sql.close_cursor(l_theCursor); utl_file.fclose( l_output ); return l_cnt; end dump_csv;
The original link is below.
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:95212348059
Thank you
Knani. -
!!! Need to print the javax.xml.soap.SOAPElement - please help
Hello
I have a webservice correctly executed in Weblogic 9.2. I wrote a stand-alone client that receives the javax.xml.soap.SOAPElement as return type of webservice. As
SOAPElement soapElement = port.getClientPartyIdFromBrAcct("CV4009946");
I can properly see the request and response using the TCP/IP monitor.
But I need to print the entire SOAPElement as a string. Because I set the SOAPElement as XML in an HTML page to display in the browser... in a way properly shaped.
Please let me know how I can do it.Hello
I did something similar. You can add the following method:public String convertDocumentToString (input element) {}
DOMSource domSource = new DOMSource (input);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult (writer);
TransformerFactory tf = TransformerFactory.newInstance ();
Transformer transformer;
try {}
transformer = tf.newTransformer ();
transform. Transform (domSource, result);
} catch (Exception e) {}
System.out.println (e);
}
Return writer.toString ();
}It will return your xml into a string and then call with your SOAPElement object as input.
André
-
How can I print the results of my research?
I have more than 3000 DWF files in my search results. They are located in different folders on our server. How can I print the results of my research?
This means that nomo did not read your question carefully.
I think Directory printer Karen will do what you want. 3000 files is a lot of paper. You can download Cute PDF Writer and save the output to a PDF instead - at least until you get the options sorted...
-
Need to get the result of the required format
Hi all
I'll have the data in a table below:
ID NUM1 num2 1 555 555 2 123 345 3 456 567 4 666 666 ID NUM1 num2 1 555 555 2 123 345 3 456 567 4 666 666 and they need to get the result as below:. Help, please...
ID NUM 1 555 2 123 2 345 3 456 3 567 4 666 Thanks in advance...
Hello
So, instead of having 2 columns on 1 row, you want to have 1 column on 2 rows. It's just that UNPIVOT:
SELECT DISTINCT
ID, num
D
UNPIVOT (num
FOR the label IN (num1, num2)
)
ORDER BY id, num
;
It is more effective than the UNION, because it requires only 1 pass through the table.
-
Insert the result of a query select in another table
Hello
I have a strange problem when I try to insert all the results of a query select in another table, using the declaration of the order.
With the declaration of COMMAND it works fine
Work:
------------------------------
INSERT INTO ADART01 (SELECT (codart)
"STOCK". "" CODART_STO ".
Of
"DB". ' ' 'ACTIONS');
------------------------------
But if I try to sort the result using the declaration of the ORDER, I have the following error:
Error: ORA-00907 missing right parenthesis
------------------------------
INSERT INTO ADART01 (SELECT (codart)
"STOCK". "" CODART_STO ".
Of
"DB". "" "ACTIONS"
ORDER BY
"STOCK". ("' CODART_STO ASC ');
------------------------------
Any idea?
Thank you for your help,
Angel.delete "()" to select
create table test1 (a number, b varchar2(100)); insert into test1 (a, b) select level, 'level ' || level from dual connect by level < 101; insert into test1 (a, b) select level, 'level ' || level from dual connect by level < 101 order by to_char(sysdate - level, 'D'); select * from test1; drop table test1;
-
Need to get the result of joing the views dba
Hello
need to get the result of the fileds below in a database
TABLE_NAME NOM_PARTITION NOM_TABLESPACE PARTITION_TYPE (RANGE?) PARTITION_RANGE_CONDITION SPACE_OCCUPIED_AS_OF_DATE (IN GB)
can I know what are the points of view that I can use and application
apprecaited for assistance
Thank you
Published by: user12266475 on November 2, 2011 11:33LONG data type is NOT friendly SQL.
Consider the following:SQL> @long SQL> drop table test; Table dropped. SQL> create table test (id LONG); Table created. SQL> insert into test values(q'[RANGE TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')]'); 1 row created. SQL> set serveroutput on SQL> DECLARE 2 long_var LONG; 3 var_var VARCHAR2(2000); 4 BEGIN 5 dbms_output.enable(10000); 6 SELECT id INTO long_var FROM test ; 7 var_var := substr(long_var,19,19); 8 dbms_output.put_line(var_var); 9 END; 10 / 2009-01-01 00:00:00 PL/SQL procedure successfully completed.
-
defining the results of a query to a variable
Hi all
I'm having a problem affecting the results of a query to a variable. What I'm trying to do, is to do an AJAX call to a .cfc file and pass back the results of the function. The main problem is, I'm again moving a block of HTML (resulting from a cfquery in a cfoutput) stored in a variable. My code is something like...
< name cffunction = "getText" access = "remote" returntype = 'Cancel' >
< datasource = "" #request.dsn # cfquery "name ="queryTable">"
SELECT kort, infoBOf infoTable
< / cfquery >
< cfset result = ' <!-this is the part I'm stuck, I want the table go here. -> ">"< table >
< cfoutput query = "tablequery" >
< b >
< td > #infoA # < table > < td > #infoB # < table >
< /tr >
< / cfoutput >
< /table >
< cfwddx action = "cfml2js" input = "" # result # ' toplevelvariable 'o' = > "< / cffunction >
It is a simplified version of what I want to do, but you get the idea...
Is it still the right way to go about this? Thank you
That's what I get for trying the E-mail response feature! Are you not happy, that I double checked my post.
You could do a lot of string concatenation here to do stuff like
"& Kort &" "& infoB &" "> time and time again." But in reality the tagsis so much easier to use.
#infoA #. #infoB #.
-
I need to print the last value
Hello
in the Sub statement I need to print the last value
means last 5555, I can print other values, but last value 5555 is I can't print
Please help me
Thanks in advanceSELECT REGEXP_SUBSTR('5454 4587454 547451 188745 5555','[^'||' '||']+'||' ',1,5) p1 from dual;
DavidKarthick_Arp wrote:
Like thiswith t as ( select '5454 4587454 547451 188745 5555' str from dual ) select regexp_substr(str, ' [[:digit:]]*$') from t
Why leave space in front of her?
SQL> ed Wrote file afiedt.buf 1 with t as (select '5454 4587454 547451 188745 5555' str from dual) 2 -- 3 select regexp_substr(str, '[0-9]+$') 4* from t SQL> / REGE ---- 5555 SQL>
-
Compare the result of a query with a number and return a message
Hello
I have the following query in oracle 9i:
SELECT COUNT (*)
OF hourly_files
WHERE date_received = TO_DATE ((SELECT TO_CHAR (SYSDATE - INTERVAL '1' DAY, 'DDMMYYYY')
(THE DOUBLE), 'DDMMYYYY');
This will produce a number of lines required
I need to compare the number of output with another number hardcoded (threshold) and print an appropriate example message
If the result of the query above is 18000 and the number of threshold is fixed at 20000, then output a meesage:
Number of files received less than 2000
Any help will be very appreciated!
Thank you.SQL> ed Wrote file afiedt.buf 1 SELECT CASE WHEN COUNT(*) >5 THEN 'Number is > than 5' 2 WHEN COUNT(*) <1 THEN 'Its less than 1' 3 ELSE 'Its in between' 4 END 5 FROM emp 6* WHERE deptno=20 SQL> / CASEWHENCOUNT(*)>5 ------------------ Its in between SQL> SELECT COUNT(*) FROM emp 2 WHERE deptno=10; COUNT(*) ---------- 3
-
Need to obtain the result in an orderly manner
Hello!!
I had used this querry
Which gives the following resultselect func_find_busfun_desc('MEL', apbuf_fun_id,1) AS form_desc FROM APPL_BUS_FUN WHERE APBUF_PAR_FUN_ID ='SUP_DET_TRANS' AND APBUF_FUN_ID IN ('SUP1030','SUP1040','SUP1080','SUP1010','SUP1120','SUP1130','SUP1180','SUP1160')
I need to organize the output asRate Contract Details NCR Supplier Document Details Stocks Purchase Order Purchase Reciept Supplier Aging Details Supplier Balance
Could someone help me pls!Supplier Balance Supplier Document Details Supplier Aging Details Stocks Purchase Order Purchase Reciept NCR Rate Contract details
Wilhelm wundt wrote:
There is no specific connection I coded directly hard value, but I'm getting output likeSupplier Balance Supplier Aging Details Stocks Purchase Order Purchase Reciept NCR Rate Contract details Supplier Document Details //It must be second one But it resides last
I had used this query
select form_desc from( select func_find_busfun_desc('MEL', apbuf_fun_id,1) AS form_desc FROM APPL_BUS_FUN WHERE APBUF_PAR_FUN_ID ='SUP_DET_TRANS' AND APBUF_FUN_ID IN ('SUP1030','SUP1040','SUP1080','SUP1010','SUP1120','SUP1130','SUP1180','SUP1160') ) order by decode(form_desc, 'Supplier Balance',1, 'Supplier Document Details',2, 'Supplier Aging Details',3, 'Stocks',4, 'Purchase Order',5, 'Purchase Reciept',6, 'NCR',7, 'Rate Contract details',8,100)
Hope you got the code.
Decoding is a number of "form_desc" "based on your requirement. If the description given in the decoding is NOT EXACTLY matching your description the order is not correct. It seems that the description 'The Document provider Details' in your output and the decoding is slightly different (Extra space or typo...) -
assign the value to a selection of the result of a query control
I want to assign a value to my controls with the result of the query.
It works for CFINPUT TEXT, but it does not work to SELECT
I want to know are there any way tp affect my drop-down list value based on the result of questy.
I have CFSTOREPROC as follows:
< cfstoredproc procedure = "PSP" >
< cfprocparam value = '#form. "IDNumber #" CFSQLTYPE = "cf_sql_integer" >
< name cfprocresult = resultset "spResult" = "1" >
< / cfstoredproc >
< type CFINPUT = 'text' id = "txtIDNumber" value = "" #spResult.IDNumber # "/ >"
I am able to name a TEXT of ENTRY CF as above the code value,
< select id = "lstNumber" value = "#spResult.lstNumber #" > < / select >
but it does not affect the value of my result of the query to SELECT entry.
Is it possible to assign a value to the query result SELECTION control?
I tried to use JavaScript that works if I pass a number, but it does not work if I pass a query result,
Your help is very appreciated,
Kind regards
Iccsi,
@Iccsi,
My bad! Yes, you will either need to the CFOUTPUT tag (that you commented out in your code) but without specifying a query or change the CFLOOP query CFOUTPUT = "Notes". If one of these should work:
OR
-Carl V.
-
Refcursor takes a long time to print the results
Hi gurus,
I have a table with name kemp with columns
kemp_ID NOT NULL NUMBER (10)
when I do a query on the table
ACRONYM CLOB
TERM CLOB
DEFINITION of CLOB
Select * Kemp; results will soon appear less than * 1.5 seconds *
But when I write a procedure to return the results using refcursor
Create procedure pr_retall (cv_1 in the sys_refcursor)
as
Start
Open SELECT cv_1 * Kemp;
end;set serveroutput size unlimited;
It takes around * seconds * 7 to appears.
var x 1 refcursor;
exec pr_retall(:x1);
print x 1;
Please tell me know ways to tune. I want to reduce the time that it is to consume.
Thank you and best regards,
Vikas KrishnaVikas Krishna wrote:
Please find the schedule.
Using elapsed time (like you) to measure and benchmark performance is not going.
Why? Because the test2 is given rarely, if ever how these tests are usually done, executed with the help of the same conditions that test1 was executed in.
Conditions are different between the tests, the elapsed time is different. As conditions differ, you cannot compare test1 with test2. I gave an example of what a mistake it is thread {message identifier: = 4333700}-where physical i/o slows test1 and test2accelerates the logic I/O. And how this can be used to support the conclusion that the CBO does not exist hint warp_drive increased performance of test2.
If you want to compare test1 against test2, you must know exactly in detail how each test works technically... you want to know how to ensure that the common point between two tests remain constant for all tests and how to measure only the elements that differ between tests.
And no, the comparative analysis is not that complex. In fact, it is even more complex than that. It is best left to those who know how to compare... on behalf of those who can find significance in the result of this benchmark.
For the majority of us work and development in the real world, comparative analysis makes a useless answer to a question meaningless for an absurd question. Totally useless...
Maybe you are looking for
-
Regarding more Atheros Bluetooth for Windows 8
I recently bought a laptop G6-2005ax and I "m planning to level of Windows 7 Home Basic to Windows 8. So I downloaded and ran the Windows 8 Upgrade Wizard. It shows that the ATHEROS BLUETOOTH SUITE (64) is not compatible with Windows 8. Is this to sa
-
change unlimited network meter in Windows XP
There's an answer posted for Windows 8 (and it solved the problem for my laptop). Now, I need to do the same thing for my desktop PC (which is Windows XP). How can I change the Win XP to see a unlimited network?
-
Stuck on the HP logo screen after installing new graphics card.
I installed a new graphics card today and I'm stuck in the loading screen. My old card boots gts 450 my computer very well, but my new graphics card cannot. I replaced my old diet with a 600w power supply, and it worked fine with my old card. It's my
-
XP is connected to the wireless network but can't get online...
I have a wireless network that works very well with my computer laptop and desktop so its punt in Mac OS, but when I boot XP, it cannot get online. He sees the network and says I'm connected but IE and Firefox keep the display of error messages telli
-
Clip + only has the memory of neighborhood
Clip + 4 GB froze last week during loading. A reset would not work so I had to let the battery go out. He said now with no music or whatever it is to this subject that I have 975 MB of space left. Can anyone help?