Help needed in SQL performance - Using CASE in SQL statement versus 2 query

Hi,
I have a requirement to find count from a bunch of tables.
The SQL I have gives the count of all members.
I have created 2 queries to find count of active and inactive members.
The key difference is only the active dates.
Each query takes 20 seconds to execute.
I modified the SQL to use CASE statement in the SELECT.
So after the data is fetched the CASE statement will evaluate the active date and gives 2 counts (active and inactive)
Is it advisable to use this approach. Will CASE improve SQL performance ? I have to justify this.
Please let me know your thoughts.
Thanks,
J

Hi,
If it can be done in single SQL do it in single SQL.
You said:
Will CASE improve SQL performance There can be both cases to prove if the performance is better or worse.
In your case you should tell us how it is.
Regards,
Bhushan

Similar Messages

  • Urgent help needed for XML Tags using XMLForest()

    Folks
    I need some urgent help regarding getting use defined tag in your
    XML output.
    For this I am using XMLElement and XMLForest which seems to work fine
    when used at the SQL prompt but when used in a procedure throws and error
    SQL> Select SYS_XMLAGG(XMLElement("SDI",
                                       XMLForest(sdi_num)))
         From sdi
         where sdi_num = 22261;- WORKS FINE
    But when used in a procedure,doesnt seem to work
    Declare
        queryCtx  DBMS_XMLQuery.ctxType;
        v_xml     VARCHAR2(32767);
        v_xmlClob CLOB;
        BEGIN
        v_xml:='Select SYS_XMLAGG(XMLElement("SDI",
                                             XMLFOREST(sdi_num)))
        From sdi
        where sdi_num = 22261';
        queryCtx :=DBMS_XMLQuery.newContext(v_xml);
        v_xmlClob :=DBMS_XMLQuery.getXML(queryCtx);
        display_xml(v_xmlClob);
    End;
    CREATE OR REPLACE PROCEDURE  display_xml(result IN OUT NOCOPY CLOB)
    AS
         xmlstr varchar2(32767);
         line varchar2(2000);
    BEGIN
         xmlstr:=dbms_lob.SUBSTR(result,32767);
         LOOP
         EXIT WHEN xmlstr is null;
         line :=substr(xmlstr,1,instr(xmlstr,chr(10))-1);
         dbms_output.put_line('.'||line);
         xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
         END LOOP;
    end;
    SQL> /
    .<?xml version = '1.0'?>
    .<ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an
    XML tag name.</ERROR>
    PL/SQL procedure successfully completed.
    SQL>HELP is appreciated as to where I am going wrong?

    Hi,
    if you want to transform something to something else, you should declare, what is your source.
    I would prefer to use plain XSL-Transformations, because you have a lot more options to transform your source and you can even better determine, how your output should looks like.
    Kind regards,
    Hendrik

  • Query help needed for querybuilder to use with lcm cli

    Hi,
    I had set up several queries to run with the lcm cli in order to back up personal folders, inboxes, etc. to lcmbiar files to use as backups.  I have seen a few posts that are similar, but I have a specific question/concern.
    I just recently had to reference one of these back ups only to find it was incomplete.  Does the query used by the lcm cli also only pull the first 1000 rows? Is there a way to change this limit somwhere?
    Also, since when importing this lcmbiar file for something 'generic' like 'all personal folders', pulls in WAY too much stuff, is there a better way to limit this? I am open to suggestions, but it would almost be better if I could create individual lcmbiar output files on a per user basis.  This way, when/if I need to restore someone's personal folder contents, for example, I could find them by username and import just that lcmbiar file, as opposed to all 3000 of our users.  I am not quite sure how to accomplish this...
    Currently, with my limited windows scripting knowledge, I have set up a bat script to run each morning, that creates a 'runtime' properties file from a template, such that the lcmbiar file gets named uniquely for that day and its content.  Then I call the lcm_cli using the proper command.  The query within the properties file is currently very straightforward - select * from CI_INFOOBJECTS WHERE SI_ANCESTOR = 18.
    To do what I want to do...
    1) I'd first need a current list of usernames in a text file, that could be read (?) in and parsed to single out each user (remember we are talking about 3000) - not sure the best way to get this.
    2) Then instead of just updating the the lcmbiar file name with a unique name as I do currently, I would also update the query (which would be different altogether):  SELECT * from CI_INFOOBJECTS where SI_OWNER = '<username>' AND SI_ANCESTOR = 18.
    In theory, that would grab everything owned by that user in their personal folder - right? and write it to its own lcmbiar file to a location I specify.
    I just think chunking something like this is more effective and BO has no built in back up capability that already does this.  We are on BO 4.0 SP7 right now, move to 4.1 SP4 over the summer.
    Any thoughts on this would be much appreciated.
    thanks,
    Missy

    Just wanted to pass along that SAP Support pointed me to KBA 1969259 which had some good example queries in it (they were helping me with a concern I had over the lcmbiar file output, not with query design).  I was able to tweak one of the sample queries in this KBA to give me more of what I was after...
    SELECT TOP 10000 static, relationships, SI_PARENT_FOLDER_CUID, SI_OWNER, SI_PATH FROM CI_INFOOBJECTS,CI_APPOBJECTS,CI_SYSTEMOBJECTS WHERE (DESCENDENTS ("si_name='Folder Hierarchy'","si_name='<username>'"))
    This exports inboxes, personal folders, categories, and roles, which is more than I was after, but still necessary to back up.. so in a way, it is actually better because I have one lcmbiar file per user - contains all their 'personal' objects.
    So between narrowing down my set of users to only those who actually have saved things to their personal folder and now having a query that actually returns what I expect it to return, along with the help below for a job to clean up these excessive amounts of promotion jobs I am now creating... I am all set!
    Hopefully this can help someone else too!
    Thanks,
    missy

  • Help needed:Printing HTML file using javax.print

    Hi
    I am using the following code which i got form the forum for rpinting an HTML file.
    The folllowing code is working fine, but the problem is the content of HTML file is not getting printed. I am geeting a blank page with no content. What is the change that is required in the code? ALso is there any simpler way to implement this. Help needed ASAP.
    public boolean printHTMLFile(String filename) {
              try {
                   JEditorPane editorPane = new JEditorPane();
                   editorPane.setEditorKit(new HTMLEditorKit());
                   //editorPane.setContentType("text/html");
                   editorPane.setSize(500,500);
                   String text = getFileContents(filename);
                   if (text != null) {
                        editorPane.setText(text);                    
                   } else {
                        return false;
                   printEditorPane(editorPane);
                   return true;
              } catch (Exception tce) {
                   tce.printStackTrace();
              return false;
         public String getFileContents(String filename) {
              try {
                   File file = new File(filename);
                   BufferedReader br = new BufferedReader(new FileReader(file));
                   String line;
                   StringBuffer sb = new StringBuffer();
                   while ((line = br.readLine()) != null) {
                        sb.append(line);
                   br.close();
                   return sb.toString();
              } catch (Exception tce) {
                   tce.printStackTrace();
              return null;
         public void printEditorPane(JEditorPane editorPane) {
                   try {
                        HTMLPrinter htmlPrinter = new HTMLPrinter();
                        htmlPrinter.printJEditorPane(editorPane, htmlPrinter.showPrintDialog());
                   } catch (Exception tce) {
                        tce.printStackTrace();
         * Sets up to easily print HTML documents. It is not necessary to call any of the setter
         * methods as they all have default values, they are provided should you wish to change
         * any of the default values.
         public class HTMLPrinter {
         public int DEFAULT_DPI = 72;
         public float DEFAULT_PAGE_WIDTH_INCH = 8.5f;
         public float DEFAULT_PAGE_HEIGHT_INCH = 11f;
         int x = 100;
         int y = 80;
         GraphicsConfiguration gc;
         PrintService[] services;
         PrintService defaultService;
         DocFlavor flavor;
         PrintRequestAttributeSet attributes;
         Vector pjlListeners = new Vector();
         Vector pjalListeners = new Vector();
         Vector psalListeners = new Vector();
         public HTMLPrinter() {
              gc = null;
              attributes = new HashPrintRequestAttributeSet();
              flavor = null;
              defaultService = PrintServiceLookup.lookupDefaultPrintService();
              services = PrintServiceLookup.lookupPrintServices(flavor, attributes);
              // do something with the supported docflavors
              DocFlavor[] df = defaultService.getSupportedDocFlavors();
              for (int i = 0; i < df.length; i++)
              System.out.println(df.getMimeType() + " " + df[i].getRepresentationClassName());
              // if there is a default service, but no other services
              if (defaultService != null && (services == null || services.length == 0)) {
              services = new PrintService[1];
              services[0] = defaultService;
         * Set the GraphicsConfiguration to display the print dialog on.
         * @param gc a GraphicsConfiguration object
         public void setGraphicsConfiguration(GraphicsConfiguration gc) {
              this.gc = gc;
         public void setServices(PrintService[] services) {
              this.services = services;
         public void setDefaultService(PrintService service) {
              this.defaultService = service;
         public void setDocFlavor(DocFlavor flavor) {
              this.flavor = flavor;
         public void setPrintRequestAttributes(PrintRequestAttributeSet attributes) {
              this.attributes = attributes;
         public void setPrintDialogLocation(int x, int y) {
              this.x = x;
              this.y = y;
         public void addPrintJobListener(PrintJobListener pjl) {
              pjlListeners.addElement(pjl);
         public void removePrintJobListener(PrintJobListener pjl) {
              pjlListeners.removeElement(pjl);
         public void addPrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.addElement(psal);
         public void removePrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.removeElement(psal);
         public boolean printJEditorPane(JEditorPane jep, PrintService ps) {
                   if (ps == null || jep == null) {
                        System.out.println("printJEditorPane: jep or ps is NULL, aborting...");
                        return false;
                   // get the root view of the preview pane
                   View rv = jep.getUI().getRootView(jep);
                   // get the size of the view (hopefully the total size of the page to be printed
                   int x = (int) rv.getPreferredSpan(View.X_AXIS);
                   int y = (int) rv.getPreferredSpan(View.Y_AXIS);
                   // find out if the print has been set to colour mode
                   DocPrintJob dpj = ps.createPrintJob();
                   PrintJobAttributeSet pjas = dpj.getAttributes();
                   // get the DPI and printable area of the page. use default values if not available
                   // use this to get the maximum number of pixels on the vertical axis
                   PrinterResolution pr = (PrinterResolution) pjas.get(PrinterResolution.class);
                   int dpi;
                   float pageX, pageY;
                   if (pr != null)
                        dpi = pr.getFeedResolution(PrinterResolution.DPI);
                   else
                        dpi = DEFAULT_DPI;
                   MediaPrintableArea mpa = (MediaPrintableArea) pjas.get(MediaPrintableArea.class);
                   if (mpa != null) {
                        pageX = mpa.getX(MediaPrintableArea.INCH);
                        pageY = mpa.getX(MediaPrintableArea.INCH);
                   } else {
                        pageX = DEFAULT_PAGE_WIDTH_INCH;
                        pageY = DEFAULT_PAGE_HEIGHT_INCH;
                   int pixelsPerPageY = (int) (dpi * pageY);
                   int pixelsPerPageX = (int) (dpi * pageX);
                   int minY = Math.max(pixelsPerPageY, y);
                   // make colour true if the user has selected colour, and the PrintService can support colour
                   boolean colour = pjas.containsValue(Chromaticity.COLOR);
                   colour = colour & (ps.getAttribute(ColorSupported.class) == ColorSupported.SUPPORTED);
                   // create a BufferedImage to draw on
                   int imgMode;
                   if (colour)
                        imgMode = BufferedImage.TYPE_3BYTE_BGR;
                   else
                        imgMode = BufferedImage.TYPE_BYTE_GRAY;
                   BufferedImage img = new BufferedImage(pixelsPerPageX, minY, imgMode);
                   Graphics myGraphics = img.getGraphics();
                   myGraphics.setClip(0, 0, pixelsPerPageX, minY);
                   myGraphics.setColor(Color.WHITE);
                   myGraphics.fillRect(0, 0, pixelsPerPageX, minY);
                        java.awt.Rectangle rectangle=new java.awt.Rectangle(0,0,pixelsPerPageX, minY);
                   // call rootView.paint( myGraphics, rect ) to paint the whole image on myGraphics
                   rv.paint(myGraphics, rectangle);
                   try {
                        // write the image as a JPEG to the ByteArray so it can be printed
                        Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
                        ImageWriter writer = (ImageWriter) writers.next();
                                       // mod: Added the iwparam to create the highest quality image possible
                        ImageWriteParam iwparam = writer.getDefaultWriteParam();
                        iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
                        iwparam.setCompressionQuality(1.0f); // highest quality
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        ImageOutputStream ios = ImageIO.createImageOutputStream(out);
                        writer.setOutput(ios);
                        // get the number of pages we need to print this image
                        int imageHeight = img.getHeight();
                        int numberOfPages = (int) Math.ceil(minY / (double) pixelsPerPageY);
                        // print each page
                        for (int i = 0; i < numberOfPages; i++) {
                             int startY = i * pixelsPerPageY;
                             // get a subimage which is exactly the size of one page
                             BufferedImage subImg = img.getSubimage(0, startY, pixelsPerPageX, Math.min(y - startY, pixelsPerPageY));
                                                 // mod: different .write() method to use the iwparam parameter with highest quality compression
                             writer.write(null, new IIOImage(subImg, null, null), iwparam);
                             SimpleDoc sd = new SimpleDoc(out.toByteArray(), DocFlavor.BYTE_ARRAY.JPEG, null);
                             printDocument(sd, ps);
                             // reset the ByteArray so we can start the next page
                             out.reset();
                   } catch (PrintException e) {
                        System.out.println("Error printing document.");
                        e.printStackTrace();
                        return false;
                   } catch (IOException e) {
                        System.out.println("Error creating ImageOutputStream or writing to it.");
                        e.printStackTrace();
                        return false;
                   // uncomment this code and comment out the 'try-catch' block above
                   // to print to a JFrame instead of to the printer
                   /*          JFrame jf = new JFrame();
                             PaintableJPanel jp = new PaintableJPanel();
                             jp.setImage( img );
                             JScrollPane jsp = new JScrollPane( jp );
                             jf.getContentPane().add( jsp );
                             Insets i = jf.getInsets();
                             jf.setBounds( 0, 0, newX, y );
                             jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
                             jf.setVisible( true );*/
                   return true;
              * Print the document to the specified PrintService.
              * This method cannot tell if the printing was successful. You must register
              * a PrintJobListener
              * @return false if no PrintService is selected in the dialog, true otherwise
              public boolean printDocument(Doc doc, PrintService ps) throws PrintException {
                   if (ps == null)
                   return false;
                   addAllPrintServiceAttributeListeners(ps);
                   DocPrintJob dpj = ps.createPrintJob();
                   addAllPrintJobListeners(dpj);
                   dpj.print(doc, attributes);
                   return true;
              public PrintService showPrintDialog() {
                   return ServiceUI.printDialog(gc, x, y, services, defaultService, flavor, attributes);
              private void addAllPrintServiceAttributeListeners(PrintService ps) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < psalListeners.size(); i++) {
                   PrintServiceAttributeListener p = (PrintServiceAttributeListener) psalListeners.get(i);
                   ps.addPrintServiceAttributeListener(p);
              private void addAllPrintJobListeners(DocPrintJob dpj) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < pjlListeners.size(); i++) {
                   PrintJobListener p = (PrintJobListener) pjlListeners.get(i);
                   dpj.addPrintJobListener(p);
              // uncomment this also to print to a JFrame instead of a printer
              /* protected class PaintableJPanel extends JPanel {
                   Image img;
                   protected PaintableJPanel() {
                        super();
                   public void setImage( Image i ) {
                        img = i;
                   public void paint( Graphics g ) {
                        g.drawImage( img, 0, 0, this );
    Thanks
    Ram

    Ram,
    I have had printing problems too a year and a half ago. I used all printing apis of java and I still find that it is something java lacks. Now basically you can try autosense. To check whether your printer is capable of printing the docflavor use this PrintServiceLookup.lookupPrintServices(flavor, aset); . If it lists the printer then he can print the document otherwise he can't. I guess that is why you get the error.
    Regards,
    Kevin

  • ORacle sales analyzer doesn't display sql's using show sq.sql.stmts

    Hi,
    I cannot view the sql statements generated by Oracle Sales analyzer cube using show sq.sql.stmts.
    Moreover when I check on db I don't see any sql's being issued by web OSA session.
    What could be the possible reason for this?

    Lang wrote:
    Hi
    Can anyone help please, I am using SQL developer 3.0, and I have come across a lot of cases that after compiling a package , the compiler doesn't show me any errors, and It shows me the package is compiled , but it 's not valid after I close down the sql developer and log back in again.
    I am using 11g instantclient with it.Really?
    & here I thought SQL Developer used JDBC Thin to connect to the DB.

  • Connecting DB Oracle/SQL server using the same SQL Navigator  release 5.1.0

    I have
    SQL Navigator release 5.1.0.655 installed in my desktop
    License version X-pert Edition
    Licensed Options
    PL/SQL Debugger
    CodeXpert
    Knowledge Xpert For Pl/SQL
    Xper Tuning
    Currently I have the access of Oracle DB using this SQL navigator and MS-SQL server using MS-Sql server Query Analyzer
    My question is -- using the same SQL Navigator can I connect MS-SQL server DB/Tables and can I run sql query using this..
    Thanks in advance.
    Mash

    Why, in an Oracle forum, are you asking a question about a Quest product connecting to a Microsoft product?
    How does this relate to the Oracle Database?

  • Charactersitic values to be used in IFTHEN ELSE STATEMENT IN QUERY

    scenario: i need to use the characteristic values(not the attributes) to be used in an IF THEN ELSE STATEMENT in query. so i created a formula variable for the characteritic of processing type replacement path, replace with key.The values are not fetched in the result and is displayed as X.
    what should i replace with key,lable, constant or other options whereas  my requirement is the all the values present in the characteristc should be used.
    eg. if char name is xyz and has the values 1,2,3,4,5 till -
    20.
    then in a calculated key figure :(formulavariable =1)* kefig1keyfig2 +not(formulavariable =1)kef2keyfig3.
    this formula variable should have all the values of the characteristic values ie 1,2,3---20.
    2. how should i do get the values of characterstics values in the equation give me the steps in detail..
    3. i do not want to use the attributes, though i tried initally while creating the formual variable i replaced with attribute value, there is was an error and there were no reult.
    i tried to create char. variable  for the characteristic  of manual entr , not ready for input values and gave all the values 1,2,3 --20 as default values and then created formaul variable and repalce with the variable, however this characteristic variable is not at all displayed from the list of variables which will be displayed while creating the formula variable.
    help me out.
    Thanks

    hi srini,
    i have includedthe char in rows. i want you to explain in detail how to use these values in the if then else statement in query.
    i have created a calculated key figure 2= (formual variable =1 & keyfig a =0)* keyfig1kefig2 +not(formual variable =1 & keyfig a =0)keyfig2 *calculated keyfig1.
    so this formula variable of replacement path have ref. to then char. and with what value should it replace, key, name, external char or attribut etc so that i should get the values of the char from 1 to20.
    i donot to repalce with the attribute. i just want the char. values and not thier attributes (1. description 2. the second attribute has the values say abc1,efg2,ghi3 for respective charteristic values.
    ie
    char value               desc                 2nd attrib
    1                            hi                     abc1
    2                            bye                  defg2
    3                            ciao                  ghi3

  • Help needed with Dashboard prompt using SQL Constrain

    I am trying to implement a filter using presentation variables in a Dashboard Prompt.
    I wish to use SQL filter to Constrain the results to populate the 2nd Combo Box.
    The solution works for the 1st time, and there after it doesn't.
    Can anyone suggest a better approach or correct me if I am doing anything wrong.
    NOTE: I do not wish to use 'Constrain' Check box which is provided by Oracle.
    The code -> http://picasaweb.google.com/lh/photo/GTEQfuC6g7xGeP6HXor6_A?feat=directlink
    It works the First time ->http://picasaweb.google.com/lh/photo/SUrrZJSgB5W8H39D899yGQ?feat=directlink
    Hence forth it does not -> http://picasaweb.google.com/lh/photo/vUVrMPbPpdEzj7nHnePZEg?feat=directlink
    -Rohit.

    hi....
    your picasa is not opening.. i don't know why??
    follow this.. Can presentation variable created in one Dashboar prompt be used in other?
    see my first reply in this thread..
    may it solves..
    Thanks & Regards
    Kishore Guggilla

  • Help needed to load data using sql loader.

    Hi,
    I trying to load data from xls to oracle table(solaris OS) and its failing to load data.
    Control file:
    LOAD DATA
    CHARACTERSET UTF16
    BYTEORDER BIG ENDIAN
    INFILE cost.csv
    BADFILE consolidate.bad
    DISCARDFILE Sybase_inventory.dis
    INSERT
    INTO TABLE FIT_UNIX_NT_SERVER_COSTS
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    HOST_NM,
    SERVICE_9071_DOLLAR DOUBLE,
    SERVICE_9310_DOLLAR DOUBLE,
    SERVICE_9700_DOLLAR DOUBLE,
    SERVICE_9701_DOLLAR DOUBLE,
    SERVICE_9710_DOLLAR DOUBLE,
    SERVICE_9711_DOLLAR DOUBLE,
    SERVICE_9712_DOLLAR DOUBLE,
    SERVICE_9713_DOLLAR DOUBLE,
    SERVICE_9720_DOLLAR DOUBLE,
    SERVICE_9721_DOLLAR DOUBLE,
    SERVICE_9730_DOLLAR DOUBLE,
    SERVICE_9731_DOLLAR DOUBLE,
    SERVICE_9750_DOLLAR DOUBLE,
    SERVICE_9751_DOLLAR DOUBLE,
    GRAND_TOTAL DOUBLE
    Log file:
    Table FIT_UNIX_NT_SERVER_COSTS, loaded from every logical record.
    Insert option in effect for this table: INSERT
    TRAILING NULLCOLS option in effect
    Column Name Position Len Term Encl Datatype
    HOST_NM FIRST * , CHARACTER
    SERVICE_9071_DOLLAR NEXT 8 DOUBLE
    SERVICE_9310_DOLLAR NEXT 8 DOUBLE
    SERVICE_9700_DOLLAR NEXT 8 DOUBLE
    SERVICE_9701_DOLLAR NEXT 8 DOUBLE
    SERVICE_9710_DOLLAR NEXT 8 DOUBLE
    SERVICE_9711_DOLLAR NEXT 8 DOUBLE
    SERVICE_9712_DOLLAR NEXT 8 DOUBLE
    SERVICE_9713_DOLLAR NEXT 8 DOUBLE
    SERVICE_9720_DOLLAR NEXT 8 DOUBLE
    SERVICE_9721_DOLLAR NEXT 8 DOUBLE
    SERVICE_9730_DOLLAR NEXT 8 DOUBLE
    SERVICE_9731_DOLLAR NEXT 8 DOUBLE
    SERVICE_9750_DOLLAR NEXT 8 DOUBLE
    SERVICE_9751_DOLLAR NEXT 8 DOUBLE
    GRAND_TOTAL NEXT 8 DOUBLE
    Record 1: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column HOST_NM.
    Field in data file exceeds maximum length
    Table FIT_UNIX_NT_SERVER_COSTS:
    0 Rows successfully loaded.
    1 Row not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Please help me ASAP.
    Awaiting u r reply.

    Hi,
    I verified and everything looks fine according to me.
    Table structure:
    OST_NM VARCHAR2(30)
    SERVICE_9071_DOLLAR NUMBER(8,2)
    SERVICE_9310_DOLLAR NUMBER(8,2)
    SERVICE_9700_DOLLAR NUMBER(8,2)
    SERVICE_9701_DOLLAR NUMBER(8,2)
    SERVICE_9710_DOLLAR NUMBER(8,2)
    SERVICE_9711_DOLLAR NUMBER(8,2)
    SERVICE_9712_DOLLAR NUMBER(8,2)
    SERVICE_9713_DOLLAR NUMBER(8,2)
    SERVICE_9720_DOLLAR NUMBER(8,2)
    SERVICE_9721_DOLLAR NUMBER(8,2)
    SERVICE_9730_DOLLAR NUMBER(8,2)
    SERVICE_9731_DOLLAR NUMBER(8,2)
    SERVICE_9750_DOLLAR NUMBER(8,2)
    SERVICE_9751_DOLLAR NUMBER(8,2)
    GRAND_TOTAL NUMBER(8,2)
    Control file:
    LOAD DATA
    BYTEORDER BIG ENDIAN
    INFILE cost.csv
    BADFILE consolidate.bad
    DISCARDFILE Sybase_inventory.dis
    INSERT
    INTO TABLE FIT_UNIX_NT_SERVER_COSTS
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    HOST_NM ,
    SERVICE_9071_DOLLAR NUMBER(8,2),
    SERVICE_9310_DOLLAR NUMBER(8,2),
    SERVICE_9700_DOLLAR NUMBER(8,2),
    SERVICE_9701_DOLLAR NUMBER(8,2),
    SERVICE_9710_DOLLAR NUMBER(8,2),
    SERVICE_9711_DOLLAR NUMBER(8,2),
    SERVICE_9712_DOLLAR NUMBER(8,2),
    SERVICE_9713_DOLLAR NUMBER(8,2),
    SERVICE_9720_DOLLAR NUMBER(8,2),
    SERVICE_9721_DOLLAR NUMBER(8,2),
    SERVICE_9730_DOLLAR NUMBER(8,2),
    SERVICE_9731_DOLLAR NUMBER(8,2),
    SERVICE_9750_DOLLAR NUMBER(8,2),
    SERVICE_9751_DOLLAR NUMBER(8,2),
    GRAND_TOTAL NUMBER(8,2)
    Sample date file:
    ABOS12,122.46,,1315.00,,1400.00,,,,,,,,1855.62,,4693.07
    ABOS39,6391.16,,1315.00,,1400.00,,,,,,,,,4081.88,13188.04

  • Help needed - Planning Server 2012 solution, DC/Exchange/SQL/RDP host/Remote apps etc

    Hi All,
    I have a client needing me to provide a Windows server based solution for their business. I have limited experience with Server 2012, although I have worked with 2008R2 and SBS2011, I am needing some guidance with this 2012 project.
    The client has about 8-10 local users who work at one office with an NBN connection, and 2 other locations that have 3-5 users at each location. I am needing to provide them with a server based solution to manage their data, remote access and also their
    email. They are also likely to expand to another physical office soon.
    I need to provide them with a DC controller, Exchange server and possibly an SQL server in the future. They currently use an Act database, but I have been told that once the database in ACT grows to 4G, a dedicated database is required?
    I am currently thinking of having one physical server and virtualising the additional servers on this platform, however I come from a UNIX background and have not virtualised using Hyper V or ESXi before. I have read a little regarding the CLI and GUI Hyper
    V options, but I really need advice on what will suit my needs best from someone that has done it.
    I am thinking I maybe should recommend one physical machine with Server 2012 Std which, from what I understand, will allow me to install the host hyper V host on the physical machine and then I could possibly install an instance of Server 2012 as
    the DC, Exchange and SQL server on one VM licence, however I have read it is not preferred to have the exchange server on the same VM as the DC but have read that limiting the memory usage of Exchange can negate these issues?
    I will also need to have a terminal server/RDP session host in there as well which I could maybe use the 2nd VM licence for.
    I suppose my question is, considering that I need to end up with a DC, Exchange server, terminal server/RDP session host and possibly a SQL server in the future, am I better off virtualising and running these on a Server 2012 Std licence, that allows a hyper
    v host + 2xVM's or should I be splitting these roles up on different physical machines, keeping in mind costs need to be kept to a minimum.
    Also I need to consider the Microsoft Office side of things. Is it more financially viable to use office licences and use remote apps from the terminal server, or just purchase Office H&B for the workstations/laptops and have their outlook connected
    directly to the exchange server?
    I am concerned from the performance viewpoint that if I run the DC/Exchange and SQL from one VM, then the TS/RDP Host from the other VM licence it may be too much for the DC/Exchange/SQL VM to handle.
    I have used SBS 2011 in a few locations with Exchange and the SQL and DC roles installed on HP DL and ML gen 8 servers, and although they run a little slow on the console, they seem to serve the network clients fine.
    If do end up running on one physical machine the Hyper V host, one VM as a DC, Exchange and SQL server, and the other VM licence as a RDP session host, what sort of spec'd machine would be recommended to be able to do this, keeping in mind
    I usually lean towards HP servers.
    Anyhow, thx in advance and any comments or suggestions will certainly be appreciated.
    Mkm

    Hello,
    sorry but in your case without the knowledge of all major requirements i would suggest that you or your client contact an expert and not work with the forums to get this amount of information and setup requirements.
    Exchange on DCs is NOT recommended, even not from Microsoft. Also it is highly recommended to run at least 2 DC/DNS/GC per domain for failover and redundancy, of course NOT on the same physical machine.
    RDS servers should also run on dedicated machines and not be used for anything else.
    SQL should also run on a separate server.
    You cannot compare SBS version with regular server versions, the concept behind is different.
    With that small amount of users you should consider using an Office365 solution where you could use a plan that fits your needs and have just computers for your client employees.
    But as stated above therefore you should find an experienced consultant.
    Best regards
    Meinolf Weber
    MVP, MCP, MCTS
    Microsoft MVP - Directory Services
    My Blog: http://blogs.msmvps.com/MWeber
    Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    Twitter:  

  • Help needed with condition based joins in pl\sql

    Hi,
    I need to get data from 6 tables,
    Scenario 1 : I need to join 4 tables and join this result set to 5th table
    Scenario2: resultset of join of 4 tables to 6th table
    In this case how do i save the intermediate result set of 4 tables to use it in further joins.

    Welcome to the forum.
    Your question is broad.
    http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    A more detailed example would help.
    Mention your database version as well and see the FAQ http://forums.oracle.com/forums/help.jspa when it comes to posting formatted examples using the {noformat}{noformat} tag
    However, i think using the WITH clause or a subquery ( a.k.a. inline view) is what you're looking for.
    Do some searches on http://asktom.oracle.com to find many examples.
    Also see:
    http://www.oracle-base.com/articles/misc/WithClause.php
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries007.htm#sthref3193                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help needed in business logic implmentation in oracle sql.

    I got a requirement from customer that i need to generated numbers based on first value which is entered by users but not second values..
    for example:
    c1 c2
    1 1
    2 1
    3 1
    4 1
    1 2
    2 2
    3 2
    4 2
    1 3
    2 3
    3 3
    4 3
    1 4
    2 4
    3 4
    4 4
    1 5
    2 5
    3 5
    4 5
    unlimited..
    the user input only first column values which comes from UI and i need to provide second column values when records are getting inserted into db table.
    user always enter only 1-4 values in first column but never input second values in second column of table.. both columns are numerical.
    the second values should be provided automatically or programmatically when records are getting inserted into table and automatically... how this can be done?
    Can any one help me out to get this done either using sql,plsql concept?
    thanks a lot in advance.

    Hi,
    Demonstration
    SQL> DROP TABLE t1;
    Table supprimée.
    SQL> CREATE TABLE t1 (c1 NUMBER, c2 NUMBER);
    Table créée.
    SQL>
    SQL> insert into t1 (c1) values(1);
    1 ligne créée.
    SQL> insert into t1  (c1) values(2);
    1 ligne créée.
    SQL> insert into t1 (c1) values(3);
    1 ligne créée.
    SQL> insert into t1 (c1) values(4);
    1 ligne créée.
    SQL> insert into t1 (c1) values(1);
    1 ligne créée.
    SQL> insert into t1 (c1) values(2);
    1 ligne créée.
    SQL> insert into t1 (c1) values(3);
    1 ligne créée.
    SQL> insert into t1 (c1) values(4);
    1 ligne créée.
    SQL> insert into t1 (c1) values(1);
    1 ligne créée.
    SQL> insert into t1 (c1) values(2);
    1 ligne créée.
    SQL> commit;
    Validation effectuée.
    SQL>
    SQL> CREATE OR REPLACE VIEW view_t1
      2  AS
      3     SELECT c1, ROW_NUMBER () OVER (PARTITION BY c1 ORDER BY c1) c2
      4       FROM t1;
    Vue créée.
    SQL>
    SQL>
    SQL> SELECT   c1,c2
      2      FROM view_t1
      3  ORDER BY c2, c1;
            C1         C2
             1          1
             2          1
             3          1
             4          1
             1          2
             2          2
             3          2
             4          2
             1          3
             2          3
    10 ligne(s) sélectionnée(s).
    SQL>

  • Request some help, over procedure's performance uses regular expressions for its functinality

    Hi All,
            Below is the procedure, having functionalities of populating two tables. For first table, its a simple insertion process but for second table, we need to break the soruce record as per business requirement and then insert into the table. [Have used regular expressions for that]
            Procedure works fine but it takes around 23 mins for processing 1mm of rows.
            Since this procedure would be used, parallely by different ETL processes, so append hint is not recommended.
            Is there any ways to improve its performance, or any suggestion if my approach is not optimized?  Thanks for all help in advance.
    CREATE OR REPLACE PROCEDURE SONARDBO.PRC_PROCESS_EXCEPTIONS_LOGS_TT
         P_PROCESS_ID       IN        NUMBER, 
         P_FEED_ID          IN        NUMBER,
         P_TABLE_NAME       IN        VARCHAR2,
         P_FEED_RECORD      IN        VARCHAR2,
         P_EXCEPTION_RECORD IN        VARCHAR2
        IS
        PRAGMA AUTONOMOUS_TRANSACTION;
        V_EXCEPTION_LOG_ID     EXCEPTION_LOG.EXCEPTION_LOG_ID%TYPE;
        BEGIN
        V_EXCEPTION_LOG_ID :=EXCEPTION_LOG_SEQ.NEXTVAL;
             INSERT INTO SONARDBO.EXCEPTION_LOG
                 EXCEPTION_LOG_ID, PROCESS_DATE, PROCESS_ID,EXCEPTION_CODE,FEED_ID,SP_NAME
                ,ATTRIBUTE_NAME,TABLE_NAME,EXCEPTION_RECORD
                ,DATA_STRUCTURE
                ,CREATED_BY,CREATED_TS
             VALUES           
             (   V_EXCEPTION_LOG_ID
                ,TRUNC(SYSDATE)
                ,P_PROCESS_ID
                ,'N/A'
                ,P_FEED_ID
                ,NULL 
                ,NULL
                ,P_TABLE_NAME
                ,P_FEED_RECORD
                ,NULL
                ,USER
                ,SYSDATE  
            INSERT INTO EXCEPTION_ATTR_LOG
                EXCEPTION_ATTR_ID,EXCEPTION_LOG_ID,EXCEPTION_CODE,ATTRIBUTE_NAME,SP_NAME,TABLE_NAME,CREATED_BY,CREATED_TS,ATTRIBUTE_VALUE
            SELECT
                EXCEPTION_ATTR_LOG_SEQ.NEXTVAL          EXCEPTION_ATTR_ID
                ,V_EXCEPTION_LOG_ID                     EXCEPTION_LOG_ID
                ,REGEXP_SUBSTR(str,'[^|]*',1,1)         EXCEPTION_CODE
                ,REGEXP_SUBSTR(str,'[^|]+',1,2)         ATTRIBUTE_NAME
                ,'N/A'                                  SP_NAME    
                ,p_table_name
                ,USER
                ,SYSDATE
                ,REGEXP_SUBSTR(str,'[^|]+',1,3)         ATTRIBUTE_VALUE
            FROM
            SELECT
                 REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
            FROM
                DUAL t1 CROSS JOIN
                        TABLE
                            CAST
                                MULTISET
                                    SELECT LEVEL
                                    FROM DUAL
                                    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
                                AS SYS.odciNumberList
                        ) t2
            WHERE REGEXP_SUBSTR(str,'[^|]*',1,1) IS NOT NULL
            COMMIT;
           EXCEPTION
             WHEN OTHERS THEN
             ROLLBACK;
             RAISE;
        END;
    Many Thanks,
    Arpit

    Regex's are known to be CPU intensive specially when dealing with large number of rows.
    If you have to reduce the processing time, you need to tune the Select statements.
    One suggested change could be to change the following query
    SELECT
                 REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
            FROM
                DUAL t1 CROSS JOIN
                        TABLE
                            CAST
                                MULTISET
                                    SELECT LEVEL
                                    FROM DUAL
                                    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
                                AS SYS.odciNumberList
                        ) t2
    to
    SELECT REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,level) str
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
    Before looking for any performance benefit, you need to ensure that this does not change your output.
    How many substrings are you expecting in the P_EXCEPTION_RECORD? If less than 5, it will be better to opt for SUBSTR and INSTR combination as it might work well with the number of records you are working with. Only trouble is, you will have to write different SUBSTR and INSTR statements for each column to be fetched.
    How are you calling this procedure? Is it not possible to work with Collections? Delimited strings are not a very good option as it requires splitting of the data every time you need to refer to.

  • Help needed for file processing using FTP

    Hi All,
    I am new to ODI tool and currently we are implementing one project in ODI. Could you please, any one help me on the following requirement... how to implement it?
    Scenario:
    i) I need to pick a file from remote host 'outbox' dir using FTP process, and place into local 'temp' dir. (I can do it with odiFTPGet tool)
    ii) Change the file as per target business requirement.??? ( this step challenging me)
    for ex:
    if source file name : <project name>_<source ID>_<transaction name>_<unique id>.txt
    target name should be : 1234_<transaction name>_<sysdate in yyyyMMddhhmmss>_<unique id>_2345.txt ( here 1234 and 2345 are hard coded values)
    iii) Later move to local 'temp' to local 'outbox' dir. ( I can do it with odiFileMove tool)
    iv) After successful process move the file from remote 'outbox' to remote 'archive' dir ??? (again this is challenging me).
    For this my questions are:
    1) How to get file name into a variable ( In one of the post , it says we need to create data model and data stores, and interface to get the file names into a file. apart from is there any easy way i can implement it in package it self?)
    2) How to tokenize a long string ( i.e., need to tokenize the source file to get <unique id> and <transaction name> and map to target file name)
    3) How to define implementation for Java in user function?? do we need to use class declarations and import statements?? I need a sample user function in Java.
    4) How to move/rename a file in remote server?? ( need to move file from remote 'outbox' server to remote archive' dir)
    5) If any step in package fails, How to get the error msg into a variable which i can use for sending mail and raise a ticket in remedy?? ( I will pass that variable to as content to mail and remedy ticket)
    6) How to handle list type data (string list) by variables in ODI?? (As we can define single variable not as list.)
    I am sorry to ask all my queries I a single post. But I need to solutions for all to implement this in my project.
    Thanks in advance. Appreciate early response.
    Regards,
    Kiran.N

    Can any one share your thoughts for my request.
    Thanks in advance.
    Regards,
    Kiran

  • Help needed in exporting dump using DBMS_DATAPUMP

    Hi,
    Soory in posting the Requirement in GENERAL:
    I need a help in building the Procedure where I will use DBMS_DATAPUMP for Export purpose.
    I have a scenario where there is TABLEA and TABLE B.
    TABLE A structure:
    CODE VARCHAR2(10),NAME VARHAR2(50)
    TABLE B structure:
    DEPT VARCHAR2(10),CODE VARCHAR2(10),DEPT_DESC VARCHAR2(40)
    i want to take the dump of values in joining TABLE A nad TABLE B for e.g after joining I have the values as:
    CODE NAME DEPT
    10 SSSS TECH
    20 PPPP ADMIN
    Any help will be benefitial for me

    This is remarkably offensive. First you ask for questions about school work and then when you don't get an instantaneous reply you post again.
    Please apologize and do not do it again.
    Thank you.

Maybe you are looking for