How to generate csv ouput by using a procedure
Hi All,
How do I generate a csv (comma separate value) output by using procedure. I have 2 SQL statements in my procedure, I need to generate a csv file with the result set of 2 SQL's. For Example;
I have the following 2 SQL's in my procedure
Cursor emp_det Is Select * From emp where sal < 4000;
Cursor sal_det Is Select e.* from emp e,dept d where d.dname = 'SALES'
My requirement is to generate a csv ouput with the result set of cursors emp_det & sal_det. How can I generate a csv ouput by using PL/SQL. I could generate the same by using tools like TOAD & PL/SQL Developer. But I need to generate csv output by using PL/SQL only...Your help would be more appreciated.
use tom kyte's dump_csv.
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;Thanks,
Karthick.
Similar Messages
-
How to generate CSV ouput from JD Edwards 8.11 using rtf template
Hi,
I have a report "Critical Date Report" - R15611 in JD Edwards 8.11. This report has to be generated as CSV output from BI Publisher which is embedded to JDE. why we choose the output in BI Publisher is to move some of the data displaying to different place in the page(ex: Move the company address from top left corner to Bottom right corner).
In order to achieve this
1.We create blank rtf template and upload to XML repository using P95600 application
2.Create report definition using P95620 application
3.Here I see the available output types as PDF,RTF,HTML,EXCEL,POWERPOINT and XML,ETEXT(GRAYED OUT)
Which output type we can use for CSV ?
4.Execute the report definition of the critical date report from P95620 to get the XML source
5.This XML source will be loaded into the blank rtf template
6.From this point no idea how to design the rtf template in order to get the CSV output.
7.We did design and output types as excel - but the result data is not in good formatting and alignment.
If anyone has worked on similar type of requirement,let us know how to do or send a sample XML source,rtf template and how the CSV output will be.
Thanks in Advance.
VijayIve replied to your other post.
-
How to generate new perner number using Abap Code in pa0002. what is the fu
how to generate new perner number using Abap Code in pa0002. what is the function Module used.
hi
define internal number ranges for ur implementation then when u run PA 40 do not input any employee number , system will generate the employee number automatically.
Regards
sameer -
How we generate Surrogate Keys without using identify column
Hi All,
How we generate Surrogate Keys without using identify column.
Regards,
ManishThere are various options
1.IDENTITY columns - simplest to implement
2. Using NEWID(), NEWSEQUENTIALID() functions (if you want to use GUID values as surrogate keys)
3. SEQUENCE object (if SQL 2012 and above)
4. Using custom functions to generate keys yourself
This is an good article which compares use of GUIDs against integers as surrogate keys
http://blog.jonathanoliver.com/integers-vs-guids-and-natural-vs-surrogate-keys/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to work on Data Analysis using Stored procedures
How to work on Data Analysis using Stored procedures any suggestions
Carefully? Precisely? Tomorrow? Your question has no context so it means little to an outside reader. Perhaps you should start with some basic research into the data mining features of sql server:
data mining homepage -
How To Generate Early watch report Using SDCCN
Hi Guys,
Can any body please provide me brief knowledge on " how to generate an Early Watch Report using SDCCN"
infact i have searched in the forums but not very much clear.
Thanks,
LAXThis may not be the appropriate forum for this question. You may want to consider posting your question on the SAP NetWeaver Administration forum instead.
Having said that, the following may help:
OSS Note 763561 - Service Data Control Center (SDCCN) - FAQ -
How to generate I&Q data using NI5640R card?
Hi there,
I know how to generate a chirp using the NI5640R card (because there is a "chirp" generation function/block), But i dont know how to generate the I and Q components of the chirp. Could someone please help me with generating the I and Q components of a chirp (i.e, Can you please make a VI that generates the I and Q components of a chirp and give it to me).
Any help regarding this will be grately appreciated.
Thanks,
Sandeep.
Sandeep Palreddy, Graduate Research Assistance
The Microwave Remote Sensing Laboratory (MIRSL)
University of Massachusetts
151 Holdsworth Way
Amherst MA 01003-9284If the chirp signal you are generating is all real valued, there will be no Q component.
-
How to Generate a MDX statement using a BEX query
Hello,
Is there any possiblity in BW to generate a MDX statement using a BEx query?
Thanks,
RaviBW does not generate any MDX statement for Bex query.I have tried ample number of times to acheive this but failed.
Like an Infocube the Query is also an object where in you can write MDX queries on BEx Queries.
As it is I never found BW rendering MDX queries.But with MDX queries you can get something but how far it helps I don't know.
RSCRM_BAPI is obsolete and it is recommended to use RSCRM_REPORT somewhere I have read ,but when I went to that transaction I never found that "MDX" button at all.
It was converted to "OLAP Check" which gave me some warning on the key figures and that's it.
Somehow I feel BW is not comfortable with MDX.
Regs
Gopi -
How to Generate 250 Users Conference using Lync 2013 Stress and Performance Tool
How to Generate 250 Users N-way IM Conference using Lync 2013 Stress and Performance Tool.
Please Let know the configurations to generate the XMLs. We are not able to create more than 70 users N-way IM conference though during configuration, we opted for 300 users conference for Large Conference (in custom setting).
The tool somehow does not create the number of participants as indicated. Is there any way to troubleshoot why it's not generating the expected load.Hi,
Would you please elaborate more about your Lync environment?
Please check if you meet the following configuration requirements:
Set the MaxMeetingSize option to 1000. (The default is 250.)
Set the AllowLargeMeetings option to True.
Set the EnableAppDesktopSharing option to None.
Set the AllowUserToScheduleMeetingsWithAppSharing option to False.
Set the AllowSharedNotes option to False.
Set the AllowAnnotations option to False.
Set the DisablePowerPointAnnotations option to True.
Set the AllowMultiview option to False.
Set the EnableMultiviewJoin option to False.
More details:
http://technet.microsoft.com/en-us/library/jj205074.aspx
Best Regards,
Eason Huang
Eason Huang
TechNet Community Support -
How to generate a PDF output using batch file in 10G
Hello,
I am using .bat file to generate a report PDF output. I have done this many times in 6i but for 10G I am unable to do the same.
Can someone please look at the syntax below and let me know where I am going wrong.
I understand that reports are different for 6i and 10G specially .rep file but I am sure we should be able to generate a PDF file using 10G. Please let me know.
Thanks
IQ
Contents of .bat file follow
ECHO Opening parameter form. Please do not close this window.
C:\
FOR /F "tokens=1 " %%I IN ('time /t') DO (SET _TIME=%%I)
FOR /F "tokens=2 " %%I IN ('date /t') DO (SET _DATE=%%I)
SET EXP_DATE=%_DATE:~6,4%%_DATE:~0,2%%_DATE:~3,2%_%_TIME:~0,2%%_TIME:~3,2%
SET FILENAME=SEND_EMAIL_%EXP_DATE%_%USERNAME%.PDF
CD C:\Users\Documents
RWCONVERTER REPORT=C:\Users\Documents\send_email.rep USERID=scott/tiger@ORCL1 ORIENTATION=LANDSCAPE DESFORMAT=PDF DESTYPE=FILE
DESNAME=C:\Users\\%FILENAME% PRINTJOB =NORwconverter is not used to run reports:
rwconverter (Reports Converter) enables you to convert one or more report definitions or PL/SQL libraries from one storage format to another.
I think you mean rwrun:
rwrun (Reports Runtime) runs a report by starting its own in-process server (not to be confused with the default in-process Reports Server), which runs in the same JVM as the rwrun process.
This bat file has to run on the server. There is no Reports installation on the client anymore.
If you want to run a report from a client, you can make a bat file that calls the report url
See: http://download.oracle.com/docs/cd/E14571_01/bi.1111/b32121/pbr_cla002.htm#i634710 -
How to generate a PDF report using ADF RichTable?
Hi,
I am using JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660. I am displaying my data from db in a JSF Fragment(JSFF) using ADF RichTable component. Actually now I want to generate a PDF report using that data shown in the table on click of a Generate Button. Can anyone please provide me code or sample for that?
Thanks,
Vikashttp://kohlivikram.blogspot.com/2009/04/generate-pdf-report-in-adf.html
Thanks,
Navaneeth -
How to generate interrupts on TC using a 6601 timer
Need to generate interrupts on TC using a 6601 timer board in Linux. Have enabled the proper interrupt enable bits in the timer registers and can poll on the TC acknowledge bit to see it set when TC occurs, but am not able to generate an interrupt on TC. Is there a procedure or bits to be set in the pci interface to allow TC interrupts to be passed on to the processor. Am able to program the timers at the register level and am sure that I can access the timers and program them.
Bill B:
Is there anyplace I can get the docs for the registers not included in the PCI-6601/6602 RLP manual?
Apparently this global-interrupt etc register and several others are not listed in the RLP. Maybe there is a newer version which includes all the info?
Thanks,
Bob
[email protected] -
How to insert into a table using a procedure in a trigger
I have following trigger and based on the some condition, it should inser a row in to a table using the procedure:
CREATE OR REPLACE TRIGGER RSSC.RR_SERV_ADD_ON_REQ_bu before update on RSSC.RR_SERV_ADD_ON_REQ
for each row
DECLARE
lr_appr_trans_hdr APPR_TRANS_HDR%ROWTYPE;
-- Inserting a row into APPR_TRANS_HDR table
lr_appr_trans_hdr.apth_ref_system := 'RSAO';
lr_appr_trans_hdr.apth_xref_col_name := 'RSAO_ADD_ON_REQ_NUM';
lr_appr_trans_hdr.apth_xref_id := :NEW.RSAO_ADD_ON_REQ_NUM;
lr_appr_trans_hdr.apth_trans_srce := 'I';
lr_appr_trans_hdr.apth_balance_amt := :NEW.RSAO_TOT_AMT;
lr_appr_trans_hdr.apth_is_finance_adj := 'N';
SPI_APPR_TRANS_HDR (
lr_appr_trans_hdr.apth_id
,lr_appr_trans_hdr.apth_create_dt
,lr_appr_trans_hdr.apth_create_user_id
,lr_appr_trans_hdr.apth_update_dt
,lr_appr_trans_hdr.apth_update_user_id
,lr_appr_trans_hdr.apth_ref_system
,lr_appr_trans_hdr.apth_xref_col_name
,lr_appr_trans_hdr.apth_xref_id
,lr_appr_trans_hdr.apth_trans_srce
,lr_appr_trans_hdr.apth_udc_name_cd
,lr_appr_trans_hdr.apth_udc_acct_num
,lr_appr_trans_hdr.apth_level1_apprvl_stat
,lr_appr_trans_hdr.apth_level1_apprvl_dt
,lr_appr_trans_hdr.apth_level1_apprvr_id
,lr_appr_trans_hdr.apth_level2_apprvl_stat
,lr_appr_trans_hdr.apth_level2_apprvl_dt
,lr_appr_trans_hdr.apth_level2_apprvr_id
,lr_appr_trans_hdr.apth_received_dt
,lr_appr_trans_hdr.apth_balance_amt
,lr_appr_trans_hdr.apth_cust_name
,lr_appr_trans_hdr.apth_sent_dt
,lr_appr_trans_hdr.apth_wbs_element
,lr_appr_trans_hdr.apth_gl_acct_num
,lr_appr_trans_hdr.apth_is_finance_adj );
When I use the above, it is saying wrong number of argument or type.
When I use the following instead, I am getting :NEW.APTH_ID must be declared.
SPI_APPR_TRANS_HDR('APPR_TRANS_HDR',to_char(:NEW.APTH_ID),'APTH_ID',:OLD.APTH_ID,:NEW.APTH_ID);
How can use the procedure in a trigger.
Following is the table structure:
Column Name Data Type Column Comments
APTH_ID NUMBER(16) Computed unique identified per large table standards (yyyymmddnnnnnnnn)
APTH_CREATE_DT DATE sysdate
APTH_CREATE_USER_ID VARCHAR2(65) ‘conv’
APTH_UPDATE_DT DATE sysdate
APTH_UPDATE_USER_ID VARCHAR2(65) ‘conv’
APTH_REF_SYSTEM VARCHAR2(4) ‘RSAO’
CPA_PREM_NUM NUMBER(13,0) NULL
RSR_REQ_NUM NUMBER(16) NULL
RSAO_ADD_ON_REQ_NUM NUMBER(16) rsao_add_on_req_num
APTH_TRANS_SRCE VARCHAR2(2) ‘I’
APTH_LDC_NAME_CD VARCHAR2(4) NULL
APTH_LDC_ACCT_NUM VARCHAR2(25) NULL
APTH_LEVEL1_APPROVAL_STAT VARCHAR2(1) NULL
APTH_LEVEL1_APPROVAL_DT DATE NULL.
APTH_LEVEL1_APPROVAL_ID VARCHAR2(30) NULL
APTH_LEVEL2_APPROVAL_STAT VARCHAR2(1) NULL
APTH_LEVEL2_APPROVAL_DT DATE NULL.
APTH_LEVEL2_APPROVAL_ID VARCHAR2(30) NULL
APTH_RECEIVED_DT DATE NULL
APTH_BALANCE_AMT NUMBER(11,2) RR_SERV_ADD_ON_REQ.rsao_tot_amt – amount previously extracted to sap
APTH_CUST_NAME VARCHAR2(65) NULL
APTH_SENT_DT DATE NULL
APTH_WBS_ELEMENT VARCHAR2(25) NULL
APTH_GL_ACCT_NUM VARCHAR2(15) NULL
APTH_IS_FINANC_ADJ VARCHAR2(1) ‘N’
Edited by: user652807 on Sep 3, 2008 4:51 PMIt appears you're missing the format mask in the TO_CHAR, ...
TO_CHAR(:new.apth,'YYYYMMHR24MISS')
The full code would help a bit more. -
How to Generate CSV Output from JD Edwards BI Publisher
Hi All,
I have a report "Critical Date Report" - R15611 in JD Edwards 8.11. This report has to be generated as CSV output from BI Publisher which is embedded to JDE.
The purpose we want use BI Publisher is to move some of the data displaying to different place in the page(ex: Move the company address from top left corner to Bottom right corner).
In order to achieve this
1.We created blank rtf template and upload to XML repository using P95600 application
2.Create report definition using P95620 application
3.Here I see the available output types as PDF,RTF,HTML,EXCEL,POWERPOINT and XML,ETEXT(GRAYED OUT)
Which output type we can use for CSV ?
4.Execute the report definition of the critical date report from P95620 to get the XML source
5.This XML source will be loaded into the blank rtf template
6.From this point no idea how to design the rtf template in order to get the CSV output.
7.We did design and output type as excel - but the result data is not in good formatting and alignment*(Headers and footers are repeating).*
If any one has worked on similar type of requirement,let us know how to do or send a sample XML source,rtf template and how the CSV output will be. Or any document link present in Oracle site will be helpful. Please let me know if you need more details.
Thanks in Advance.
VijayHi Vijay,
For CSV output, you need an E-text template (not RTF) that's why its grayed out! You can use Excel as output type and have (No headers and footers) , then you can open the file in Excel and store it as CSV. Does not always display correctly though.
Why are you compelled to use BI publisher? you can use the JDE standard csv output report, (as is used by most EDI systems) of course this may involve a bit of customization if you wants the fields arranged differently.
-Domnic -
How to Generate a new PERNR using HR_MAINTAIN_MASTERDATA in WD?
Hi Experts;
Can I get some sample code for creating a new PERNR using HR_MAINTAIN_MASTERDATA FM. ???!!!
I've created a some input fields in webdynpro using infotype PA0002 and depending upon those fields I want to generate a PERNR number .
Plz help me with some sample code ..
Thanks in Adv.
Buntywhat am I missing in the below code ??? is the code correct ??? Using the below code how will I get the new PERNR value ??
method ONACTIONSAVE .
DATA lo_nd_final_node TYPE REF TO if_wd_context_node.
DATA lo_el_final_node TYPE REF TO if_wd_context_element.
DATA ls_final_node TYPE wd_this->element_final_node.
DATA lv_inits LIKE ls_final_node-inits.
DATA lv_nachn LIKE ls_final_node-nachn.
DATA lv_vorna LIKE ls_final_node-vorna.
DATA lv_titel LIKE ls_final_node-titel.
DATA lv_gesch LIKE ls_final_node-gesch.
DATA lv_natio LIKE ls_final_node-natio.
DATA lv_famst LIKE ls_final_node-famst.
DATA lv_gbpas LIKE ls_final_node-gbpas.
DATA lv_stras LIKE ls_final_node-stras.
DATA lv_ort01 LIKE ls_final_node-ort01.
DATA lv_pstlz LIKE ls_final_node-pstlz.
DATA lv_telnr LIKE ls_final_node-telnr.
DATA lv_locat LIKE ls_final_node-locat.
DATA lv_usrid LIKE ls_final_node-usrid.
* navigate from <CONTEXT> to <FINAL_NODE> via lead selection
lo_nd_final_node = wd_context->get_child_node( name = wd_this->wdctx_final_node ).
* get element via lead selection
lo_el_final_node = lo_nd_final_node->get_element( ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `INITS`
IMPORTING
value = lv_inits ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `NACHN`
IMPORTING
value = lv_nachn ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `VORNA`
IMPORTING
value = lv_vorna ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `TITEL`
IMPORTING
value = lv_titel ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `GESCH`
IMPORTING
value = lv_gesch ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `NATIO`
IMPORTING
value = lv_natio ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `FAMST`
IMPORTING
value = lv_famst ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `GBPAS`
IMPORTING
value = lv_gbpas ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `STRAS`
IMPORTING
value = lv_stras ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `ORT01`
IMPORTING
value = lv_ort01 ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `PSTLZ`
IMPORTING
value = lv_pstlz ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `LAND1`
IMPORTING
value = lv_land1 ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `LOCAT`
IMPORTING
value = lv_locat ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `TELNR`
IMPORTING
value = lv_telnr ).
* get single attribute
lo_el_final_node->get_attribute(
EXPORTING
name = `USRID`
IMPORTING
value = lv_usrid ).
DATA lv_new_pernr LIKE ls_final_node-new_pernr.
* get single attribute
lo_el_final_node->SET_attribute(
EXPORTING
name = `NEW_PERNR`
IMPORTING
value = lv_new_pernr ).
CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
* EXPORTING
* PERNR = '00000000'
* MASSN =
* ACTIO = 'INS'
* TCLAS = 'A'
* BEGDA = SY-DATUM
* ENDDA = '99991231'
* OBJPS =
* SEQNR =
* SPRPS =
* SUBTY =
* WERKS =
* PERSG =
* PERSK =
* PLANS =
* DIALOG_MODE = '0'
* LUW_MODE = '1'
* NO_EXISTENCE_CHECK = ' '
* NO_ENQUEUE = ' '
* IMPORTING
* RETURN =
* RETURN1 =
* HR_RETURN =
TABLES
proposed_values =
* MODIFIED_KEYS =
endmethod.
Maybe you are looking for
-
JTable: How to reference the selected row during a drag?
I am implementing Drag and Drop on the rows of a JTable. I want to change the background colour of each successive JTable row ("highlight" the row) as another row is dragged over it (I already have similar functionality implemented in a custom TableC
-
I am getting an out of memory error when I try to open a PDF in Acrobat XI Pro
How do I clear the memory and get rid of this message. Thanks
-
When I start adobe Pro Extended it tells me my serial number is not valid. We purchased this number back in 2009 and never had a problem till now.
-
I lost the capability of opening my photo's and uploading photos from my iPhone. Not sure what happened. Either way, I eventually deleted my 6.06 version and upgraded to iPhoto 08. But still the same problem. It brings up the main screen, but searche
-
Real Player is not working properly.It downloads videos but when I click "play" ,it doesn't reproduce the video. I tried resetting Real Player but nothing happens. It worked fine up until a couple of dyas ago. What can I do?