Testing SQL Query on ORACLE SQL Developer - beginner











up vote
0
down vote

favorite












I'm new to Oracle SQL Developer and SQL in general. I have the following questions:



1) I'm connected to my company's database. I have access to the views. How do test out SQL query on Oracle SQL Developer as I'm trying to ensure
that the result is in line with what I expect or that it even works. For example, when I write VBA code in Excel I a) debug, b) debug.print variable to immediate window to instropect them.
I want to find out how to do that in Oracle SQL Developer.



2) How do I bring up results window in Oracle SQL Developer?



3) I tried to run the following SQL query but I got the following error message.



spool "C:myfolderTEST_sql.csv";
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
spool off;


Error message:



Error starting at line : 2 in command -
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
Error at Command Line : 4 Column : 10
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:









share|improve this question






















  • are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
    – thatjeffsmith
    Nov 20 at 12:30










  • your last line is also wrong, see my answer below
    – thatjeffsmith
    Nov 20 at 12:37















up vote
0
down vote

favorite












I'm new to Oracle SQL Developer and SQL in general. I have the following questions:



1) I'm connected to my company's database. I have access to the views. How do test out SQL query on Oracle SQL Developer as I'm trying to ensure
that the result is in line with what I expect or that it even works. For example, when I write VBA code in Excel I a) debug, b) debug.print variable to immediate window to instropect them.
I want to find out how to do that in Oracle SQL Developer.



2) How do I bring up results window in Oracle SQL Developer?



3) I tried to run the following SQL query but I got the following error message.



spool "C:myfolderTEST_sql.csv";
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
spool off;


Error message:



Error starting at line : 2 in command -
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
Error at Command Line : 4 Column : 10
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:









share|improve this question






















  • are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
    – thatjeffsmith
    Nov 20 at 12:30










  • your last line is also wrong, see my answer below
    – thatjeffsmith
    Nov 20 at 12:37













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm new to Oracle SQL Developer and SQL in general. I have the following questions:



1) I'm connected to my company's database. I have access to the views. How do test out SQL query on Oracle SQL Developer as I'm trying to ensure
that the result is in line with what I expect or that it even works. For example, when I write VBA code in Excel I a) debug, b) debug.print variable to immediate window to instropect them.
I want to find out how to do that in Oracle SQL Developer.



2) How do I bring up results window in Oracle SQL Developer?



3) I tried to run the following SQL query but I got the following error message.



spool "C:myfolderTEST_sql.csv";
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
spool off;


Error message:



Error starting at line : 2 in command -
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
Error at Command Line : 4 Column : 10
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:









share|improve this question













I'm new to Oracle SQL Developer and SQL in general. I have the following questions:



1) I'm connected to my company's database. I have access to the views. How do test out SQL query on Oracle SQL Developer as I'm trying to ensure
that the result is in line with what I expect or that it even works. For example, when I write VBA code in Excel I a) debug, b) debug.print variable to immediate window to instropect them.
I want to find out how to do that in Oracle SQL Developer.



2) How do I bring up results window in Oracle SQL Developer?



3) I tried to run the following SQL query but I got the following error message.



spool "C:myfolderTEST_sql.csv";
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
spool off;


Error message:



Error starting at line : 2 in command -
SELECT /*csv*/ CLIENT_NAME, ORDER_ID, PRODUCT,
QUANTITY, to_char(CREATION_DATE,'mm/dd/yyyy
hh24:mi:ss') as CREATION_DT
FROM reports.REPORT_ORDER
ORDER BY ORDER_ID
FETCH FIRST 5 ROWS;
Error at Command Line : 4 Column : 10
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:






sql debugging oracle-sqldeveloper






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 2:54









tkj80

234




234












  • are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
    – thatjeffsmith
    Nov 20 at 12:30










  • your last line is also wrong, see my answer below
    – thatjeffsmith
    Nov 20 at 12:37


















  • are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
    – thatjeffsmith
    Nov 20 at 12:30










  • your last line is also wrong, see my answer below
    – thatjeffsmith
    Nov 20 at 12:37
















are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
– thatjeffsmith
Nov 20 at 12:30




are you on a 12c database? fetch first syntax won't work on 7, 8, 9, 10, or 11 databases
– thatjeffsmith
Nov 20 at 12:30












your last line is also wrong, see my answer below
– thatjeffsmith
Nov 20 at 12:37




your last line is also wrong, see my answer below
– thatjeffsmith
Nov 20 at 12:37












1 Answer
1






active

oldest

votes

















up vote
1
down vote













You have two ways to execute a query in SQL Developer.



As a script:



spool c:usersjdsmithso.csv
select /*csv*/ first_name,
last_name,
to_char(hire_date,'mm/dd/yyyy hh24:mi:ss') hire_date
from employees
order by employee_id
fetch first 5 rows only;
spool off


enter image description here



Execute with F5 (or use the 2nd button on the Worksheet toolbar)



This will walk the contents of your SQL Worksheet (unless you have highlighted text, and then only that), and put it through our script (SQL*Plus) engine. That's how the SPOOL commands will be executed - those happen on the client, and not by the database.



Your other option is to just execute the query.



enter image description here



Your SINGLE query will be executed, and the first page of results will be returned to a data grid. As you scroll through the results, more rows will be fetched, until they are all back.



You are getting an error with your code, because either:




  1. you're not on at least Oracle Database 12c, where FETCH FIRST syntax was added

  2. AND you forgot the 'ONLY' keyword on your FETCH






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385547%2ftesting-sql-query-on-oracle-sql-developer-beginner%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You have two ways to execute a query in SQL Developer.



    As a script:



    spool c:usersjdsmithso.csv
    select /*csv*/ first_name,
    last_name,
    to_char(hire_date,'mm/dd/yyyy hh24:mi:ss') hire_date
    from employees
    order by employee_id
    fetch first 5 rows only;
    spool off


    enter image description here



    Execute with F5 (or use the 2nd button on the Worksheet toolbar)



    This will walk the contents of your SQL Worksheet (unless you have highlighted text, and then only that), and put it through our script (SQL*Plus) engine. That's how the SPOOL commands will be executed - those happen on the client, and not by the database.



    Your other option is to just execute the query.



    enter image description here



    Your SINGLE query will be executed, and the first page of results will be returned to a data grid. As you scroll through the results, more rows will be fetched, until they are all back.



    You are getting an error with your code, because either:




    1. you're not on at least Oracle Database 12c, where FETCH FIRST syntax was added

    2. AND you forgot the 'ONLY' keyword on your FETCH






    share|improve this answer

























      up vote
      1
      down vote













      You have two ways to execute a query in SQL Developer.



      As a script:



      spool c:usersjdsmithso.csv
      select /*csv*/ first_name,
      last_name,
      to_char(hire_date,'mm/dd/yyyy hh24:mi:ss') hire_date
      from employees
      order by employee_id
      fetch first 5 rows only;
      spool off


      enter image description here



      Execute with F5 (or use the 2nd button on the Worksheet toolbar)



      This will walk the contents of your SQL Worksheet (unless you have highlighted text, and then only that), and put it through our script (SQL*Plus) engine. That's how the SPOOL commands will be executed - those happen on the client, and not by the database.



      Your other option is to just execute the query.



      enter image description here



      Your SINGLE query will be executed, and the first page of results will be returned to a data grid. As you scroll through the results, more rows will be fetched, until they are all back.



      You are getting an error with your code, because either:




      1. you're not on at least Oracle Database 12c, where FETCH FIRST syntax was added

      2. AND you forgot the 'ONLY' keyword on your FETCH






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        You have two ways to execute a query in SQL Developer.



        As a script:



        spool c:usersjdsmithso.csv
        select /*csv*/ first_name,
        last_name,
        to_char(hire_date,'mm/dd/yyyy hh24:mi:ss') hire_date
        from employees
        order by employee_id
        fetch first 5 rows only;
        spool off


        enter image description here



        Execute with F5 (or use the 2nd button on the Worksheet toolbar)



        This will walk the contents of your SQL Worksheet (unless you have highlighted text, and then only that), and put it through our script (SQL*Plus) engine. That's how the SPOOL commands will be executed - those happen on the client, and not by the database.



        Your other option is to just execute the query.



        enter image description here



        Your SINGLE query will be executed, and the first page of results will be returned to a data grid. As you scroll through the results, more rows will be fetched, until they are all back.



        You are getting an error with your code, because either:




        1. you're not on at least Oracle Database 12c, where FETCH FIRST syntax was added

        2. AND you forgot the 'ONLY' keyword on your FETCH






        share|improve this answer












        You have two ways to execute a query in SQL Developer.



        As a script:



        spool c:usersjdsmithso.csv
        select /*csv*/ first_name,
        last_name,
        to_char(hire_date,'mm/dd/yyyy hh24:mi:ss') hire_date
        from employees
        order by employee_id
        fetch first 5 rows only;
        spool off


        enter image description here



        Execute with F5 (or use the 2nd button on the Worksheet toolbar)



        This will walk the contents of your SQL Worksheet (unless you have highlighted text, and then only that), and put it through our script (SQL*Plus) engine. That's how the SPOOL commands will be executed - those happen on the client, and not by the database.



        Your other option is to just execute the query.



        enter image description here



        Your SINGLE query will be executed, and the first page of results will be returned to a data grid. As you scroll through the results, more rows will be fetched, until they are all back.



        You are getting an error with your code, because either:




        1. you're not on at least Oracle Database 12c, where FETCH FIRST syntax was added

        2. AND you forgot the 'ONLY' keyword on your FETCH







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 12:45









        thatjeffsmith

        7,15911039




        7,15911039






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385547%2ftesting-sql-query-on-oracle-sql-developer-beginner%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen