Choosing rows for adding into text file

Hello!
Recordset with several rows per reference.
Need to find references with at least one of four rowreferences.
Not all references include any of the four rowreferences.
Need to sum up all rows of reference except the rows with the four rowreferences and group by customerid
If sum per customerid is above set limit, add a line to textfile, one line per reference, sum of special four rowreferences, sum of all rowreferences
Tried this:
Set s7=rows with one or many of the four rowreferences grouped by reference
For finding out which references are valid for inserting into the textfile
Set s8=sum of all rows per reference grouped by customerid
For getting all data for reference.
Set s9 = all customerid’s
I have tried several do...loop statements, but I cannot get it right.
I tried to move through s9, find matching rows from s8, then add up sum per reference in s8 minus sum per reference in s7.
Then if sum per customerid is more than set limit, add separate rows from s8 of this particular customer
 into the file.
What is the best way to solve this ?
Thank you in advance!

I previously asked for your table structure and you posted this --
here are the tables:
Customerinvoices:
ma
Arve
Kellelt
Summa
Kuupaev
52674
150057
customer1
588
16-veebr-15
52673
2015039982
customer2
67,2
13-veebr-15
52672
2015040760
customer2
67,21
13-veebr-15
52671
2015040528
customer2
121,21
13-veebr-15
Customerinvoicesread
SaadudArveNr
Kulu
Sum
Hain
52674
22-01
48
52674
22-07
50
52674
16-29
83,3
52674
16-29
156,8
52674
16-29
83,3
52674
16-29
166,6
52673
58-06
67,2
52672
58-06
67,21
52671
58-06
121,21
and then I need the data to go to the csv so that:
invoice#; sum without tax; sum of tax, date
150057; 490; 98, 16.02.2015
There is the sum of all rows except the tax rows and then the sum of all the tax rows.
That did not give me your structure.  The results line 150057; 490; 98;... did not match data posted.
I cannot help if I do not have the whole picture.
Build a little, test a little

Similar Messages

  • Is it possible to export the out put of Crystal report into text file?

    Hi All,
    Is it possible to export the out put of Crystal report into text file?

    Hi
    Yes, Go to File --> Export --> Export Report --> Under Format select TEXT & select the destination as "Disk file"(defaultly selected)
    Give the proper details as per your requirement for "Characters per inch" & "Number of lines per page" & click on 'OK"
    In "Choose Export file" window, select the destination folder & provide file name. click on "SAVE"
    Regards
    Ashwini

  • Problem with data saving into text file

    Hi,
    The problem I am facing wihile saving the data into text file is that everytime when I am slecting the path from front panel, the data which is being saved is appended with the previous data, i.e. not only in the new text file, the new set of data is saved but also, if there is any previuos run for the program, the corresponding data is also present in that text file.
    However, when I change the same 'control'(file path) to 'constant' in the block diagram, and add the file path, there is no such problem. Basically, changing the "File path" from constant in the block diagram to control (so that it is displayed in the front panel) is causing the problem.
    Please help!
    Thanks 
    Solved!
    Go to Solution.
    Attachments:
    front panel.JPG ‏222 KB
    Block Diagram.JPG ‏70 KB
    Block diagram with File Path as Constant.JPG ‏74 KB

    Your shift register on the For loop is not initialized. It will retain the value of the string from the last time it executed. Initialize that and it should solve your problem.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • I have to average data of 1min and then log into text file

    For my application i have to average data of 1min and then log into text file. please guide me on this . To transfer the data i am using notifier.
    Prashant Soni
    LabVIEW Engineer

    hi prashant,
      Check this attachment..I just implemented my idea    in this one.
    Thanks and regards,
    srikrishnaNF
    Attachments:
    Example_VI_BD.png ‏12 KB

  • Spool SQl data into text file using dynamic sql

    Hi,
    I am spooling output data into text file using command
    select 'select t.mxname,bo.lxtype,t.mxrev'||chr(10)||'from mx_1234567'||chr(10)||
    'where <condition>';
    here mxname varchar(128),lxtype(128),mxrev(128) all are of varchar type.I want the output in format
    e.g Part|1211121313|A
    but due to column width the output,I am getting is with spaces.
    "Part then blank spaces |1211121313 then blank spaces |A"
    how can I remove these spaces between columns.I used set space 0 but not working.
    Thanks in advance.
    Your help will be appreciated.

    Hi Frank,
    I have seen your reply for SET LINE SIZE function. But, I could not be able to understand it.
    I am facing similar kind of issue in my present project.
    I am trying spool more than 50 columns from a table into flat file. Because of more column lengths in few columns, i am getting space. There are so many columns with the same issue. I want to remove that space.so that, data can fit perfectly in one line in .txt file without any wrap text.
    Below is my sample query.sql. Please let me know the syntax. My mail id : [email protected]
    --Created : Sep 22,2008, Created By : Srinivasa Bojja
    --Export all Fulfillments
    --Scheduled daily after 1:00am and should complete before 3:30am
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    SET LINESIZE 800
    SET WRAP OFF
    SET PAGESIZE 800
    SET FEEDBACK OFF
    SET HEADING ON
    SET ECHO OFF
    SET CONCAT OFF
    SET COLSEP '|'
    SET UNDERLINE OFF
    SPOOL C:\Fulfillment.txt;
    SELECT SRV.COMM_METHOD_CD AS Method,
    SRV.SR_NUM AS "Fulfillment Row_Id",
    CON.LAST_NAME AS "Filled By"
    SRV.SR_TITLE AS Notes,
    SRVXM.ATTRIB_04 AS "Form Description"
    FROM SIEBEL.S_SRV_REQ SRV,
    SIEBEL.S_SRV_REQ_XM SRVXM,
    SIEBEL.S_USER USR,
    SIEBEL.S_CONTACT CON
    WHERE SRV.ROW_ID = SRVXM.PAR_ROW_ID AND
    SRV.OWNER_EMP_ID = USR.ROW_ID AND
    CON.ROW_ID= SRV.CST_CON_ID;
    SPOOL OFF;
    EXIT;

  • Is there any way to download smartform into text file

    is there any way to download smartform into text file

    Hi,
    No you cant save a smart form into text file but you can store it in a XML file.
    Goto menu Utilities --> select More Utilities --> select Upload/Download --> click Download and give the path to save the backup for smartform.
    Now you smartform is saved to XML file at your PC.
    Also you can upload this smartform.
    Hope this helps you.
    Regards,
    Tarun

  • Downloading ...into text file

    hii Friends,,,,
                        i want to download report program into text file and its includes into seperate text file without using function modules.I want to do it with CL_GUI_FRONTEND_SERVICES and readreport.
    Kindly halp me or send any sample code???
    Regards Mandeep.

    Hi Mandeep Singh,
    The solution is simple press the button PATTERN or press CTRL + F6.
    That gives you a pop up.
    Select radio button "ABAP Object Patterns"
    Press Enter.
    In Call Method radio button.
    Type "CL_GUI_FRONTEND_SERVICES"  in Class/Interface.
    <b>Select the METHOD of your choice by pressing F4 in the box Method.</b>
    This should solve the query.
    Reward Points if useful.
    Thanks,
    Tej..

  • Can not get application bc4j for adding context root file

    Hi all,
    Can someone help me on this,
    i got this this error while trying to run my web based reporting:
    06/08/21 18:01:04 [SEVERE]: Error instantiating application at file:/C:/Documents and Settings/Bryan1/Desktop/Pattern Maching JSP 2006Feb/jdevstudio1013/jdev/system/oracle.j2ee.10.1.3.34.12/embedded-oc4j/applications/bc4j.ear: Unable to get ApplicationConfig for bc4j : Error creating deployment directory: IO Error: The system cannot find the path specified.
    06/08/21 18:01:04 [SEVERE]: Error instantiating application at file:/C:/Documents and Settings/Bryan1/Desktop/Pattern Maching JSP May2006/jdevstudio1013/jdev/system/oracle.j2ee.10.1.3.34.12/embedded-oc4j/applications/ITS.ear: Unable to get ApplicationConfig for ITS : Error creating deployment directory: IO Error: The system cannot find the path specified.
    2006-08-21 18:01:07.265 WARNING J2EE_OJR0007 Can not get application bc4j for adding context root file:/C:/Pattern Maching JSP May2006/jdevstudio1013/jdev/system/oracle.j2ee.10.1.3.34.12/embedded-oc4j/config/default-web-site.xml
    Ready message received from Oc4jNotifier.
    Embedded OC4J startup time: 5282 ms.
    Target URL -- http://192.168.2.55:8988/Trans-Reporting-context-root/login.jsp
    06/08/21 18:01:07 Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview initializedIF i run http://192.168.2.55:8080/Reporting/login.jsp from web browser then is ok, but cannot straight run from JDeveloper? How to set the path?
    rgds,
    bryan

    Dear Frank,
    Thanks for ur reply but i still failed to access to my login.jsp
    I already select RUN from menu then clean <XXXX.jpr>, then rebuild the project and Run the project but still have the same problem.
    rgds,
    bryan

  • Sql query o/p into text file using 11g

    i am using 11g. i want to write the result of the query into text file.how to do it

    Hi if you are using SQL*plus then try with SPOOL command or if your are using TOAD then you can export the result of the query into a file of your choice. example Excel cheet or text file.
    just right click on the result in your toad window and there will be a option of export result to a file.

  • Setting Font for converting multiple text files into PDF using VB 6.0

    Dear All,
    Am converting multiple text files into PDF using VB6.0. Currently, am unable to control the font face and size for the generated files. Below is the procedure am using for each file;
    Public Sub proc_convert_to_PDF(srcFilename As String, destFilename As String)
    Dim p_AcroApp As CAcroApp
    Dim p_VDoc As CAcroAVDoc
    Dim p_DDoc As CAcroPDDoc
    Dim IsOk As Boolean
    Set p_AcroApp = CreateObject("AcroExch.App")
    Set p_VDoc = CreateObject("AcroExch.AVDoc")
    Call p_VDoc.Open(srcFilename, "")
    Set p_VDoc = p_AcroApp.GetActiveDoc
    If p_VDoc.IsValid Then
    Set p_DDoc = p_VDoc.GetPDDoc
    ' Fill in pdf properties.
    p_DDoc.SetInfo "Title", Format(Date, "dd-mm-yyy")
    p_DDoc.SetInfo "Subject", srcFilename
    If p_DDoc.Save(1 Or 4 Or 32, destFilename) <> True Then
    MsgBox "Failed to save " & srcFilename
    End If
    p_DDoc.Close
    End If
    'Close the PDF
    p_VDoc.Close True
    p_AcroApp.Exit
    'Clear Variables
    Set p_DDoc = Nothing
    Set p_VDoc = Nothing
    Set p_AcroApp = Nothing
    End Sub
    What I need;
    1) to be able to set the font face of the destination file ( destFilename)
    2) to be able to set the font size of the destination file ( destFilename)
    Am using Adobe Acrobat 7.0 Type Library
    Kindly Help.
    Thanks in advance

    We didn't say it doesn't work. We said it isn't supported.
    There are a number of other ways to make a PDF. The one which would
    give the most control is if your application directly printed to GDI,
    controlling the font directly. This could print to Adobe PDF.
    You could look for an application that gives control of font for
    printing.
    You could use a text-to-PostScript system and distill the result. You
    could even look for a non-Adobe text-to-PDF.
    Working in the unsupported and dangerous world you chose, the font
    size for text conversion is set (and this is very bad design from
    Adobe) in the settings for Create PDF > From Web Page. There is no API
    to this.
    Aandi Inston

  • Extra space adding during spool data into text file

    I'm using sql developer to query oracle tables. I can export data using GUI of sql developer, but I wish to use spool query to export the data. Using below query, I was able to export the data to specified location, but my final text file consist of additional spaces after each line. These additional spaces between each line is causing an error to upload the text file in different location.
    Did any one face have this issue? Below is my query
    set head off
    SET FEEDBACK OFF
    SET ECHO    OFF
    SET TRIMSPOOL ON
    SET TRIMOUT ON
    spool c:\test.txt
    select cast(memberid||',12'as varchar2(20))
    from abc;
    spool off
    set head on
    set ECHO on
    i'm using trimspool, and trimout, but it is not removing any blank spaces.

    Sorry, I changed my export.sql to the query you provided.
    SET HEAD OFF FEED OFF ECHO OFF
    SET LIN 120 PAGES 0 TRIMS ON
    SPOOL c:\test.txt
    SELECT memberid || ',12' FROM abc;
    SPOOL OFF
    But,the spool query is still adding additional spaces making length of each line 43 characters in final text file output.

  • Exporting table data into text files

    I got a request to export the data from about 85 tables into 85 text files. I assume that they will want a header row and some delimiter character. This is a process that must run every night by a sql job.
    Obviously I want it to be flexible. Tables could be addede and removed and columns could be added and removed. There will probably be a control table that has the list of tables to export.
    Looked at bcp - but seems that it is command line only?
    SSIS package?
    What other options are there?

    Wanted to post my solution. Ended up using bcp in a PowerShell Script. I was unable to use bcp in SQL because it requires xp_cmdshell and that is not allowed at many of our client sites. So wrote a Powershell script that executes bcp. The ps script
    loops through a table that contains a row for each table/view to export along with many values and switches for the table/view export: export path, include column headers, enclose each field in double quotes, double up embedded double quotes, how to format
    dates, what to return for NULL integers - basically the stuff that is not flexible in bcp. To get this flexibility I created a SQL proc that takes these values as input and creates a view. Then the PS bcp does a SELECT on the view. Many of my tables are
    very wide and bcp has a limit of 4000/8000. Some of my SELECT statements ended up being GT 35k in length. So using a view got around this size limitation.
    Anyway, the view creation and bcp download is really fast. It can download about 4 gb of data in 20 minutes. It can download it faster the 7z can zip it.
    Below is the SQL proc to format the SELECT statement to create the view for bcp (or some other utility like SQLCMD, Invoke-SQLCMD) or SQL query by "SELECT * from v_ExportData". the proc can be used from SQL or PS, or anything that can call a SQL
    Proc and then read a SQL view.
    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExportTablesCreateView]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[ExportTablesCreateView]
    GO
    CREATE PROCEDURE [dbo].[ExportTablesCreateView]
    ExportTablesCreateView
    Description:
    Read in a tablename or viewname with parameters and create a view v_ExportTable of the
    data. The view will typically be read by bcp to download SQL table data to flat files.
    bcp does not have the options to include column headers, include fields in double quotes,
    format dates or use '0' for integer NULLS. Also, bcp has a limit of varhar 4000 and
    wider tables could not be directly called by bcp. So create the v_ExportTable and have
    bcp SELECT v_ExportTable instead of the original table or view.
    Parameters:
    @pTableName VARCHAR(128) - table or view to create v_ExportTable from
    @pColumnHeader INT =1 - include column headers in the first row
    @pDoubleQuoteFields INT = 1 - put double quotes " around all column values including column headers
    @pDouble_EmbeddedDoubleQuotes INT = 1 - This is usually used with @pDoubleQuoteFields INT = 1. 'ab"c"d would be 'ab""c""d.
    @pNumNULLValue VARCHAR(1) = '0' - NULL number data types will export this value instead of bcp default of ''
    @pDateTimeFormat INT = 121 - DateTime data types will use this format value
    Example:
    EXEC ExportTablesCreateView 'custname', 1, 1, 1, '0', 121
    @pTableName VARCHAR(128),
    @pColumnHeader INT = 1,
    @pDoubleQuoteFields INT = 1,
    @pDouble_EmbeddedDoubleQuotes INT = 1,
    @pNumNULLValue VARCHAR(1) = '0',
    @pDateTimeFormat INT = 121
    AS
    BEGIN
    DECLARE @columnname varchar(128)
    DECLARE @columnsize int
    DECLARE @data_type varchar(128)
    DECLARE @HeaderRow nvarchar(max)
    DECLARE @ColumnSelect nvarchar(max)
    DECLARE @SQLSelect nvarchar(max)
    DECLARE @SQLCommand nvarchar(max)
    DECLARE @ReturnCode INT
    DECLARE @Note VARCHAR(500)
    DECLARE db_cursor CURSOR FOR
    SELECT COLUMN_NAME, ISNULL(Character_maximum_length,0), Data_type
    FROM [INFORMATION_SCHEMA].[COLUMNS]
    WHERE TABLE_NAME = @pTableName AND TABLE_SCHEMA='dbo'
    OPEN db_cursor
    FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_type
    SET @HeaderRow = ''
    SET @ColumnSelect = ''
    -- Loop through each of the @pTableColumns to build the SELECT Statement
    WHILE @@FETCH_STATUS = 0
    BEGIN
    BEGIN TRY
    -- Put double quotes around each field - example "MARIA","SHARAPOVA"
    IF @pDoubleQuoteFields = 1
    BEGIN
    -- Include column headers in the first row - example "FirstName","LastName"
    IF @pColumnHeader = 1
    SET @HeaderRow = @HeaderRow + '''"' + @ColumnName + '"'' as ''' + @columnname + ''','
    -- Unsupported Export data type returns "" - example "",
    IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
    SET @ColumnSelect = @ColumnSelect + '''""'' as [' + @ColumnName + '],'
    -- Format DateTime data types according to input parameter
    ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2', 'date', 'datetimeoffset')
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE QUOTENAME(CONVERT(VARCHAR,[aaa], 121), CHAR(34)) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''""'' ELSE QUOTENAME(CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + '), CHAR(34)) END AS [' + @ColumnName + '],'
    -- SET Numeric data types with NULL value according to input parameter
    ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
    -- example - CASE when [aaa] IS NULL THEN '"0"' ELSE QUOTENAME([aaa], CHAR(34)) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''"' + @pNumNULLValue + '"'' ELSE QUOTENAME([' + @columnname + '], CHAR(34)) END AS [' + @ColumnName + '],'
    ELSE
    -- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
    IF @pDouble_EmbeddedDoubleQuotes = 1
    BEGIN
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + REPLACE([aaa],'"','""') + '"' END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + REPLACE([' + @ColumnName + '],''"'',''""'') + ''"'' END AS [' + @ColumnName + '],'
    END
    -- DO NOT PUT Double embedded double quotes - example "abc"d"ed" unchanged to "abc"d"ed"
    ELSE
    BEGIN
    -- example - CASE when [aaa] IS NULL THEN '""' ELSE '"' + [aaa] + '"' END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @ColumnName + '] IS NULL THEN ''""'' ELSE ''"'' + [' + @ColumnName + '] + ''"'' END AS [' + @ColumnName + '],'
    END
    END
    -- DO NOT PUT double quotes around each field - example MARIA,SHARAPOVA
    ELSE
    BEGIN
    -- Include column headers in the first row - example "FirstName","LastName"
    IF @pColumnHeader = 1
    SET @HeaderRow = @HeaderRow + '''' + @ColumnName + ''' as ''' + @columnname + ''','
    -- Unsupported Export data type returns '' - example '',
    IF @Data_Type in ('image', 'varbinary', 'binary', 'timestamp', 'cursor', 'hierarchyid', 'sql_variant', 'xml', 'table', 'spatial Types')
    SET @ColumnSelect = @ColumnSelect + ''''' as [' + @ColumnName + '],'
    -- Format DateTime data types according to input parameter
    ELSE IF @Data_Type in ('datetime', 'smalldatetime', 'datetime2','date', 'datetimeoffset')
    -- example - CASE when [aaa] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[aaa], 121) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + '],' + CONVERT(VARCHAR,@pDateTimeFormat) + ') END AS [' + @ColumnName + '],'
    -- SET Numeric data types with NULL value according to input parameter
    ELSE IF @Data_Type in ('bigint', 'numeric', 'bit', 'smallint', 'decimal', 'smallmoney', 'int', 'tinyint', 'money', 'float', 'real')
    -- example - CASE when [aaa] IS NULL THEN '"0"' ELSE CONVERT(VARCHAR, [aaa]) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN ''' + @pNumNULLValue + ''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
    ELSE
    BEGIN
    -- Double embedded double quotes - example "abc"d"ed" to "abc""d""ed". Only applicible for character data types.
    IF @pDouble_EmbeddedDoubleQuotes = 1
    -- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,REPLACE([aaa],'"','""')) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,REPLACE([' + @columnname + '],''"'',''""'')) END AS [' + @ColumnName + '],'
    ELSE
    -- example - CASE when [aaa] IS NULL THEN '' ELSE CONVERT(VARCHAR,[aaa]) END AS [aaa],
    SET @ColumnSelect = @ColumnSelect + 'CASE WHEN [' + @columnname + '] IS NULL THEN '''' ELSE CONVERT(VARCHAR,[' + @columnname + ']) END AS [' + @ColumnName + '],'
    END
    END
    FETCH NEXT FROM db_cursor INTO @ColumnName, @ColumnSize, @Data_Type
    END TRY
    BEGIN CATCH
    RETURN (1)
    END CATCH
    END
    CLOSE db_cursor
    DEALLOCATE db_cursor
    BEGIN TRY
    -- remove last comma
    IF @pColumnHeader = 1
    SET @HeaderRow = SUBSTRING(@HeaderRow , 1, LEN(@HeaderRow ) - 1)
    SET @ColumnSelect = SUBSTRING(@ColumnSelect, 1, LEN(@ColumnSelect) - 1)
    -- Put on the finishing touches on the SELECT
    IF @pColumnHeader = 1
    SET @SQLSelect = 'SELECT ' + @HeaderRow + ' UNION ALL ' +
    'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
    ELSE
    SET @SQLSelect = 'SELECT ' + @ColumnSelect + ' FROM [' + @pTableName + ']'
    ---- diagnostics
    ---- PRINT truncates at 4k or 8k, not sure, my tables have many colummns
    --PRINT @SQLSelect
    --DECLARE @END varchar(max) = RIGHT(@SQLSelect, 3000)
    --PRINT @end
    --EXECUTE sp_executesql @SQLSelect
    -- drop view if exists -- using view because some tables are very wide. one of my tables had a 33k select statement
    SET @SQLCommand = '
    IF EXISTS (SELECT * FROM SYS.views WHERE name = ''v_ExportTable'')
    BEGIN
    DROP VIEW v_ExportTable
    END'
    EXECUTE @ReturnCode = sp_executesql @SQLCommand
    IF @returncode = 1
    BEGIN
    RETURN (1)
    END
    -- create the view
    SET @SQLCommand = '
    CREATE VIEW v_ExportTable AS ' + @SQLSelect
    -- diagnostics
    --print @sqlcommand
    EXECUTE @ReturnCode = sp_executesql @SQLCommand
    IF @returncode = 1
    BEGIN
    RETURN (1)
    END
    END TRY
    BEGIN CATCH
    RETURN (1)
    END CATCH
    RETURN (0)
    END -- CREATE PROCEDURE [dbo].[ExportTablesCreateView]
    GO

  • VBScript for parsing multiple text files

    Hi,
    I have around 175 text files that contain inventory information that I am trying to parse into an Excel file. We are upgrading our Office platform from 2003 to 2010 and my boss wants to know which machines will have trouble supporting it. I found a script
    that will parse a single text file based upon ":" as the delimiter and I'm having trouble figuring out how to change it to open an entire folder of text files and write all of the data to a single Excel spreadsheet. Here is an example of the text
    file I'll be parsing. I'm interested in the "Memory and Processor Information" and "Disk Drive Information" sections mainly.
    ABEHRENS-XP Computer Inventory
    OS Information
    OS Details
    Caption: Microsoft Windows XP Professional
    Description:
    InstallDate: 20070404123855.000000-240
    Name: Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddisk0\Partition1
    Organization: Your Mom
    OSProductSuite:
    RegisteredUser: Bob
    SerialNumber: 55274-640-3763826-23029
    ServicePackMajorVersion: 3
    ServicePackMinorVersion: 0
    Version: 5.1.2600
    WindowsDirectory: C:\WINDOWS
    Memory and Processor Information
    504MB Total memory HOW CAN I PULL THIS WITHOUT ":" ALSO
    Computer Model: HP d330 uT(DG291A)
    Processor:               Intel(R) Pentium(R) 4 CPU 2.66GHz
    Disk Drive Information
    27712MB Free Disk Space ANY WAY TO PULL THIS WITHOUT ":"
    38162MB Total Disk Space
    Installed Software
    Here is the start of the script I have so far. . .
    Const ForReading = 1
    Set objDict = CreateObject("Scripting.Dictionary")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile("C:\Test\test.txt" ,ForReading)
    WANT THIS TO BE C:\Test
    Do Until objTextFile.AtEndOfStream
    strLine = objTextFile.ReadLine
    If Instr(strLine,":") Then
    arrSplit = Split(strLine,":") IS ":" THE BEST DELIMITER TO USE?
    strField = arrSplit(0)
    strValue = arrSplit(1)
    If Not objDict.Exists(strField) Then
    objDict.Add strField,strValue
    Else
    objDict.Item(strField) = objDict.Item(strField) & "||" & strValue
    End If
    End If
    Loop
    objTextFile.Close
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    objExcel.Workbooks.Add
    intColumn = 1
    For Each strItem In objDict.Keys
    objExcel.Cells(1,intColumn) = strItem
    intColumn = intColumn + 1
    Next
    intColumn = 1
    For Each strItem In objDict.Items
    arrValues = Split(strItem,"||")
    intRow = 1
    For Each strValue In arrValues
    intRow = intRow + 1
    objExcel.Cells(intRow,intColumn) = strValue
    Next
    intColumn = intColumn + 1
    Next
    Thank you for any help.

    You are The Bomb.com! I had to play around with it to pull some additional data (model and processor) and then write a quick macro to remove the unwanted text and finally I wanted the data to write in columns instead of rows so this is what I ended up with:
    Option Explicit
    Dim objFSO, objFolder, strFolder, objFile
    Dim objReadFile, strLine, objExcel, objSheet
    Dim intCol, strExcelPath
    Const ForReading = 1
    strFolder = "c:\Test"
    strExcelPath = "c:\Test\Inventory.xlsx"
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Workbooks.Add
    Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
    intCol = 0
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strFolder)
    For Each objFile In objFolder.Files
      intCol = intCol + 1
      Set objReadFile = objFSO.OpenTextFile(objFile.Path, ForReading)
      Do Until objReadFile.AtEndOfStream
        strLine = objReadFile.ReadLine
        If (InStr(strLine, "Computer Inventory") > 0) Then
          objSheet.Cells(intCol, 1).Value = Left(strLine, InStr(strLine, "Computer Inventory") - 2)
        End If
        If (InStr(strLine, "Total memory") > 0) Then
          objSheet.Cells(intCol, 2).Value = Left(strLine, InStr(strLine, "Total memory") - 2)
        End If
        If (InStr(strLine, "Computer Model:") > 0) Then
          objSheet.Cells(intCol, 3).Value = (strLine)
        End If
        If (InStr(strLine, "Processor:") > 0) Then
          objSheet.Cells(intCol, 4).Value = (strLine)
        End If
        If (InStr(strLine, "Total Disk Space") > 0) Then
          objSheet.Cells(intCol, 5).Value = Left(strLine, InStr(strLine, "Total Disk Space") - 2)
        End If
        If (InStr(strLine, "Free Disk Space") > 0) Then
          objSheet.Cells(intCol, 6).Value = Left(strLine, InStr(strLine, "Free Disk Space") - 2)
        End If
      Loop
    Next
    objExcel.ActiveWorkbook.SaveAs strExcelPath
    objExcel.ActiveWorkbook.Close
    objExcel.Quit
    Thanks again!
    Hi ,
    I am have very basic knowledge about VB scripting, but this code could be the perfect solution i am looking for. could you guide me exactly how to run and test the same , i would be really thankful for your kind and generous support on this.
    Thanks ,
    Veer

  • 'FROM keyword not found where expected'error while Inserting into Text file

    Hi,
    I have created a simple interface for testing purpose. All it has to do is to Read the data from a Source Text file and put it into another text file (exactly the same headers as that of source) ...
    I am using Oracle as my staging area.
    But at 'Insert column Header' Stage, it gives me a warning 'FROM keyword not found where expected' and when it goes to the next step 'Insert Rows' it gives me the same error 'FROM keyword not found where expected' and aborts its execution.
    I checked the query for insertion and found nothing wrong in it (FROM Statement is just where it is expected, that is) but somehow its not working.
    Can somebody help me out as i have done it before on other Installations and dont know why it is occuring that too for the simplest thing in ODI ...
    Regards,
    Nitesh.

    Probably you missed the concat operator.
    select rpad(nvl(lu_parid,' '),1,19)|| v_comma ||
    rpad(nvl(lu_class,' '),1,3)
    from temp_te07                                                                                                                                                                                                                                                                                                           

  • Export data into text file

    Hi all,
    I want to export table data into a delimeted text file with SQL*Plus.
    [edit]
    Sorry, non delimited text file
    [edit]
    Example:
    CREATE TABLE delim (
    col_a VARCHAR2(20),
    col_b VARCHAR2(40)
    value stored in
    col_a = FISH_1
    col_b = FISH_2
    spool x:\test_1.lst
    set feedback off;
    set HEADING off;
    set pagesize 0;
    set linesize 60;
    select col_a, col_b
    from table delim;
    spool off;
    =>
    FISH_1
    FISH_2
    When I now do the same with
    set linesize 62;
    the reslut is like this
    =>
    FISH_1 FISH_2
    In the output of the second example there is a blank between col_a and col_b.
    I have to export the column data without this one blank between columns.
    Is there any way to do this?
    Thanks and cheers,
    ben
    Message was edited by:
    ben512

    Well in your example there is one space between the two columns, anyway you can see in my previous example that there is a set colsep and that show what you want.
    But here is another example:
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> create table test (
      2  col_a VARCHAR2(5),
      3  col_b VARCHAR2(3)
      4  );
    Table created.
    SQL>
    SQL> insert into test (col_a, col_b)
      2  values('abc', 'FA');
    1 row created.
    SQL>
    SQL> insert into test (col_a, col_b)
      2  values('def', 'KL');
    1 row created.
    SQL> insert into test values ('12345','123');
    1 row created.
    SQL> rem if you don't want to have a space between the two columns then
    SQL> set head off
    SQL> set colsep ""
    SQL> select col_a, col_b from test;
    abc  FA
    def  KL
    12345123
    SQL> rem if you want to have one space between the two columns then
    SQL> set colsep " "
    SQL> select col_a, col_b from test;
    abc   FA
    def   KL
    12345 123
    SQL>

Maybe you are looking for

  • Not display main window of page

    Hi, My requiremnet is ,i want to display each sales order number in each page in layout.when am giving the input two sales orders, the first sales order (0001)dispaly its header and item details in main window finely but in second page it disaply the

  • Saving text messages and pictures when resetting

    I want to reset my iPhone to factory default because one of my buddies jailbroke it and I hate the jailbroken version. It's slow and annoying. Is there a way for me to save all of my text messages and pictures, reset the phone to factory default, and

  • Access point confusion

    Hey thanks! So is each access point connected to a cable, but just from behind the device if it's not daisy chained? I guess this is the most confusing to me. Sorry to be a pain! ha

  • Wine for Arch Linux? [SOLVED]

    I used sudo pacman -S wine. It said target not found. Is this not in the AUR or something? There is no download option from the wine website. I read some people were able to get Assassins creed to run normally with wine, so I wanted to try it out. La

  • What happened with Vi(m)?

    Today i made a 'pacman -Syu', cause the last time i did this was 3 month before. So it also updates Vim... i could not manage to edit to edit a file yet. There's simply no 'insert mode' when pressing 'i' anymore and navigating with arrowcursors ends