column new_value and display type and value of a variable












0















column dcol new_value mydate noprint
select to_char(sysdate - case
when to_char(sysdate,
'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
when to_char(sysdate,
'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
end,'YYYYMMDD') dcol
from dual;

set feedback off

spool "C:testtest_&mydate..csv";

select /*csv*/ * from REPORTS.TEST;

spool off;


Hi,



I have the above SQL query that was written by someone else. I'm trying to understand and follow it.
I have the following questions - wonder if someone could help me with them?



1) There are 2 instances of 'dcol' in the query:
a) column dcol, then b) select dcol from dual. Is 'dcol' a column name from dual table? It seems that if I replace 'dcol' with 'random_col' -
the query still work the same



2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?



3) How do I debug the SQL query in Oracle SQL Developer? For example, in the following:



select to_char(sysdate - case
when to_char(sysdate,
'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
when to_char(sysdate,
'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
end,'YYYYMMDD') dcol
from dual;


I want to find out: a) what is the value of sysdate?, b) which case, select falls into?



4) If at the end of the SQL query, I add: Define mydate; I would get the following output:



DEFINE MYDATE = "20181126" (VARCHAR2)



Is there other ways to display what the variable mydate is and its type?










share|improve this question



























    0















    column dcol new_value mydate noprint
    select to_char(sysdate - case
    when to_char(sysdate,
    'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
    when to_char(sysdate,
    'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
    end,'YYYYMMDD') dcol
    from dual;

    set feedback off

    spool "C:testtest_&mydate..csv";

    select /*csv*/ * from REPORTS.TEST;

    spool off;


    Hi,



    I have the above SQL query that was written by someone else. I'm trying to understand and follow it.
    I have the following questions - wonder if someone could help me with them?



    1) There are 2 instances of 'dcol' in the query:
    a) column dcol, then b) select dcol from dual. Is 'dcol' a column name from dual table? It seems that if I replace 'dcol' with 'random_col' -
    the query still work the same



    2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?



    3) How do I debug the SQL query in Oracle SQL Developer? For example, in the following:



    select to_char(sysdate - case
    when to_char(sysdate,
    'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
    when to_char(sysdate,
    'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
    end,'YYYYMMDD') dcol
    from dual;


    I want to find out: a) what is the value of sysdate?, b) which case, select falls into?



    4) If at the end of the SQL query, I add: Define mydate; I would get the following output:



    DEFINE MYDATE = "20181126" (VARCHAR2)



    Is there other ways to display what the variable mydate is and its type?










    share|improve this question

























      0












      0








      0








      column dcol new_value mydate noprint
      select to_char(sysdate - case
      when to_char(sysdate,
      'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
      when to_char(sysdate,
      'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
      end,'YYYYMMDD') dcol
      from dual;

      set feedback off

      spool "C:testtest_&mydate..csv";

      select /*csv*/ * from REPORTS.TEST;

      spool off;


      Hi,



      I have the above SQL query that was written by someone else. I'm trying to understand and follow it.
      I have the following questions - wonder if someone could help me with them?



      1) There are 2 instances of 'dcol' in the query:
      a) column dcol, then b) select dcol from dual. Is 'dcol' a column name from dual table? It seems that if I replace 'dcol' with 'random_col' -
      the query still work the same



      2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?



      3) How do I debug the SQL query in Oracle SQL Developer? For example, in the following:



      select to_char(sysdate - case
      when to_char(sysdate,
      'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
      when to_char(sysdate,
      'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
      end,'YYYYMMDD') dcol
      from dual;


      I want to find out: a) what is the value of sysdate?, b) which case, select falls into?



      4) If at the end of the SQL query, I add: Define mydate; I would get the following output:



      DEFINE MYDATE = "20181126" (VARCHAR2)



      Is there other ways to display what the variable mydate is and its type?










      share|improve this question














      column dcol new_value mydate noprint
      select to_char(sysdate - case
      when to_char(sysdate,
      'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
      when to_char(sysdate,
      'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
      end,'YYYYMMDD') dcol
      from dual;

      set feedback off

      spool "C:testtest_&mydate..csv";

      select /*csv*/ * from REPORTS.TEST;

      spool off;


      Hi,



      I have the above SQL query that was written by someone else. I'm trying to understand and follow it.
      I have the following questions - wonder if someone could help me with them?



      1) There are 2 instances of 'dcol' in the query:
      a) column dcol, then b) select dcol from dual. Is 'dcol' a column name from dual table? It seems that if I replace 'dcol' with 'random_col' -
      the query still work the same



      2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?



      3) How do I debug the SQL query in Oracle SQL Developer? For example, in the following:



      select to_char(sysdate - case
      when to_char(sysdate,
      'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
      when to_char(sysdate,
      'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
      end,'YYYYMMDD') dcol
      from dual;


      I want to find out: a) what is the value of sysdate?, b) which case, select falls into?



      4) If at the end of the SQL query, I add: Define mydate; I would get the following output:



      DEFINE MYDATE = "20181126" (VARCHAR2)



      Is there other ways to display what the variable mydate is and its type?







      sql oracle debugging






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 23:43









      tkj80tkj80

      234




      234
























          1 Answer
          1






          active

          oldest

          votes


















          0














          1) dcol is the column_name for the output of the dual query



          select to_char(sysdate - case
          when to_char(sysdate,
          'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
          when to_char(sysdate,
          'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
          end,'YYYYMMDD') dcol
          from dual;


          output.....
          +----------+
          | dcol |
          +----------+
          | 20181126 |
          +----------+


          The first line of your code says
          column dcol new_value mydate noprint.



          This means to store the value of dcol and put that into the "sql plus/sqldeveloper" variable mydate.



          NB This is a sqlplus command which is understood by the sqlplus program/sqldeveloper (Its not a standard PL/SQL) command.



          set feedback off 
          means suppress the query status such as
          42 rows returned..


          2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?.



          You would need a .. to escape the "." in sqlplus/sqldeveloper program.



          Spool command is a sqlplus thing. here you notice that you are creating a "csv" file with the file name as that returned from the 1) output which is present in the variable &mydate



          select /*csv*/ * from REPORTS.TEST;


          This is a syntax in sqldeveloper, which will generate csv file as the output.
          Check this link to see how easy it is to generate csv



          https://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/



          spool off means create the file in C:testtest_20181126.csv



          3) Just run the query as is.



          4) Just give this a try select &mydate from dual;






          share|improve this answer
























          • Did i answer your query

            – George Joseph
            Nov 29 '18 at 14:31











          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',
          autoActivateHeartbeat: false,
          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%2f53490731%2fcolumn-new-value-and-display-type-and-value-of-a-variable%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









          0














          1) dcol is the column_name for the output of the dual query



          select to_char(sysdate - case
          when to_char(sysdate,
          'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
          when to_char(sysdate,
          'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
          end,'YYYYMMDD') dcol
          from dual;


          output.....
          +----------+
          | dcol |
          +----------+
          | 20181126 |
          +----------+


          The first line of your code says
          column dcol new_value mydate noprint.



          This means to store the value of dcol and put that into the "sql plus/sqldeveloper" variable mydate.



          NB This is a sqlplus command which is understood by the sqlplus program/sqldeveloper (Its not a standard PL/SQL) command.



          set feedback off 
          means suppress the query status such as
          42 rows returned..


          2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?.



          You would need a .. to escape the "." in sqlplus/sqldeveloper program.



          Spool command is a sqlplus thing. here you notice that you are creating a "csv" file with the file name as that returned from the 1) output which is present in the variable &mydate



          select /*csv*/ * from REPORTS.TEST;


          This is a syntax in sqldeveloper, which will generate csv file as the output.
          Check this link to see how easy it is to generate csv



          https://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/



          spool off means create the file in C:testtest_20181126.csv



          3) Just run the query as is.



          4) Just give this a try select &mydate from dual;






          share|improve this answer
























          • Did i answer your query

            – George Joseph
            Nov 29 '18 at 14:31
















          0














          1) dcol is the column_name for the output of the dual query



          select to_char(sysdate - case
          when to_char(sysdate,
          'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
          when to_char(sysdate,
          'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
          end,'YYYYMMDD') dcol
          from dual;


          output.....
          +----------+
          | dcol |
          +----------+
          | 20181126 |
          +----------+


          The first line of your code says
          column dcol new_value mydate noprint.



          This means to store the value of dcol and put that into the "sql plus/sqldeveloper" variable mydate.



          NB This is a sqlplus command which is understood by the sqlplus program/sqldeveloper (Its not a standard PL/SQL) command.



          set feedback off 
          means suppress the query status such as
          42 rows returned..


          2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?.



          You would need a .. to escape the "." in sqlplus/sqldeveloper program.



          Spool command is a sqlplus thing. here you notice that you are creating a "csv" file with the file name as that returned from the 1) output which is present in the variable &mydate



          select /*csv*/ * from REPORTS.TEST;


          This is a syntax in sqldeveloper, which will generate csv file as the output.
          Check this link to see how easy it is to generate csv



          https://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/



          spool off means create the file in C:testtest_20181126.csv



          3) Just run the query as is.



          4) Just give this a try select &mydate from dual;






          share|improve this answer
























          • Did i answer your query

            – George Joseph
            Nov 29 '18 at 14:31














          0












          0








          0







          1) dcol is the column_name for the output of the dual query



          select to_char(sysdate - case
          when to_char(sysdate,
          'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
          when to_char(sysdate,
          'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
          end,'YYYYMMDD') dcol
          from dual;


          output.....
          +----------+
          | dcol |
          +----------+
          | 20181126 |
          +----------+


          The first line of your code says
          column dcol new_value mydate noprint.



          This means to store the value of dcol and put that into the "sql plus/sqldeveloper" variable mydate.



          NB This is a sqlplus command which is understood by the sqlplus program/sqldeveloper (Its not a standard PL/SQL) command.



          set feedback off 
          means suppress the query status such as
          42 rows returned..


          2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?.



          You would need a .. to escape the "." in sqlplus/sqldeveloper program.



          Spool command is a sqlplus thing. here you notice that you are creating a "csv" file with the file name as that returned from the 1) output which is present in the variable &mydate



          select /*csv*/ * from REPORTS.TEST;


          This is a syntax in sqldeveloper, which will generate csv file as the output.
          Check this link to see how easy it is to generate csv



          https://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/



          spool off means create the file in C:testtest_20181126.csv



          3) Just run the query as is.



          4) Just give this a try select &mydate from dual;






          share|improve this answer













          1) dcol is the column_name for the output of the dual query



          select to_char(sysdate - case
          when to_char(sysdate,
          'hh24:mi:ss') between '17:00:00' and '23:59:59' then 0
          when to_char(sysdate,
          'hh24:mi:ss') between '00:00:00' and '17:00:00' then 1
          end,'YYYYMMDD') dcol
          from dual;


          output.....
          +----------+
          | dcol |
          +----------+
          | 20181126 |
          +----------+


          The first line of your code says
          column dcol new_value mydate noprint.



          This means to store the value of dcol and put that into the "sql plus/sqldeveloper" variable mydate.



          NB This is a sqlplus command which is understood by the sqlplus program/sqldeveloper (Its not a standard PL/SQL) command.



          set feedback off 
          means suppress the query status such as
          42 rows returned..


          2) "C:testtest_&mydate..csv"; why is there a double '.' as opposed to single '.' right before 'csv'?.



          You would need a .. to escape the "." in sqlplus/sqldeveloper program.



          Spool command is a sqlplus thing. here you notice that you are creating a "csv" file with the file name as that returned from the 1) output which is present in the variable &mydate



          select /*csv*/ * from REPORTS.TEST;


          This is a syntax in sqldeveloper, which will generate csv file as the output.
          Check this link to see how easy it is to generate csv



          https://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/



          spool off means create the file in C:testtest_20181126.csv



          3) Just run the query as is.



          4) Just give this a try select &mydate from dual;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 27 '18 at 2:20









          George JosephGeorge Joseph

          1,60559




          1,60559













          • Did i answer your query

            – George Joseph
            Nov 29 '18 at 14:31



















          • Did i answer your query

            – George Joseph
            Nov 29 '18 at 14:31

















          Did i answer your query

          – George Joseph
          Nov 29 '18 at 14:31





          Did i answer your query

          – George Joseph
          Nov 29 '18 at 14:31




















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53490731%2fcolumn-new-value-and-display-type-and-value-of-a-variable%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

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)