Maintaining SQL Queries in a separate text file

Hi,
I am working on web based project using Spring MVC framework and I am maintaining all SQL queries in a separate text file so that I can change them any time when needed. I just want to know am I doing right, it this a optmistict way of coding??

>
I am working on web based project using Spring MVC framework and I am maintaining all SQL queries in a separate text file so that I can change them any time when needed. I just want to know am I doing right, it this a optmistict way of coding??
>
The best place to store the queries, and HOW to store them depends on your architecture and on how your application is being used.
Is this a single-user application on a user's pc? Or is your application located on an application server in the middle-tier?
The queries should be stored where they will be used. Your queries should be stored in the tier where your application code will reside. On the client PC for a single-user app, on the application server for a 3-tier app and incorporated into stored procedures/functions/packages if part of a database app.
If your application is totally external to the database (e.g. a reporting app) then it doesn't make sense for you to become part of the database architecture. An org isn't going to let you create objects in the database to store your queries when your queries are not part of the database application. That puts the burden on them to backup your objects, restore them for your and provide support to you and your application.
What format to store the queries in is a different issue. A major criteria is the type of queries you are using and how they are used. Many apps that query the database cannot just use hard-coded queries that are never modified. Users need to be able to provide parameters (e.g. name, ID, state, etc) to select just the data that they want.
That means the base query itself may not even be valid syntax but needs to have a WHERE clause added. Prepared statements and queries that use bind variables ('WHERE ID = ?') are typically used for these.
One method of storage is to use Java property files that use name=value pairs. Using property files makes it easy to use Java to find a query by name and load it for you. Then your code would have functionality to modify the query to provide the parameter 'bind' values and execute it.
There are also frameworks available for handling database related functionality. There is no need for you to write your own libraries for this. I suggest you locate a suitable framework to use.

Similar Messages

  • How can I use sql loader to load a text file into a table

    Hi, I need to load a text file that has records on lines tab delimited into a table. How would I be able to use the sql loader to do this? I am using korn shell to do this. I am very new at this...so any kind of helpful examples or documentation would be very appreciated. I would love to see some examples to help me understand if possible. I need help! Thanks alot!

    You should check out the documentation on SQL*Loader in the online Oracle document titled Utilities. Here's a link to the 9iR2 version of it: http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96652/part2.htm#436160
    Hope this helps.

  • Want to change the SQL Server Agent Job History Text Files Location

    We have SQL Server 2014 installed on a couple servers, but they were not consistent on directory paths during the installs. I am trying to get the servers to all match.
    On one server, SQL Server the Agent Log and Job History files were being written to [H:\Data Root Directory\MSSQL12.MSSQLSERVER\MSSQL\Log].
    I want to change that to [H:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log] to match the other server.
    I have ALREADY gone into SSMS - [SQL Server Agent] - [Properties] and changed the "Error Log " "Fle Name" to [H:\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log\SQLAGENT.OUT].  And that is working great.
    In [SQL Server Configuration Manager] - [SQL Server (MSSQLSERVER)] - [Properties] - Startup Parameters entries have been changed to the new path (-d, -e, and -l), and under [Advanced] both Data Path and Dump Directory are pointing to the new path. 
    In [SQL Server Configuration Manager] - [SQL Server Agent (MSSQLSERVER)] - [Properties] - [Advanced] Dump Directory is pointing to the new path. 
    However, the job's History text files are still being written to the old path.
    There is no setting in the Jobs or the Maintenance Plans that controls the history file location.
    I have searched the registry and changed three settings from the old path to the new path.  The registry does NOT contain any more references to the old path.
    I rebooted the server, but when the jobs run their history text files are still be written to the old path.
    Does anybody have any ideas??   Thanks

    I checked the [Job] - [Step] - [Advanced ] - "Output File", and the field is blank.
    I then reviewed all the tabs and left menu items in the Job...I cannot find any where the references the old path.
    I then went to the Maintenance Plan and checked every thing there.  Still cannot find what is referencing this old path.
    SQL Server is also still writing xel files to this old path...if that offers any clues.
    The text file being generated is the recap of the Job run.  Starts with this:
    Microsoft(R) Server Maintenance Utility (Unicode) Version 12.0.2430
    Report was generated on "xxxxxxxxxxxxxxx".
    Maintenance Plan: SQL_Backups_Log
    Duration: 00:00:03
    Status: Succeeded.
    Details:
    Thanks for the ideas....

  • 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.

  • How to Save SQL query template as a text file

    Hi,
    How to save a SQL query template in my server as a Text file?? I tried using Text saver but it is not getting saved in the path specified.
    Sweety

    Hi Sweety,
    In the transaction editor (for business logic), add your query template to a transaction.  Add a Tracer after and link the Query property of the SQL Query action block to the Message property of the transaction.  Run the transaction and you will see your Action Block's sql script as the message from the Tracer.  You can do the same with the Server property, SD and ED, etc.
    Also if you wish to dynamically load the sql script into the query, you can do that at run time by linking a script source to the query property.  Useful to have if you have to use a complex expression to dynamically create your script.  This sometimes occurs when you have multiple filtering inputs from a webpage and you can reduce the number of tables in a complex join when the fields are left empty.  Normally this would be done as a way to improve the performance of the query.
    Hopefully this is clear.  If not I can probably provide some sample expressions.
    Regards,
    Mike

  • Can a ring control be populated using a separate text file when VI loads (not running)?

    I would like to know if there is a way to populate a ring or enum control list using values maintained in a text file (or other format) outside of a VI.  I have to be able to call this VI from TestStand or LabVIEW, and would like to be able to use the drop down interface to pick from the list of selections.  As a result, the ring or enum list would need to be updated before the VI runs.  I want to avoid just using a string to prevent typo's from creating errors.  There would be several different VI's getting the list values from this text file.  Is this possible, or am I way off base?  Or does anyone have any other ideas or suggestions?
    Thanks everyone,
    q.

    Thanks for the replies.  I had a chance to play with ring controls and updating the string array dynamically.
    However, as I mentioned in my first post, one of the reasons I want to use dynamically updated lists is to have a readable drop down list in TestStand when you configure a step (i.e. Specify Module).  This would help serve as a part of a hardware abstraction layer, and for maintainability purposes we don't want to split the hardware map among a number of VI's.
    Unfortunately, TestStand doesn't seem to recognize the string list from a ring control.  And as mentioned above, there are issues with updating Enums.  Is it possible to accomplish a way of dynamically populating this list in such a way that TestStand will recognize it?  Is there another control that would work better (e.g. list boxes, combo boxes, etc.)?
    Thanks for your help,
    q

  • How to load data to a SQL Server 2000 from a text file ( fixed / delimited)

    I am a navie user to ODI, just installed some time back. And I wanted to load text data ina file ( fixed length/ delimited ) to SQL server 2000 database.
    Iam intrested to know the steps I need to take to achieve this. I mean for example first creating topology,next designer..
    Could you please provide some books/articles or any documents that talt about these steps clearly one-by-one.

    Hi,
    Oracle Data Integrator - Getting Started with an ETL Project
    follow this manuel step by step and you will be able to load data from file to any database...

  • Want to execute SQL Queries from Textfile

    I have a text file full of a bunch of sql queries, of the format:
    select something1, something2
    from someplace
    select something3, something4
    from someplace2
    select something5, something6
    from someplace3
    I want to execute these queries one at a time and then after each one executes, I will do something with the resultset. Question is, how do I pull each query from the text file one at a time and execute? I was doing this by using java.util.Scanner and java.lang.StringBuilder where I would scan one line at a time and then check to see if the line is empty, otherwise I append the line to the StringBuilder. If the line is empty, I process whatever is stored in the StringBuilder. The problem with doing this is that it does not preserve the newline from the text file, so I get queries that look like:
    "select something5, something6from someplace3"
    which of course are invalid. Does anyone know a better way to build SQL queries / statements from a text file? How do I get the newline or carriage return character?

    Just replace newline by space?

  • Urgent: Mailing text files

    I have currently written a stored procedure which calculates
    bills and saves them in a separate text file for each
    user/customer. I want to automatically mail them to each user.
    Their email address will be stored in the database. Can any one
    help me in generating automatic mails thru stored procedures....
    null

    Unfortunately .. there is no direct way through PL/SQL
    One work around if you have a Unix server.
    I guess you have used PL/SQL File I/O UTL_FILE package to create
    the file.
    You will need to script something on the server..
    Eg. First line of every file .. send in the email id
    [email protected]
    line1
    line2..
    Write a script which reads the first line and gets the email
    and then using unix mail command it will work.
    Adil Sameer (guest) wrote:
    : I have currently written a stored procedure which calculates
    : bills and saves them in a separate text file for each
    : user/customer. I want to automatically mail them to each user.
    : Their email address will be stored in the database. Can any
    one
    : help me in generating automatic mails thru stored
    procedures....
    null

  • SSIS none text qualifier results in text file containing "_x003C_none_x003E"

    There is a bug in SSIS when exporting data from SQL to a comma delimited text file where you specified no text qualifier.
    This bug apparently only occurs when you develop the SSIS on a x64 win7 PC and copy the .dtsx file (windows explorer copy/paste) to network path of a x86 SQL server and schedule the job to run from SQL Agent on the same x86 SQL server.
    When the SSIS runs, the text file is written out containing text qualifier = "“_x003C_none_x003E".
    If you look at "
    _x003C_none_x003E", it actually means <none>.  x003C = "<" and x003E = ">".
    If you go into the SSIS package, double-click in the connection manager section to open the flat file connection manager editor and try to clear the text qualifier removing the <none>,
    the <none> value get added back in.
    The only work-around is to NOT open the
    flat file connection manager editor, but instead make the change using the property window and clear out any value in the TextQualifier field.
    Other similar problems occur when you actually want to put a real value in the text qualifier.  For explain if you select the double-quote as the text qualifier and copy to a
    x86 server and run, you end up with a text file containing the value "
    _x0022" around each field instead of a double quote.
    In my mind this is a serious bug, I did some research and other people have been having this same issue.
    FYI, the SQL server is currently SQL2008 with SP2.  I will try to get it updated to SP3/4 this weekend to see that will help.
    FYI2, when I am developing the SSIS using VS2008 and my local test/run is done through visual studio on my Dev PC (x64).  Everything works fine this way.  I do not have a instance of SQL on my machine so I did not test it running from SQL Agent
    on my PC.

    Todd,
    Sorry to revive an older post, but we are currently running into this problem...again, but this is happening on SQL Server 2008 R2 SSIS servers and the corresponding developer machines.
    Everything that I'm finding in forums and blogs pretty much points that this is an issue with build mismatches (i.e. one system not being caught up to the server while others are), but I have yet to find anything that really outlines how to properly rectify
    the situation and prevent it from happening going forward.
    Currently all but our production server (from a server perspective) are exactly the same version numbers (same CU applied).
    I can't really speak to all of the developer boxes, but mine matches all but the production server (production is showing a lower number than the expected 10.50.2500.0).
    As shown below, what is really odd is the second entry and last entry.  Second entry is showing SP1 as the generic identifier, but yet shows Build 7600.
    The bottom one shows RTM in the generic identifier, but yet shows Build 7601 Service Pack 1, and the version number isn't the expected 10.50.2500.0.
    SQL Server Version
    Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03     Standard Edition (64-bit)
    on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
    Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03     Standard Edition (64-bit)
    on Windows NT 6.1 <X64> (Build 7600: ) (Hypervisor)
    Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03     Standard Edition (64-bit)
    on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
    Microsoft SQL Server 2008 R2 (RTM) - 10.50.1617.0 (X64)   Apr 22 2011 19:23:43     Standard Edition (64-bit)
    on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

  • Exporting Playlist as text file

    Hi i want to Export my Playlist as text file listing, and send to a friend by email.
    In other words i want to send a list of all my albums in itunes in list form. (not all the songs)
    This should be simple enough, but i have wasted hours trying to do it.
    Hope you can help.
    DUAL 1ghz / 300GB / 1.75 GB DDR SDram   Mac OS X (10.4.4)  

    Hi there,
    I'm confused. You want to export each Playlist as a text file? Or you want to export each individual album in your iTunes library as a separate text file?
    For the former - converting a Playlist into a text file - you could do the following. If there is a faster more streamlined way, I don't know it.
    1. While viewing your playlist in iTunes, make sure only the columns you want in your text file are showing. (Remove columns by right-clicking on the header bar.)
    2. Select all songs (Command-A) then right-click and select "Copy."
    3. Open Notepad or, even better, Excel or some other spreadsheet software and Paste. The information is tab-delimited, so if you put it into a spreadsheet it automatically puts each item of information in its own column.
    You could also just select all the songs in your library, sorted by album, then Copy and Paste into a spreadsheet. Then you could sort the spreadsheet according to album name or whatever and get rid of columns (song name, genre, etc) as you see fit. And, although I wouldn't necessarily recommend it, I'm sure there's some third-party software that will convert your playlists to text or spreadsheets or whatever. Hope this helps...
    PowerPC Mac Mini G4 1.2Ghz   Mac OS X (10.3.9)   512MB RAM . 80GB HD . AirPort . Wired Keyboard / Mouse

  • Query Output Into a Text File

    Hello Experts,
    There is a situation where i need ur help.My query is :
    Can I export the output of more than one queries into a * Single Text File * ?
    Also can it be possible to automate these Queries Output to export into the Text File ??
    I also want this Text File Output to mail the end users by using the Process Chain. So is this possible to create a process chain for sending this Text File to the Users via mail ??
    Thanks In Advance
    Neha

    Hello Neha,
    Though i have been working with APDs since some time. But havent actually been involved in designing one. But you could find many documents for the APD on web. And as far as i know, you will need a program to save file from APD.
    I have a document which explains how you can use APD in  process chain. can forward you the same if you want.
    I am sorry as i wasnt of much help for you, as i havent worked on similar requirement before, but this thing just striked in my mind.
    Regards,
    Anuj

  • MDX output to text file

    I have an MDX query embedded in a MaxL script. I want the query to output to a text file on my Unix server. I have tried using the MaxL spool command, but it outputs STDOUT, not just the output from the MDX. I want the MDX results set and only the MDX results set in a separate text file. There has got to be a way to do this, right? I'm trying to use MDX instead of a report script for extracting data from one essbase cube and loading it into another.<BR><BR>Any help is appreciated,<BR><BR>James

    ok so i'm a bit new to flash, any help would be much appreciated as i've never used the save method.
    i've got the boolean variable: flag,
    and i want to output it's value to a text file when i press the taketheticket button:
    this is was i have so far
    function taketheticket(event:MouseEvent):void
                        trace("the change is " + flag);
                        gotoAndStop(8);

  • Scheduling multiple tab BO XI3 report needs to save into multiple text file

    Hi,
    I have BO XI 3 Desktop Intelligence reports, those reports contains multiple tabs. Once after scheduling these reports the output needs to save as different text files (each tab as separate text file). Generally when select output as text file we will get the text file with the data of current tab, but in this scenario I want all the tabs data into different text files. I guess we can do this with macro. But I am not good in macro development, hope somebody can help me.
    Could you please help out for the same!
    Thanks,
    Rama

    Thanks Dan.. I made chenges in code as per your suggestion.. its working fine in DeskI -> local PC
    But this is not working in InfoView level... when i scheduled the same report its not saving into multiple text files... can you please have look...
    macro code as follows:-
    Public Sub SaveAsText()
    Dim StrTxtPath As String
    Dim BusDoc As busobj.Document
    Set BusDoc = ThisDocument
    Dim BusRep As Report
    Dim I As Integer
    On Error GoTo ErrHandler
    'StrTxtPath = "
    xxxx.xxx.xxx.com\common\Reporting\"
    StrTxtPath = "D:\Business Objects\Test_Macro\"
    For I = 1 To BusDoc.Reports.Count
    Set BusRep = BusDoc.Reports.Item(I)
    BusRep.ExportAsText (StrTxtPath & BusRep.Name)
    Next I
    ErrHandler:
    Exit Sub
    End Sub
    When i run this macro through DeskI.. its saving the report as multiple .txt files with respective number of tabs... but the same thing is not working when i tried in scheduling...
    Can you please suggest me what are the changes needs to be done...
    Thanks in Advance
    Thanks,
    Rama

  • Index items to text file

    Hi scripters,
    I have index entries in my indesign file. I want to save the index text into separate text file.
    How I can do this?
    thanks in advance
    regards
    a r u l

    What do you mean by "the index text"? The result of running the index? Or the contents of the entries in some kind of form?
    The former is easy: run the index, export the index story.
    The latter is more challenging, but still do-able.
    Dave

Maybe you are looking for

  • Songs purchased showing in ITUNES and not in windows

    Thank you in advance for any help. I can not locate the files for the songs that I purchased, therefore when I click on the song in my "purchased" file, I get the exclamation point to the left and an error comes up telling me it can not play it becau

  • Reset during installation

    Hello, I am attempting to install Solaris 9 on this system: SuperMicro P4DPR-8G2+ Motherboard Dual 2.2 GHz Xeon Processor Seagate 37 GB SCA HD The Solaris installer appears to identify my system as having a Adeptec AIC-7896 SCSI controller, but the m

  • I can't open pdf with adobe reader

    I had to download Adobe reader to open a PDF. Now I can't open the PDF and get a message that I must accept Adobe conditions forst which I did when installing it. I notice that it is a problem across different platforms all with Adobe reader. Any sol

  • Trying to cancel my membership..need a customer service phone number

    trying to cancel my membership..need a customer service phone number

  • Photoshop CS3 with Epson Stylus Photo 1400 and Mac Leopard

    I have Adobe Photoshop CS3 and an Epson Stylus PHOTO 1400 printer and Mac OS X 10.5.4. When I print a photo it comes out with excessive ink which smears very easily and has lines in it. It only does it in Photoshop. When I print from any other progra