Oracle sql commands use

my question is will it possible to use oracle sql commands in toad and genterate the reprot like I have below.
my second question is can I embede this oralc sql command in my apps. to have the out put I have below. I tried and got an error message. I am wondering if this is possible
SQL> -- Multiple COMPUTEs are also allowable.
SQL>
SQL> SET echo off
SQL> BREAK ON city skip1 ON start_date
SQL> COMPUTE sum max min of salary ON city
SQL> COMPUTE sum of salary ON start_date
SQL> SET verify off
SQL> SELECT id, first_name, salary, city FROM employee ORDER BY city
  2  /
ID   FIRST_NAME     SALARY CITY
07   David         7897.78 New York
06   Linda         4322.78
                   4322.78 minimum
                   7897.78 maximum
                  12220.56 sum
01   Jason         1234.56 Toronto
                   1234.56 minimum
                   1234.56 maximum
                   1234.56 sum
05   Robert        2334.78 Vancouver
08   James         1232.78
03   James         6544.78
02   Alison        6661.78
04   Celia         2344.78
                   1232.78 minimum
                   6661.78 maximum
                   19118.9 sum

Hi,
All of theose SQL*Plus features can be duplicated in Oracle SQL. For example, "GROUP BY ... ROLLUP" can give you an minimum, maximum and total for each city.
You can create a view that looks exactly like the SQL*Plus output (for example, the city column with values like 'New York', NULL, '**********', and 'minimum'), if you really need to. CASE is very useful for things like this, as are some analytic functions. (E.g., ROW_NUMBER can help in telling which is the first row for each city.)
To make such a view, you may find it convenient to do a UNION of two queries:
(1) One that produces one row per employee
(2) One that produces a fixed number of rows (four, to get the results you posted) per city

Similar Messages

  • Oracle SQL command

    I have read this statement on these forums many times:
    Just keep 1 thin in mind... CR will send any SQL statement, exactly as it is written, to the database. That means that if you can execute it from TOAD or the Oracle SQL Developer, you should be able to do it from CR as well.
    I have an SQL command that I have simplified so that it contains just a snippet from the original that populates a temporary table.
    Since there is a DECLARE there must be a BEGIN and END.  The required SELECT * to get the fields to show up in the field explorer will not work before the END statement.  If I put it after the END statement I get an ORA-06550 error.  "FOUND SELECT WHEN EXPECTING..." .   I got on the ORACLE website and they told me to put / before and after the SELECT.  When I try this in CR SQL command, I get ORA-06550 "ENCOUNTERED /".
    I have tried this in SQL Plus and don't get any errors.
    DECLARE Pallet  VARCHAR2(8);
            Box     VARCHAR2(8);
            ItemBox VARCHAR2(8);
            CODE    VARCHAR2(6);
    BEGIN   
        CODE := '20151';
        CODE := CONCAT(CODE, '%');
        DELETE LoadItems_temp;
       COMMIT;
    END;
    SELECT * FROM LOADITEMS_TEMP;

    Just keep 1 thin in mind... CR will send any SQL statement, exactly as it is written, to the database. That means that if you can execute it from TOAD or the Oracle SQL Developer, you should be able to do it from CR as well.
    Sounds like that may have come from me...
    99% of my reporting is done using SQL Server as a back end so I can't say if the rules change when using Oracle any of the Oracle drivers.
    That said, I can create and drop temp tables as well as declare and set variables without any issues in SQL Server... And do so regularly.
    Looking at your code... (and bear in mind that I don't know PL-SQL specific syntax...) I don't see where you are creating the temp table LoadItems_temp.
    I did a quick Google search on ORA-06550 and it appears to be syntax error. So if the code is executing in SQL-Plus without any issues but bombs in CR, my guess would be that you aren't using the right driver for your database.
    HTH,
    Jason

  • Import oracle.sql.* use in weblogic env.

    hi,
    I need to use following in my my java program and deployed in Jdeveloper(11.1.1.)
    import oracle.sql.*;
    In order to use this in my program, what pre-request installation JAR file I required.
    if so send me oracle link for download..
    Thanks

    Oracle Jdbc Drivers Download Page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
    With detailed descriptions ...which Driver is compiled on which version of JDK and Size etc....

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

  • SQL Task Expression: SQL Command using variable tables

    Hello,
    I've got a question I hope someone could help me out with. I'm working on a SSIS project that basically synchronises logins of a Source and Destination server that are part of an AlwaysOn Cluster.
    The idea is as followed: On the source server there are variable tables created named Logins_<SourceServerName>_To_<DestinationServerName> for example. This one is filled with all the login information from that server, then on the Destination
    server the same table is created and the data is transfered. The Source and Destination server names are project variables.
    Once all data is copied I use a set of code from the dba_CopyLogins script I got from SQLSoldier (http://www.sqlsoldier.com/wp/sqlserver/transferring-logins-to-a-database-mirror) to create the missing logins on the Destination server.
    What I've found is that I can't use expressions to handle the code, at least I haven't found a way yet, expression evaluation will give an error on (for example) the following code:
    Begin
    Set @SQL = 'Create Login ' + quotename(@LoginName)
    If @Type In ('U', 'G')
    Begin
    Set @SQL = @SQL + ' From Windows;'
    End
    Else
    Begin
    Set @PasswordHashString = '0x' +
    Cast('' As XML).value('xs:hexBinary(sql:variable("@PasswordHash"))', 'nvarchar(300)');
    Set @SQL = @SQL + ' With Password = ' + @PasswordHashString + ' HASHED, ';
    Set @SIDString = '0x' +
    Cast('' As XML).value('xs:hexBinary(sql:variable("@SID"))', 'nvarchar(100)');
    Set @SQL = @SQL + 'SID = ' + @SIDString + ';';
    End
    I've tried various things to get this to work as an expression, however I seem to continue to get the error:
    The expression might contain an invalid token, an incomplete token, or an invalid element. It might not be well-formed, or might be missing part of a required element such as a parenthesis.
    So the next thing I tried was just using the script as Direct input with Parameter Mapping on the tables but I've got the error:
    Must declare the table variable "@P1".
    All the way up to @P12. Since we're talking about 12 variables that are in the script in total. But they are table variables and apparently Parameter mapping is not possible on table variables or am I wrong here? Pieces of code for example are:
    Set @MaxID = (Select Max(LoginID) From ?)
    Set @CurrID = (Select Min(LoginID) From ?)
    I hope there's someone who could help me out or at least can give me a direction to look into.
    Yes we could use the script provided, but we don't want to work with LinkedServers, besides I'd have to make local jobs on the servers instead of controlling it all from 1 centralised server.
    Thank for looking at the topic and I hope you have a clue about what to do...
    Regards,
    Danny

    The code you posted is a t-sql code. If you want to store it inside ssis variable syntax is different. As per what you say what might be best would be to warp above code inside a procedure and then call it from SSIS execute sql task after passing values
    through SSIS variable
    also for 
    Set @MaxID = (Select Max(LoginID) From ?)
    etc
    create variable in SSIS, set EvaluateAsExpression true and set expression as
    "Select Max(LoginID) AS MaxID From " + @[User::TableName]
    Where TableName is SSIS variable through which you pass the table name. Then use above statement inside execute sql task and set resultset option as single row and map resultset to SSIS variable (say @[User::MaxID]) to get return value 
    similarly for other statements
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • In Oracle SQL, cannot use column in select statement and order by

    Hi,
    Is there a work around for this.
    Thanks in advance
    Pablo.

    Hi,
    943981 wrote:
    Hi All,
    This is the error I get:
    ORA-00960: ambiguous column naming in select list
    00960. 00000 - "ambiguous column naming in select list"
    *Cause:    A column name in the order-by list matches more than one select
    list columns.
    *Action:   Remove duplicate column naming in select list.
    Error at Line: 6 Column: 17That error message looks pretty clear to me. What don't you understand?
    Either
    (a) use aliases, so each column has a unique name, or
    (b) remove duplicate columns from the SELECT clause.
    Post your query. It's hard to say exactly what you're doing wrong when we don't know exactly what you're doing.
    For best results, post a complete test script (including CREATE TABLE and INSERT statements, if necessary) that people can to re-create the problem and test their ideas.
    See the forum FAQ {message:id=9360002}

  • Sql Commands for Backup and restore database

    Hi,
    What are the SQL commands used for database backup nad restore?
    Is it possible to use these command in pl/sql block or it is used only
    from sql plus?
    Thanks
    Jobin .SP

    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/intro005.htm

  • Passing Parameter from Main report to SQL command-based subreport

    I am trying to cut down the run time of my reports and have recently figured out how to write SQL commands to limit the data by filtering prior to being pulled into the reports.  However, many of my reports rely on multiple sub reports, which can cause a dramatic 'drag' on the report.
    I am trying to filter the SQL command used in my sub report by passing the group parameter, which is selected by the user in the main report, to the sub report's SQL command.  Without this parameter, the sub report has to sort through a lot more data than it would with this parameter, making the run time extremely slow.
    Any suggestions on how I can accomplish this?
    Thanks for any help you can provide,
    Marlene Allen
    Crystal Reports Developer
    Crystal Reports Professional;
    Product Type: Full;
    Product Version 11.5

    Hi Marlene,
    I don't believe you can pass a CR parameter to a Command object.
    I suggest replacing all of the Command Objects with a Stored Procedure so all of the data filtering is done server side. DB servers are much more proficient at collecting the data and filtering than CR will ever be. It will also allow you to replace subreports to also speed up your report processing. All depends on your layout of course but something to look at.
    Thank you
    Don

  • Convert IIF Access SQL to Oracle SQL...

    I am in the process of converting a MS Access application to VB.Net with Oracle database behind. However I am having a problem converting an MS Access Query that contains IIF statements into an Oracle SQL command. Below is the MS Access SQL code:
    SELECT PDTABLE_132.UNIQUE_CLASH_ID, CISClashStatusTbl.Approval_Type AS Clash_Status, CISClashTypeTbl.Clash_Type, *IIf([TEMP_ACTION_DISCIPLINE] Is Null,"UNALOCATED",[TEMP_ACTION_DISCIPLINE]) AS ACTION_DISCIPLINE*, *IIf([CISDisciplineTbl].[Discipline] Is Null,[PD_2910A_PDTABLE_111].[DISCIPLINE_NAME],[CISDisciplineTbl].[Discipline]) AS TEMP_ACTION_DISCIPLINE*
    FROM ((((((((((((PDTABLE_132 INNER JOIN PD_2910A_PDTABLE_113 ON PDTABLE_132.MODEL_INDEX_NO_A = PD_2910A_PDTABLE_113.MODEL_INDEX_NO) INNER JOIN PD_2910A_PDTABLE_113 AS PD_2910A_PDTABLE_113_1 ON PDTABLE_132.MODEL_INDEX_NO_B = PD_2910A_PDTABLE_113_1.MODEL_INDEX_NO) INNER JOIN PDTABLE_119 ON PD_2910A_PDTABLE_113.MODEL_INDEX_NO = PDTABLE_119.MODEL_INDEX_NO) INNER JOIN PDTABLE_119 AS PDTABLE_119_1 ON PD_2910A_PDTABLE_113_1.MODEL_INDEX_NO = PDTABLE_119_1.MODEL_INDEX_NO) LEFT JOIN CISClashStatusTbl ON PDTABLE_132.IF_APPROVAL_STATUS = CISClashStatusTbl.Approval_Code) LEFT JOIN CISClashTypeTbl ON PDTABLE_132.RECENT_CLASH_TYPE = CISClashTypeTbl.Clash_Code) INNER JOIN PD_2910A_PDTABLE_112 ON PD_2910A_PDTABLE_113.AREA_INDEX_NO = PD_2910A_PDTABLE_112.AREA_INDEX_NO) INNER JOIN PD_2910A_PDTABLE_112 AS PD_2910A_PDTABLE_112_1 ON PD_2910A_PDTABLE_113_1.AREA_INDEX_NO = PD_2910A_PDTABLE_112_1.AREA_INDEX_NO) LEFT JOIN CISOwnerTbl ON PDTABLE_132.UNIQUE_CLASH_ID = CISOwnerTbl.UNIQUE_CLASH_ID) LEFT JOIN CISDisciplineTbl ON CISOwnerTbl.Discipline_Code = CISDisciplineTbl.Discipline_Code) LEFT JOIN PD_2910A_PDTABLE_111 ON PDTABLE_132.ACTION_DISCIPLINE = PD_2910A_PDTABLE_111.DISCIPLINE_INDX_NO) LEFT JOIN PD_2910A_PDTABLE_111 AS PD_2910A_PDTABLE_111_1 ON PDTABLE_132.DISCIPLINE_INDEX_A = PD_2910A_PDTABLE_111_1.DISCIPLINE_INDX_NO) LEFT JOIN PD_2910A_PDTABLE_111 AS PD_2910A_PDTABLE_111_2 ON PDTABLE_132.DISCIPLINE_INDEX_B = PD_2910A_PDTABLE_111_2.DISCIPLINE_INDX_NO
    ORDER BY PDTABLE_132.UNIQUE_CLASH_ID;
    Any help would really be appreshiated.
    Thanks in advance
    Simon
    Edited by: user8275408 on 21-Jan-2010 07:25

    Hi, Simon,
    Welcome to the forum!
    An Oracle equivalent of
    IIf(TEMP_ACTION_DISCIPLINE Is Null,"UNALOCATED",TEMP_ACTION_DISCIPLINE) AS ACTION_DISCIPLINEis
    CASE
         WHEN  TEMP_ACTION_DISCIPLINE Is Null
         THEN  'UNALOCATED'
         ELSE  TEMP_ACTION_DISCIPLINE
    END          AS ACTION_DISCIPLINE, This assumes that temp_action_discipline is a string. (All THEN and ELSE clauses must return the same data type, or at least compatable types.)
    CASE is the most general way of doing IF-THE-ELSE logic in Oracle SQL.
    For certain special situations, there may be shorter ways.
    Testing a variable to see whether it is NULL or not is one of those situations, so you could also say
    NVL2 ( TEMP_ACTION_DISCIPLINE
         , TEMP_ACTION_DISCIPLINE
         , 'UNALOCATED'
    This site noramally compresses whitespace. Whenever you post formatted text here (and code should always be formatted), type these 6 characters:
    (all small letters, inside curly brackets) before and after formatted sections.
    Edited by: Frank Kulash on Jan 21, 2010 10:41 AM
    After reading Bluefrog's answer, I realized that you're testing and possibly returning the same thing, temp_action_discipline.
    In that case, NVL, like Bluefrog suggested, is the best thing to do.  CASE and NVL2, as shown above, will give the right results, but they're more complicated than you need for this job.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Compile a procedure /SQL file using JDBC?

    Is there a way we can compile a procedure or even a smiple SQL file using JDBC?
    Or in other words can "@ <file name with path>" be done using JDBC? Has anyone tried this before?
    I have five different databases, and i want to be able to compile my stored procedures at once on all my 5 databases. So, if we know if this is possible in JDBC?
    THanks

    right, as a matter of fact i wanted some pointers on how to run these SQL commands using JDBC.
    Like, set serveroutput on
    set feedback on
    @ filename or start filename
    show error
    etc.

  • Unable to connect to Oracle Database using Oracle Sql developer 2.1.1.64

    Hi Everyone,
    I am searching for some help regarding my problem with Oracle connectivity. I have installed Oracle 11g release 2 on my Windows XP Professional Laptop. For a few days after installation i could connect to the Oracle database with the SYSTEM account using Oracle SQL developer ( installed on the same Laptop) but now i am unable to do so.It gives me this annoying message:
    An error was encountered performing the required operation  Got a minus one from read call .Vendor code 0
    However i am able to connect using Sql Plus by supplying the username SYSTEM and the corresponding password.
    My TNSNAMES .ora file is as follows:
    ORACLE =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = ORACLE)
    ORACLR_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (CONNECT_DATA =
    (SID = CLRExtProc)
    (PRESENTATION = RO)
    My Listener.ora file is as follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = CLRExtProc)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ONLY:D:\app\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    (SID_DESC =
    (GLOBAL_DBNAME = Oracle)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (SID_NAME = Oracle)
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (PROTOCOL_STACK =
    (PRESENTATION = GIOP)
    (SESSION = RAW)
    ADR_BASE_LISTENER = D:\app
    My Sqlnet.ora file is as follows:
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
    I am new to Oracle and so i need someone in this forum who can help me resolve this problem. Also i even tried connecting to the database using Toad 10.5.0.41. It give me the following error:
    ORA 12537 : TNS Connection closed
    Thanks for your patience and help in advance.
    ---Prashant

    Hello Irian and Sue,
    I can connect to the Oracle database using SQL Plus. Now when i TNSPING ORACLE from command line i get the following message :
    Used parameter files:
    D:\app\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =localhost
    *)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORACLE)))*
    TNS-12537: TNS:connection closed
    Thanks for your response to my initial post.Do u have any other methods to resolve this?

  • How to use lengthy query in a "SQL Command from Variable"

    My oracle SQL Query length is more than 14000 characters, so how can i use this for "SQL command from variable".
    Sarvan

    Either create a view or a table valued UDF. Using stored procedure in OLEDB source has some gotchas it will not pick up metadata information by default due to late binding.
    http://consultingblogs.emc.com/jamiethomson/archive/2006/12/20/SSIS_3A00_-Using-stored-procedures-inside-an-OLE-DB-Source-component.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Using bind variables in Oracle SQL developer

    Hi all,
    i am using Oracle SQL developer. i want to use the bind variable in my sql.
    variable myid number :=1;
    select * from mds_3618_request where id = :myid;
    but i am getting the below error.
    Error starting at line 2 in command:
    select * from mds_3618_request where id = :myid
    Error report:
    SQL Error: Missing IN or OUT parameter at index:: 1
    Does Oracle SQL developer support bind variables in the SQL statements?
    thanks in Advance
    Vali Shaik

    You are probable going to get a quicker answer on this forum : SQL Developer
    -- Andy

  • Taking snapshot of oracle tables to sql server using transactional replication is taking a long time

    Hi All,
    I am trying to replicate around 200 oracle tables onto sql server using transaction replication and it taking a long time i.e the initial snapshot is taking more than 24 hrs and it still going on.
    Is there any way to replicate those these tables faster?
    Kindly help me out..
    Thanks

    Hi,
    According to the description, I know the replication is working fine. But it is very slow. 
    1. Check the CPU usage on Oracle publisher and SQL Server. This issue may due to slow client processing (Oracle performance) or Network performance issues.
    2. Based on SQL Server 2008 Books Online ‘Performance Tuning for Oracle Publishers’ (http://msdn.microsoft.com/en-us/library/ms151179(SQL.100).aspx). You can enable the transaction
    job set and follow the instructions based on
    http://msdn.microsoft.com/en-us/library/ms147884(v=sql.100).aspx.
    2. You can enable replication agent logging to check the replication behavior. You may follow these steps to collect them:
    To enable Distribution Agent verbose logging. Please follow these steps:
    a. Open SQL Server Agent on the distribution server.
    b. Under Jobs folder, find out the Distribution Agent.
    c. Right click the job and choose Properties.
    d. Select Steps tap, it should be like this:
    e. Click Run agent and click Edit button, add following scripts by the end of scripts in the command box:
            -Output C:\Temp\OUTPUTFILE.txt -Outputverboselevel 2
    f. Exit the dialogs
     For more information about the steps, please refer to:
    http://support.microsoft.com/kb/312292
    Hope the information helps.
    Tracy Cai
    TechNet Community Support

  • How to execute command(program) from external file in Oracle SQL developer

    Hi,
    Does anyone know, Oracle SQL developer version 1.0.0.14.67 got any function that can execute command from an external file?
    Example, i have 100 insert SQL inside a text file,
    and i want to use Oracle SQL developer to execute it. How do i read from my text file? Thanks a lots.

    If you're new to Oracle, do yourself and us a favour: read some tutorials and manuals. What sqldev's worth, better download the latest version (1.1.2), lots of fixes and enhancements...
    Now for the big popper: to run an external file: @file
    Best of luck,
    K.

Maybe you are looking for

  • Error oracle.apps.bne.exception in FSG and WEB ADI after upgrade

    Hi All, Hi, We have four Application Instances and one Database with R12.0.6 and DB version 11.1.0.7 with Load balancer Configuration. The Application is running fine with Load balancer configuration, But we are facing the below issue with report man

  • How to get Font's associated with a pdf document.

    Hi All, I am currently working on a project related to Document Management in SAP. For this I have a set of pdf document's that needs to be classified as 'searchable' and 'Non-searchable'. I am planning to identify the document based on Font contents

  • Windows Server Backup won't progress

    Hello, Recently, wbadmin on our Windows2008 std. can't complete its backup (seems breezed at the 30% -.). I tried to start wbadmin  by command line but breezed (at 30%) .  I also checked if there are any bad sectors on the volumes. I ran the chkdsk  

  • Where did the multimedia go for my iBooks in iOS 8?

    Since upgrading to iOS8 I am no longer able to access audio features for iBooks which have audio embedded on a page. For instance, tapping on an item to hear a sound. The functionality is simply gone for all books I have in my library. Any suggestion

  • ITunes Podcast Downloading RSS Feed

    Hi, I'm trying to submit a podcast, but it keeps asking for an RSS feed. What is this? How do i figure out what to put in?