CSV file generation with timestamp time details
CREATE OR REPLACE PROCEDURE extract_proc AS
l_rows number;
begin
l_rows := extract_function('select *
from table1 where date1 between trunc(sysdate) and sysdate
'MYDIR1',
'test.csv');
end;
I have a procedure extract_proc shown above which create a CSV in the directory MYDIR1 in the unix.
I would like to have the timestamp ie ddmmyyyyHH24:MI details in the CSV file name created. ie. to have a file name of test22072011.csv whenever it generates with respective timestamp to be prefixed or suffixed to the file number. Is ther any way to achieve this
Pls suggest
Many thanks
Why don't you set your file name dynamically? Something like:
AS
file_name VARCHAR2(50);
BEGIN
file_name := 'test' || TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') || '.csv';
extract_function(...,file_name);
END;
/
Similar Messages
-
How to upload multiple .CSV files in the same time.
Hi Legends,
Can anyone please help me to resolve my issue?
This is very urgent and critical.
Description:
We have two users.1)edw_user_dump
2)prd_udm.
We need to upload the xx.csv file at the same time for these two users in oracle forms.
we have differentiated .csv file name based on the user names.
the main problem is in the sql loader command the xx.csv file name is created but the data is not captured in the server (kentucky) .
Below is my code for the upload.
-- To delete the Part_Mast.log file from the client
DECLARE
pid WEBUTIL_HOST.PROCESS_ID;
v_result PLS_INTEGER;
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
BEGIN
v_result := WEBUTIL_HOST.Get_return_Code(pid ) ;
host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
END;
DECLARE
l_success boolean:=FALSE;
l_bare_filename varchar2(100):=NULL;
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
BEGIN
-- Delete the content of the log and bad file
host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
--host('cat /dev/null > /tmp/Part_Mast.bad');
-- Upload the data file to Application Server
l_bare_filename := v_username||'_'||substr(:FIC_SOURCE,instr(:FIC_SOURCE,'\',-1)+1);
l_success := webutil_file_transfer.Client_To_AS_with_progress
(clientFile => :FIC_SOURCE
,serverFile => '/tmp/'||l_bare_filename
,progressTitle => 'Upload to Application Server in progress'
,progressSubTitle => 'Please wait'
,asynchronous => false
,callbackTrigger => null
IF l_success THEN
NULL;
ELSE
null;
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE Form_Trigger_Failure;
END;
DECLARE
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
begin
host('cat /dev/null > /tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log');
host('cat /dev/null > /tmp/EDW_CF_IO_UPLOAD.bad');
end;
BEGIN
DECLARE
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
v_password varchar2(30) := GET_APPLICATION_PROPERTY(PASSWORD);
v_connect_string varchar2(30) := GET_APPLICATION_PROPERTY(CONNECT_STRING);
a_host varchar2(500);
BEGIN
a_host :='/tmp/'||v_username||'_'||'"CF615 IO Upload.csv"';
host('sqlldr '||v_username||'/'||v_password||'@'||v_connect_string||' '|| 'control=/home/edw_bis/ctl/GLB_CF_IO_UPLOAD.CTL'||' '|| 'DATA=a_host'||' '|| 'LOG=/tmp/'||v_username||'_'||'EDW_CF_IO_UPLOAD.log SKIP=1 errors=200000 DIRECT=FALSE');
dbms_output.put_line(a_host);
END;
DECLARE
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
begin
host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
EXCEPTION
WHEN OTHERS THEN
RAISE Form_Trigger_Failure;
END;
end;
DECLARE
al_id3 ALERT;
al_button Number;
BEGIN
edw_user_dump.SANM_PRC_MERGE_CF_IO_UPLOAD(:global.v_plsql_res,:global.v_ins_rec,:global.v_upd_rec);
IF NVL(:global.v_plsql_res,0) = 0 and (:global.v_ins_rec !=0 OR :global.v_upd_rec != 0 ) then
al_id3 :=FIND_ALERT('ROWINS');
SET_ALERT_PROPERTY(al_id3,alert_message_text,' Process Completed Successfully!'||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec);
al_button := SHOW_ALERT( al_id3 );
ELSIF (:global.v_plsql_res IN(-1,0) or :global.v_plsql_res > 0) and (:global.v_ins_rec =0 and :global.v_upd_rec = 0 and :global.v_del_rec =0 ) then
al_id3 :=FIND_ALERT('ROWINS');
SET_ALERT_PROPERTY(al_id3,alert_message_text,' Process Failed. Please Download the Log File '||CHR(10)||' Rows Failed : '||:global.v_plsql_res||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec);
al_button := SHOW_ALERT( al_id3 );
ELSE
al_id3 :=FIND_ALERT('ROWINS');
SET_ALERT_PROPERTY(al_id3,alert_message_text,'Please Download the Log File '||CHR(10)||' Rows Failed : '||:global.v_plsql_res||CHR(10)||' Rows Inserted : '||:global.v_ins_rec ||CHR(10)||' Rows Updated : '||:global.v_upd_rec );
al_button := SHOW_ALERT( al_id3 );
END IF;
EXCEPTION WHEN OTHERS THEN
RAISE Form_Trigger_Failure;
END;
DECLARE
v_username varchar2(30) := GET_APPLICATION_PROPERTY(USERNAME);
begin
host('cat /dev/null > /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
host('rm -rf /tmp/'||v_username||'_'||'"CF615 IO Upload.csv"');
end;
Thanks in advance!
Thanks,
MadhusudhananMadhusudhanan,
A couple of observations. First; always list your exact Forms version (eg; 10.1.2.0.2 not 10g R2). In most cases, the solution is different depending on the Forms version. Second; why must you use Forms to kick off a SQL Loader process? This is a server-side process and should be initiated by a server side process. If you absolutely must use Forms to kick off the process, again we need your Forms version in order to offer any solutions. Based on your code sample, I can asusme you are at least using Forms 9i becuase you are using WebUtil.
Is your Database and Application Server the same physical computer? If they are not, this would explain why your HOST command isn't working because HOST runs against the Application Server not the Database server.
Third; have you considered using and External Table (if your RDBMS version supports them) for each of the files you are attempting to upload? In this instance, it would be helpful to know your RDBMS version as well. External Tables can be a little frustrating to set up the first time, but as with any new construct you use - it gets easier the more you use it.
Fourth; are you getting any errors in your log file(s)? If so, what are the errors? Please list the full error message if you have one.
Finally, with respects to your statement:
Posted: Mar 18, 2011 2:30 PM - Madhu This is very urgent and critical.>
You have to understand that forum contributers are all volunteers - this is not our full-time job. If your issue is truely urgent I suggest you open a Service Request (SR) with Oracle Support! ;-)
Craig B-)
If someone's response is helpful or correct, please mark it accordingly. -
Script to merge multiple CSV files together with no duplicate records.
I like a Script to merge multiple CSV files together with no duplicate records.
None of the files have any headers and column A got a unique ID. What would be the best way to accomplish that?OK here is my answer :
2 files in a directory with no headers.
first column is the unique ID, second colomun you put whatever u want
The headers are added when using the import-csv cmdlet
first file contains :
1;a
2;SAMEID-FIRSTFILE
3;c
4;d
5;e
second file contains :
6;a
2;SAMEID-SECONDFILE
7;c
8;d
9;e
the second file contains the line : 2;b wich is the same in the first file
the code :
$i = 0
Foreach($file in (get-childitem d:\yourpath)){
if($i -eq 0){
$ref = import-csv $file.fullname -Header id,value -Delimiter ";"
}else{
$temp = import-csv $file.fullname -Header id,value -Delimiter ";"
foreach($line in $temp){
if(!($ref.id.contains($line.id))){
$objet = new-object Psobject
Add-Member -InputObject $objet -MemberType NoteProperty -Name id -value $line.id
Add-Member -InputObject $objet -MemberType NoteProperty -Name value -value $line.value
$ref += $objet
$i++
$ref
$ref should return:
id
value
1
a
2
SAMEID-FIRSTFILE
3
c
4
d
5
e
6
a
7
c
8
d
9
e
(get-childitem d:\yourpath) -> yourpath containing the 2 csv file -
Hello All,
We are facing below issue during CSV file generation :
Generated file shows field value as 8.73E+11 in output and when we are clicking inside this column result shown is approximate of the correct value like 873684000000. We wish to view the correct value 872684000013.
Values passes from report program during this file generation are correct.
Please advice to resolve this issue.
Thanks in Advance.There is nothing wrong in your program, it is the property of excel that if the value in the cell is larger than
default size it shows in output of that format. -
How can I display a .csv file as a real time waveform using labview
Hi folks.
As stated, Im looking to display a .CSV file (obtained via RS-232, example; 100,101,102,102,102,103...) as a waveform in real-time. What is the best way to approach this? Im thinking LabVIEW. I have version 7.1 but am not really experienced in using it. I'll give anything a go though. Also, I have Visual Studio 2005, so I was thinking VB???
Thanks in advance!
Simon.
Message Edited by simonious on 10-26-2007 04:13 AMHave a look at this VI.
Add a convert string to number function behind it.
André
Message Edited by andre.buurman@carya on 10-26-2007 01:08 PM
Regards,
André
Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)
Attachments:
convert csvars 2 array of vars.vi 16 KB -
Using a lookup from one CSV file to another CSV file errors with a name clash
Hi
I have a master CSV file created by querying the AD. I need to populate the "Team" attribute by doing a lookup using Name against the Name Column any of 6 CSVs, someone has prepared for me . The problem is the data is inconsistent
in the 6 CSV files so Name can hold either the Name or Username i.e. SAmAccountName or LoginName
Now my ps script works when the data is good. but I have around 30 exception cases whereby there is a mismatch . To explain:
is in this line ( see the big code block below)
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
The $_.Name is using the top level masterCSVData Name but I was hoping that it was using the
$nameAndTeamCSVData.Name as in only within the scope of the Where-Object {} ..I guess I have misunderstood the syntax of what I had written.
. A quick a dirty fix would be rename this column in all of the 4 spreadsheets or trying to fix the code.....
# now update the empty team value for user object
$csvMasterData | ForEach-Object `
$masterName = $_.Name
$masterUserName = $_.Username # to deal with exception cases
#force scope to as the properties in the outer with the same name should be out of scope
# lookup the Name to see if we can extract the user's Team
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterName }
# deal with the situation where the name in the businesses spreadsheets is actually the Username (login name) in the master csv
if ( $userObject -eq $null )
# lookup the username (loginname) to see if we can extract the user's Team # !!!!error occurs here with the $_.Name !!!!!
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
if ( $userObject -eq $null )
$_.Team = "UNKNOWN"
else
# replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
else
# Name matches so replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
DanielI see your challenge. How about collecting the column names in an array and looking for the potential names? Following my example before, try this:
$dataColumns = $I | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
Now, you can loop through the names and collect the appropriate data.
if ($dataColumns.Contains('Column1'))
#add ForEach-Object { $_.Column1... }
HTH
~fr3dd
Hi I had to wait until Friday as I have someone ( my boss) checking the business & team csv files against valid usernames and names.
# now update the empty team value for user object
$nameAndTeamCsvData | ForEach-Object `
$nt_name = $_.Name
# $masterUserName = $_.Username # to deal with exception cases
# lookup the Name to see if we can extract the username and mobile from the masterCSV
$userObject = $null # Replace my original code: $csvMasterData | Where-Object {$_.SName -eq $nt_name } # with foreach code below
$uo = $null
foreach ($uo in $csvMasterData)
if ($uo.SName -eq $nt_name)
$userObject = $uo
# ouch can't break out of this even though I found it so have to move on to the next
}if ( $userObject -ne $null ){ # Name matches so replace the few propeerties in mastercsv.Team with the ones we have looked up
$_.Username =$userObject.SamAccountName
$_.Mobile =$userObject.Mobile
This does work but is clearly not very efficient since I don't think I can
break or exit out of the foreach loop. I am thinking I could quickly modify and add your code - my import is delayed as I am having a new property added to user class... Let me know what you think. -
File name with Dateand time stamp.
Hi All,
I want to generate a file with a date and time stamp.
For that in File Receiver adaptor i am using option "Add Time Stamp" in File Construction mode. however it is generationg file name as: FileName_20082104_121211_645.txt . In this I don't know what these last three characters "_645" are? And In the File name i only want a file name with datetime stamp . I don't require underscore in between. for eg: FileName_20082104121211.txt (FileName_dateTime.txt)
Can anybody suggest me the way to achive this?
Thanks,
Atul@FileName_20082104_121211_645
The date time stamp in XI's file adapter will be in that format. This is to avoid over writing of files created simultaneously at the same time. So the last 3 digits is a form of an unique id to distinguish between the same.
In case you want the format as FileName_20082104_121211, use the dynamic configuration and create the file name inside the mapping itself and pass it across.
To get an idea about the same, ref:
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14 - an usage of the same.
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm -
Using the regex to match the file name with date time
Hello all,
currently I had problem to match the following file name with the date time. Of course I can use this regex like ""(\\\\w+|.+).(zip)" to match it. However in the current application i need to parse the file name and get the current date time to check if it is matched. Does anyone have good idea?
{code}
testfile10-08-09-2008-08-21-04-24-0443.zip
testfile11-08-09-2008-08-22-04-24-0441.zip
{code}
thanks in advanced!lauehuang wrote:
Hello all,
currently I had problem to match the following file name with the date time. Of course I can use this regex like ""(\\\\w+|.+).(zip)" to match it.That regex doesn't make a lot of sense:
- with "\\\\w" you probably meant "\\w";
- "\\w+|.+" doesn't make sense: you can simply do ".+" in that case;
- ".(zip)" will also match the string "%zip" or "Ezip".
However in the current application i need to parse the file name and get the current date time to check if it is matched. I don't know what you mean by that. -
Dyanmic csv file downloading with out writing a copy to server
Hi,
Here is my problem, any help most appriciated..
I want to download dynamically created CSV file from the weblogic server, using jsp/servlet communication.
I developed a servlet for this and i called that servlet from my jsp page, when user clicks on download button, my servlet works fine, but it writes a copy of CSV file into c:\bea\wlserver6.0 of the server, My intention is just it's has to dowload file to the client system, with out writing a copy in the server.
Here is my code snnipits..
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
HttpSession session = req.getSession(true);
try {
resultMessageLastBalance = mtdRetrieveLastBalance(req);
rsTrxnDetailLastBalance = resultMessageLastBalance.getRecordSet("lasttentrxn");
} catch (Exception e) {
e.printStackTrace();
e.getMessage();
File csvFile;
FileOutputStream file;
//codes to generate a file in local server for downloading
Calendar calendar = Calendar.getInstance();
String strFileName = Integer.toString(calendar.get(Calendar.YEAR))+Integer.toString(calendar.get(Calendar.MONTH))+Integer.toString(calendar.get(Calendar.DATE))+Integer.toString(calendar.get(Calendar.HOUR))+Integer.toString(calendar.get(Calendar.MINUTE))+Integer.toString(calendar.get(Calendar.SECOND))+Integer.toString(calendar.get(Calendar.MILLISECOND));
try {
strFileName = DeformatAcctNo(req.getParameter("acct_trxn__acctselected")) + strFileName + ".csv";
} catch (Exception e) {}
calendar = null;
csvFile = new File(strFileName);
if (!csvFile.exists()) {
csvFile.createNewFile();
file = new FileOutputStream(csvFile);
res.setContentType("application/download");
res.setHeader("Content-Disposition","attachment;filename=" + strFileName);
javax.servlet.ServletOutputStream servletoutputstream1 = res.getOutputStream();
String s = strFileName;
dumpFile(s, servletoutputstream1);
servletoutputstream1.flush();
servletoutputstream1.close();Hi,
Thanx a lot for ur solution..it's helful for me to send data with a file format,but i need t send data in csv file foramt.
hav a look at my complete servelt and try to suggesst some thing..
In this case csv file is creating in c:\bea\wlserver directory.my intensions sre just it jas to download to client, no copy in the server.
public class AcctStmtD2 extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
//variables for retrieving last balance
Message resultMessageLastBalance = null;
RecordSet rsTrxnDetailLastBalance = null;
double dblDebitTotal = 0.00;
double dblCreditTotal = 0.00;
HttpSession session = req.getSession(true);
Enumeration ea = session.getAttributeNames();
while(ea.hasMoreElements()) {
Object name = ea.nextElement();
System.out.println("values = " + session.getAttribute((String)name));
try {
resultMessageLastBalance = mtdRetrieveLastBalance(req);
rsTrxnDetailLastBalance = resultMessageLastBalance.getRecordSet("formonthtrxn");
} catch (Exception e) {
e.printStackTrace();
e.getMessage();
File csvFile;
FileOutputStream file;
//codes to generate a file in local server for downloading
Calendar calendar = Calendar.getInstance();
String strFileName = Integer.toString(calendar.get(Calendar.YEAR))+Integer.toString(calendar.get(Calendar.MONTH))+Integer.toString(calendar.get(Calendar.DATE))+Integer.toString(calendar.get(Calendar.HOUR))+Integer.toString(calendar.get(Calendar.MINUTE))+Integer.toString(calendar.get(Calendar.SECOND))+Integer.toString(calendar.get(Calendar.MILLISECOND));
try {
strFileName = DeformatAcctNo(req.getParameter("acct_stmt__acctselected")) + strFileName + ".csv";
} catch (Exception e) {}
calendar = null;
csvFile = new File(strFileName);
if (!csvFile.exists()) {
csvFile.createNewFile();
file = new FileOutputStream(csvFile);
if (rsTrxnDetailLastBalance.getTotalRowCount() >= 1) {
String strLastBal = "";
String strCurrCd = "";
try {
rsTrxnDetailLastBalance.moveLast();
strLastBal = rsTrxnDetailLastBalance.getValue("bal");
rsTrxnDetailLastBalance.moveFirst();
strCurrCd = "(" + GetCurrCdFromSession(session, req.getParameter("acct_stmt__acctselected")) + ")";
file.write(("\""+req.getParameter("acct_stmt__acctselected")+"\"").getBytes());
file.write(',');
file.write(',');
file.write(',');
file.write(',');
file.write(',');
file.write(("\""+"Last Balance "+strCurrCd+" = "+strLastBal+"\"").getBytes());
file.write('\n');
file.write(("\""+"Date"+"\"").getBytes());
file.write(',');
file.write(("\""+"Slip No"+"\"").getBytes());
file.write(',');
file.write(("\""+"Description"+"\"").getBytes());
file.write(',');
file.write(("\""+"Debit"+" "+strCurrCd+"\"").getBytes());
file.write(',');
file.write(("\""+"Credit"+" "+strCurrCd+"\"").getBytes());
file.write(',');
file.write(("\""+"Balance"+" "+strCurrCd+"\"").getBytes());
file.write('\n');
} catch (Exception e) {System.out.println("!");}
while(rsTrxnDetailLastBalance.moveNext()) {
try {
file.write(("\""+rsTrxnDetailLastBalance.getValue("txn_dt").substring(0,12)+"\"").getBytes());
file.write(',');
file.write(("\""+rsTrxnDetailLastBalance.getValue("slip_no")+"\"").getBytes());
file.write(',');
file.write(("\""+rsTrxnDetailLastBalance.getValue("dscp")+"\"").getBytes());
file.write(',');
file.write(("\""+rsTrxnDetailLastBalance.getValue("debit")+"\"").getBytes());
file.write(',');
file.write(("\""+rsTrxnDetailLastBalance.getValue("credit")+"\"").getBytes());
file.write(',');
file.write(("\""+rsTrxnDetailLastBalance.getValue("bal")+"\"").getBytes());
file.write('\n');
} catch(Exception e) {}
try {
dblDebitTotal += Double.parseDouble(rsTrxnDetailLastBalance.getValue("debit"));
} catch (Exception e) {
dblDebitTotal = 0;
try {
dblCreditTotal += Double.parseDouble(rsTrxnDetailLastBalance.getValue("credit"));
} catch (Exception e) {
dblCreditTotal = 0;
file.write(',');
file.write(',');
file.write(("\""+"Total"+"\"").getBytes());
file.write(',');
file.write(("\""+Double.toString(dblDebitTotal)+"\"").getBytes());
file.write(',');
file.write(("\""+Double.toString(dblCreditTotal)+"\"").getBytes());
} else {
file.write(("\""+"No Record Found!"+"\"").getBytes());
file.close();
res.setContentType("application/download");
res.setHeader("Content-Disposition","attachment;filename=" + strFileName);
javax.servlet.ServletOutputStream servletoutputstream1 = res.getOutputStream();
String s = strFileName;
dumpFile(s, servletoutputstream1);
servletoutputstream1.flush();
servletoutputstream1.close();
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
doGet(req, res);
private void dumpFile(String s, OutputStream outputstream) {
byte abyte0[] = new byte[4096];
boolean flag = true;
try {
FileInputStream fileinputstream = new FileInputStream(s);
int i;
while((i = fileinputstream.read(abyte0)) != -1)
outputstream.write(abyte0, 0, i);
fileinputstream.close();
} catch(Exception e) {}
private Message mtdRetrieveLastBalance(HttpServletRequest req) throws Exception {
Message msgMessage = new Message();
DAC.Parser.RecordSet objFund_Tx = msgMessage.createRecordSet("formonthtrxn");
//Set the header fields for the record
objFund_Tx.addHeaderFields("acctselected","String");
objFund_Tx.addHeaderFields("formonth","String");
objFund_Tx.addHeaderFields("foryear","String");
//Add a new row to the recordset
objFund_Tx.addRow();
msgMessage.setData("recordnm", "string", "formonthtrxn");
//Set the required fields into the recordset
objFund_Tx.setValue("acctselected", DeformatAcctNo(req.getParameter("acct_stmt__acctselected")));
objFund_Tx.setValue("formonth", req.getParameter("acct_stmt__formonth"));
objFund_Tx.setValue("foryear", req.getParameter("acct_stmt__foryear"));
objFund_Tx.setStatus("select");
System.out.println("JSP IN :"+msgMessage);
msgMessage = mtdOpenConnection(msgMessage);
System.out.println("JSP OUT :"+msgMessage);
return msgMessage;
private Message mtdOpenConnection(Message objMessage) throws Exception {
java.util.Hashtable ht = new java.util.Hashtable();
ht.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(javax.naming.Context.PROVIDER_URL, "t3://localhost:7001");
javax.naming.InitialContext ic = new javax.naming.InitialContext(ht);
DAC.BusinessObjects.RIB.Account.AccountHome pmHome = (DAC.BusinessObjects.RIB.Account.AccountHome)PortableRemoteObject.narrow(ic.lookup("AccountEJB"),Class.forName("DAC.BusinessObjects.RIB.Account.AccountHome"));
DAC.BusinessObjects.RIB.Account.Account pmObj = (DAC.BusinessObjects.RIB.Account.Account)PortableRemoteObject.narrow(pmHome.create(),Class.forName("DAC.BusinessObjects.RIB.Account.Account"));
return pmObj.mtdRetrieveTrxForMonth(objMessage);
private String convertSingleDigitMonthDayToDouble(String param) throws Exception {
if (param.length() > 1) {
return param;
} else {
return "0" + param;
//remove dashes and product name and branch code from string
private String DeformatAcctNo(String strAcctNo) throws Exception {
strAcctNo.trim();
return strAcctNo.substring(0,3)+strAcctNo.substring(4,6)+strAcctNo.substring(7,12)+strAcctNo.substring(13,14);
private String GetCurrCdFromSession(HttpSession session, String acct_no) throws Exception {
String strAcctDetail = "";
String strCurrCd = "";
Vector vList = (Vector)session.getAttribute("accountlist");
for (int i = 0; i < vList.size(); i++) {
strAcctDetail = (String)vList.get(i);
if ((strAcctDetail.substring(0, acct_no.length()).equals(acct_no))) {
strCurrCd = strAcctDetail.substring(strAcctDetail.indexOf(":") + 1, (strAcctDetail.indexOf(":") + 4));
break;
vList = null;
strAcctDetail = null;
return strCurrCd;
} -
Why won't excel read my csv file created with the powersell out-file automatically.
I wrote a PowerShell script that creates a CSV formatted file. The script simply creates a comma delimited string for each entry and adds it to a collection. Then the out-file command write it to a file.
When you open it with Excel each line is put into one cell. If you import the file and specify the "," as the delimiter, it imports just fine. If the data is saved out again as a csv file, the file is about half the size and opens
just fine with excel.
If you open the original file and the file created by Excel with notepad, they look the same.
So the files are different in size, contents look the same, but Excel won't automatically open the original file.
Any ideas of why this happens? Also PowerShell and Excel are both running on Server 2012 R2. Excel is a remote app.
If I do an export-CSV, I get some kind of information about the object.
Here is the script:
foreach ($group in $groups)
$header += '"' + $group.name + '",'
$CSVdata = @()
$CSVdata += $header
# Create a user entry
$users = Get-ADUser -filter * |select SamAccountname, Name | sort SamAccountName
foreach ($user in $users)
$Groupmembership = Get-ADPrincipalGroupMembership -Identity $user.SamAccountName
$userentry = '"' + $user.SamAccountName + '",'
$user
foreach ($group in $groups)
if ($Groupmembership.SamAccountName -contains $group.SamAccountName) { $userentry += '"X",'}
else { $userentry += '"",' }
$CSVdata += $userentry
$CSVdata
Out-File -inputobject $CSVdata -FilePath c:\batch\GroupMembership.csvOk the script works exactly like I want it. Thank you very much.
I am trying to understand the script but I am unable to figure out what the line "$keys=$t.Keys|%{$_}"
does. I figured ".keys" was a method but my search for it comes up blank. Do you have a reference you can point me to? -
CSV file download takes long time
Hi all,
i have an interactive report and there is Download link to file in different formats.
My query is long running query it took almost 3 mins to execute and show in the region .
When i want to download the report in CSV format it also took the same time as the query needs to executed.
My Question ? is why it took the same time download? is it querying DB again to save in CSV?
How the download to CSV can be faster within seconds.
Please help me.
adnanis it querying DB again to save in CSV?Yes. Depending on the report pagination property, the screen might showing a subset of the data, the CSV export function has to re-execute the query in order to generate the CSV file. Try tuning the query so it runs faster.
If you are using IE, I see that the right-click menu has a Export to Excel option; that seems to export just the data you see on the screen, not sure how IE implements that but just thought I would point it out to see if it helps in your situation. -
Load .csv file data with OWb Process flow using Web
Hi,
I Have a file in my local machine( Machines on multiple user's), need to load data through Web user interface.
Let's say have a web page with multiple radio buttons respective to different sources, by clicking on each button will pass the path of .csv file to through Application, (API or Java programming interface) execute owb Process flow as a accepting file path as a input parameter to execute for loading purpose.
Should facilitate view data, Update data through web based on user requests.
Need your guidence how can i implement this with OWb 11g R2.
Assuming with Web browser functionality. Please confirm it and if yes, please throw some light how could be the steps to implement.
ThanksHi David,
Thanks for your reply.
Undersatnd your proposed solution.But my requirement should be as follows.
1. Currently under consideration using web page likely to be implement with Java, allowing users to load .csv file data into staging area.(Loading flat file into Data abse table)
Case 1, Assuming OWB software is not installed on user machine. I think no.
Is it possible through web page (this case Java page) to trigger java procedure/Pl/SQl procedure or integration of both to laod data into staging area.If yes, how it could effect performance of data load with 1 GB file.
Case 2, OWb client software installed on User machine, while runtime passing parameters means passing manually?
In case it is automated, how should i pass machine name & Path to owb runtime web browser.
Could you please show me guidence how should I acheive this functionality with APEX customization part?
Thanks agin for your support.
Anil -
Problem in csv file generation
Hi ,
I am trying to spool a query in csv format using "col sep ,"
but it is giving problem for the text values like example i have a sql_text column which gives the sql text. in the csv file which was generated the select statement columns are going to next column where the comma is invoked.
is there any way to format while generating csv file that entire sql_text should come in one column
Thanks
Rakeshset echo OFF pages 50000 lin 32767 feed off heading ON verify off newpage none trimspool on
define datef=&1
define datet=&2
set colsep ','
spool querries.csv
SELECT s.parsing_schema_name,
p.instance_number instance_number,
s.sql_id sql_id,
x.sql_text sql_text,
p.snap_id snap_id,
TO_CHAR (p.begin_interval_time,'mm/dd/yyyy hh24:mi') begin_interval_time,
TO_CHAR (p.end_interval_time,'mm/dd/yyyy hh24:mi') end_interval_time,
s.elapsed_time_delta / DECODE (s.executions_delta, 0, 1, s.executions_delta) / 1000000 elapsed_time_per_exec,
s.elapsed_time_delta / 1000000 elapsed_time,
s.executions_delta executions, s.buffer_gets_delta buffer_gets,
s.buffer_gets_delta / DECODE (s.executions_delta, 0, 1, s.executions_delta) buffer_gets_per_exec,
module module
FROM dba_hist_sqlstat s, dba_hist_snapshot p, dba_hist_sqltext x
WHERE p.snap_id = s.snap_id
AND p.dbid = s.dbid
AND p.instance_number = s.instance_number
AND p.begin_interval_time >
TO_TIMESTAMP ('&datef','yyyymmddhh24miss')
AND p.begin_interval_time <
TO_TIMESTAMP ('&datet','yyyymmddhh24miss')
AND s.dbid = x.dbid
AND s.sql_id = x.sql_id
ORDER BY instance_number, elapsed_time_per_exec DESC ;
SPOOL OFF;
exit; -
Hi All,
Can we have a comma included in the csv generated file?
Suppose query contains comma
fieid1 field2
Pickle This pickle, must be sour.
sweet More sweets, leads to diabetes.
My csv should be of two fields not three. But i am getting the csv file in three field because of comma in field2. How Can we resolve it.
field1 field2 field3
Pickle This pickle must be sour.
sweet More sweets leads to diabetes.
Hi anybody can help on these??
ThanksThe same as you put any other character in the file...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
B1if B12FileScenario where .csv file generate with Blank sheet
Dear Expert,
I had gone through 3_B1ifB12FileScenario document, I fallow each step. Even my file created on C:\ drive show blank.
When I see Below Syntax
<xsl:template name="transform">
<FileOut xmlns="" type="file">
<xsl:for-each select="$msg/BOM/BO/Document_Lines/*">
<row>
<col>
<xsl:value-of select="$msg/BOM/BO/Documents/row/CardCode">
</xsl:value-of>
</col>
<col>
<xsl:value-of select="ItemCode">
</xsl:value-of>
</col>
<col>
<xsl:value-of select="Quantity">
</xsl:value-of>
</col>
<col>
<xsl:value-of select="LineNum">
</xsl:value-of>
</col>
<col>
<xsl:value-of select="Price">
</xsl:value-of>
</col>
</row>
</xsl:for-each>
</FileOut>
</xsl:template>
</xsl:stylesheet>
And get output as below
- <Payload Role="R" id="atom0">
- <FileOut xmlns="" type="file">
- <row>
<col>M00001</col>
<col>C00007</col>
<col>1.000000</col>
<col>0</col>
<col>250.000000</col>
</row>
</FileOut>
</Payload>
- <Payload Role="R2">
<bfa:io xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms">==== data-length: 0 ====</bfa:io>
</Payload>
Can any way say, why csv file is blank...
Thanks
Kevinhi,
I think your find the solution, I have the csv file that is blank
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:param name="atom"/>
<xsl:param name="sessionid"/>
<xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']"/>
<xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"/>
<xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"/>
<xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:Receiver/@Id"/>
<xsl:template match="/">
<Msg xmlns="urn:com.sap.b1i.vplatform:entity">
<xsl:copy-of select="/vpf:Msg/@*"/>
<xsl:copy-of select="/vpf:Msg/vpf:Header"/>
<Body>
<xsl:copy-of select="/vpf:Msg/vpf:Body/*"/>
<Payload Role="R" id="{$atom}">
<xsl:call-template name="transform"/>
</Payload>
</Body>
</Msg>
</xsl:template>
<xsl:template name="transform">
<Fileout xmln="" type="file">
<xsl:for-each select="$msg/BOM/BO/Document_lines/*">
<row>
<col>
<xsl:value-of select="$msg/BOM/BO/Documents/row/CardCode"/>
</col>
<col>
<xsl:value-of select="ItemCode"/>
</col>
<col>
<xsl:value-of select="LineNum"/>
</col>
<col>
<xsl:value-of select="Quantity"/>
</col>
<col>
<xsl:value-of select="Price"/>
</col>
</row>
</xsl:for-each>
</Fileout>
</xsl:template>
</xsl:stylesheet>
can you help me?
Maybe you are looking for
-
Using MD5 to generate Dimension IW Keys
Hi Guys I had wanted to use MD5 to hash concatenated strings in a dimension table to come up with IW Keys. I must be missing something because I couldn't find much around the net when looking for it. Basically were looking at facts and dimension data
-
Toshiba Canvio Desk 4tb not recognizesed on TV
Hi, I replaced my D3 Station 3TB (i broke it...) with Toshiba Canvio Desk 4tb, and i got a question; why is not working on my tv(Samsung LE40C530)? My tv recognizes HDD-s only up to 2 tb, so i split the disc on two partitions(i did the same with db s
-
Cannot forward a message using ios7
how do you forward a text message using ios 7
-
Flash & Premiere Pro or After effects?
Looking for advice, I am a Graphic Designer with no formal training in animation. I recieved a job I just can't pass up. It is a great opportunity for me to learn animation. I need to create a cartoon mascot that will be in an environment, that wil
-
Is Perian safe to use on MAC OSX Leopard 10.5.6?
Will I screw up any Apple application, etc... by installing Perian?