SQL query - show integer number as text

Hello,
how can I reads data from the db that is either "-1" or "1" (it's define as integer)
and display as 'YES' or 'NO' ?
Thank you
Gian

Hi,
You can also do this:
select decode(<your_column>,-1,'YES','NO') from <your_table>;
Peter D.

Similar Messages

  • Report- Pl/sql function returning sql query parsing page items as text?

    Hi Team,
    I am facing a strange issue .
    I have four page items namely
    1)JOB_CODE
    2)MIN_EXP
    3) MAX_EXP
    4) SOURCES1
    I have a report of the type "Pl/sql function returning sql query"
    declare
    v_sql varchar2(4000);
    begin
    if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    end if;
    insert into query_list values (v_sql);
    insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
    return v_sql;
    end;
    Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
    Now I select the data from the debug tables.
    select unique(query) from query_list;
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
    select * from debug;
    JOBCODE     MINEX     MAXEX     SOURCE
    21     1     10     donkeyHire
    And if I run the query in sql I get some records returned
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
    V_CANDIDATE_ID     V_FNAME     V_CURRENT_EMPLOYER     V_EXPERIENCE_YEARS
    2     Vengu     Andale Tech     4
    But the record does not show up in the report!
    does this type of report parse page items as text?
    Why is it so?
    Waiting for an early reply.
    Thanks,
    venkat

    Venkat - You don't want to put ':SOURCES1' in quotes like that.
    Scott

  • Sql query to get number of days monthwise

    Hi,
    i am new to sql, can anyone please tell me query to find number of working days between two dates month wise.
    say
    firstdate last date
    21/03/2011 25/06/2011
    march april may june
    9 22 23 18

    Hi,
    918373 wrote:
    even a result like,
    stud_id month amount
    1234 MAR-11 xyz
    1234 JUL-11 ...Please post the exact output that you want.
    Do you want 'xyz' in the output, or do you want a number like 42 (2 hours * 6 weekdays in March 2011, plus 5 hpours * 6 weekdays = 12 + 30 = 42)?
    If you want 42, then post 42. Spend 5 minutes (if it comes to that much) with a calendar and a calculator to get the exact results you want.
    >
    >
    is much better,
    in that case i want it as a view, so that i can get further details from the view....Substituting your table and column names, into the query I posted earlier and replacing COUNT (*) with SUM (no_of_hours), the query is
    WITH     cntr     AS
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX (enddate - startdate)     AS days_in_range
                  FROM    class_dets
         CONNECT BY     LEVEL     <= 1 + days_in_range
    SELECT       x.stud_id
    ,       TO_CHAR ( TRUNC (x.startdate + c.n, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       SUM (no_of_hours)          AS total_hours
    FROM       class_dets  x
    JOIN       cntr        c  ON   x.enddate >= x.startdate + c.n
    WHERE       TO_CHAR ( x.startdate + c.n
                  , 'DY'
                , 'NLS_DATE_LANGUAGE=ENGLISH'     -- If necessary
                )      NOT IN ('SAT', 'SUN')
    GROUP BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ORDER BY  x.stud_id
    ,            TRUNC (x.startdate + c.n, 'MONTH')
    ;The output, with the sample data you posted, is:
    `  STUD_ID MONTH                                     TOTAL_HOURS
          1234 March 2011                                         42
          1234 April 2011                                        147
          1234 May 2011                                          154
          1234 June 2011                                         154
          1234 July 2011                                          72
          1234 August 2011                                        46
          1234 September 2011                                     14
          1235 June 2011                                          36
          1235 July 2011                                          84
          1235 August 2011                                        92
          1235 September 2011                                     88
          1235 October 2011                                       12
          1236 June 2012                                          56
          1236 July 2012                                         154
          1236 August 2012                                        14Aside from pivoting, is that what you want?
    i edited the your query,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=1236), 'DD/MM/YYYY')     AS end_dateInstead of the 2 lines above, the query I posted had
    SELECT  MAX (enddate - startdate)     AS days_in_rangeWhy did you make that change?
    The first argument to TO_DATE is supposed to be a string. You're calling TO_DATE with this as the first argument
    (select startdate from class_dets where stud_id=1236)which is a DATE, not a string.
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH')
    ORDER BY TRUNC (a_date, 'MONTH')
    it works very well, but instead of specifying stud_id as 1236,
    but when i say,
    WITH     all_dates     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ((select enddate from class_dets where stud_id=cd.stud_id), 'DD/MM/YYYY')     AS end_date
                   FROM     dual
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    SELECT     cd.stud_id,TO_CHAR ( TRUNC (a_date, 'MONTH')
              , 'fmMonth YYYY'
              )               AS month
    , count(*)
    ,     COUNT (*) * (select fee from class_dets where stud_id=1236) * (select no_of_hours from class_dets where stud_id=1236)               AS amount
    FROM     all_dates,class_dets cd
    WHERE     a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY TRUNC (a_date, 'MONTH'),cd.stud_id
    ORDER BY TRUNC (a_date, 'MONTH'),cd.stud_id
    i get error
                   SELECT     TO_DATE ((select startdate from class_dets where stud_id=cd.stu_id), 'DD/MM/YYYY')     AS start_date
    ERROR at line 6:
    ORA-00904: "CD"."STU_ID": invalid identifierThere's no column called stu_id in class_dets. There is a column called stud_id (with 2 'd's).
    >
    what should i do?
    (sorry about the query format...how display query in a formatted way? )This site noramlly compresses whitespace.
    Whenever you post formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Discoverer Report showing Null VS Show SQL query showing results !!!

    I created a simple Cross Tab Discoverer report from a custom SQL which has a calculation for balances. The output is giving all null values even though there are balances. The output doesn't seem right. So I copied the query from Tools-->Show SQL and ran the query in the TOAD where I'm showing balances for the report. I don't understand why it is not showing in the discoverer. Please help.
    Thanks
    Edited by: PA1B on Jan 27, 2010 11:40 AM

    Sorry for late reply.
    Below is the Show SQL query. I don't think the query is application dependent. C_1 is my calculation.
    SELECT o279709.SEGMENT3 as E279727,
    o279709.SEGMENT4 as E279728,
    CASE WHEN o279709.CURRENCY_CODE = 'USD' AND o279709.TRANSLATED_FLAG <> 'Y' THEN SUM(o279709.ENDING_BAL) ELSE 0 END as C_1,
    GROUPING_ID(o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG) as GID
    FROM ( --Foriegn Entity USD Balances
    SELECT                B.SEGMENT1,
                                       B.SEGMENT2,     
                                       B.SEGMENT3,
                                  (select distinct substr(cat.COMPILED_VALUE_ATTRIBUTES,5,1) from apps.fnd_flex_values cat
                   where FLEX_VALUE_SET_ID = (select bat.FLEX_VALUE_SET_ID from apps.fnd_id_flex_structures_vl aat, apps.fnd_id_flex_segments_vl bat
                                                                                                                       where bat.id_flex_code = 'GL#' and
                                                                                                                            bat.id_flex_code = aat.id_flex_code and
                                                                                                                            aat.APPLICATION_ID = bat.APPLICATION_ID and
                                                                                                                            aat.APPLICATION_ID = 101 and
                                                                                                                            bat.SEGMENT_NAME = 'Prime Account' and
                                                                                                                            aat.id_flex_num = bat.id_flex_num
                                                                                                                            and bat.id_flex_num in (select distinct chart_of_accounts_id from apps.gl_code_combinations gat
                                                                                                                                                                              where gat.code_combination_id = A.code_combination_id))
                                       and cat.flex_value = b.segment3) ACCT_TYPE ,
                                       B.SEGMENT4,
                                       B.SEGMENT5,
                                       B.SEGMENT6,
                                       B.SEGMENT7,
                                       B.SEGMENT8,
                                       B.SEGMENT9,
                                       B.SEGMENT10,
                                       B.SEGMENT11,
                                       B.SEGMENT12,
                                       B.SEGMENT13,
                                       C.NAME,
    A.SET_OF_BOOKS_ID,
                                       A.CURRENCY_CODE,A.TRANSLATED_FLAG,
                                  SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0)) BEG_BAL,
                                  SUM(NVL(A.PERIOD_NET_DR,0)) DEBITS,
    SUM( NVL(A.PERIOD_NET_CR,0)) CREDITS ,
    A.PERIOD_NAME,
                                  SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0))+ SUM(NVL(A.PERIOD_NET_DR,0) - NVL(A.PERIOD_NET_CR,0)) ENDING_BAL
    FROM                     APPS.GL_BALANCES A ,
                                       APPS.GL_CODE_COMBINATIONS B,
                                       APPS.GL_SETS_OF_BOOKS     C
    WHERE                     A.CODE_COMBINATION_ID = B.CODE_COMBINATION_ID
    --AND                           A.PERIOD_NAME = 'SEP-09'
    AND                          C.SET_OF_BOOKS_ID = A.SET_OF_BOOKS_ID
    --AND                           A.TRANSLATED_FLAG <> 'Y'
    --AND                           B.SEGMENT1 = '83101'
    --AND                           B.SEGMENT3 = '14602'
    --AND                           A.SET_OF_BOOKS_ID = 77
    --AND                           A.CURRENCY_CODE = 'USD'
    GROUP BY           A.CODE_COMBINATION_ID,
                                  B.SEGMENT1,
                                       B.SEGMENT2,     
                                       B.SEGMENT3,
                                       B.SEGMENT4,
                                       B.SEGMENT5,
                                       B.SEGMENT6,
                                       B.SEGMENT7,
                                       B.SEGMENT8,
                                       B.SEGMENT9,
                                       B.SEGMENT10,
                                       B.SEGMENT11,
                                       B.SEGMENT12,
                                       B.SEGMENT13,          
                                       A.CURRENCY_CODE,
                                       A.TRANSLATED_FLAG,
                                       C.NAME,A.PERIOD_NAME,
    A.SET_OF_BOOKS_ID
    ) o279709
    WHERE (o279709.PERIOD_NAME = 'DEC-09')
    AND (o279709.SET_OF_BOOKS_ID <> 72)
    AND (o279709.SEGMENT12 = '000')
    AND (o279709.SEGMENT3 IN ('10101','10301','10502','12001'))
    AND (o279709.SEGMENT1 IN ('82901','82902','82903','83001','83003','83201'))
    GROUP BY GROUPING SETS(( o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG ),( o279709.SEGMENT3,o279709.SEGMENT4 ),( o279709.SEGMENT3 ))
    HAVING (GROUP_ID()=0)
    ORDER BY GID DESC;
    Thanks,
    PA1
    Edited by: PA1B on Jan 29, 2010 12:50 PM

  • SQL query to count number of VMs

    In OVM 2.2 I could run a SQL query against the OVM database to count the number of VMs that I had created, for automated reporting purposes.
    I've looked at the 3.1 OVM database and it looks like most of the data is kept in BLOB columns. So does anyone know how I might query the 3.1 database to count the number of VMs?
    Thanks.

    Hi,
    Combine the relevant data from the three tables (using UNION ALL) in a sub-query. without the GROUP BY.
    Your main query can select from the sub-query's result set, as if it were a table. Do the GROUP BY in the main query.
    That is:
    WITH     u     AS
         SELECT     TO_CHAR (emp_start, 'YYYY') AS yr     FROM     Adminstaff
        UNION ALL
         SELECT     TO_CHAR (emp_start, 'YYYY') AS yr     FROM     Clerk
        UNION ALL
         SELECT     TO_CHAR (emp_start, 'YYYY') AS yr     FROM     ITstaff
    SELECT     COUNT (*)      AS cnt
    ,     yr
    FROM     u
    GROUP BY     yr
    ORDER BY     cnt     DESC
    ;Since empno is the primary key, it's easier not to mention empno at all in the sub-query, and use "COUNT (*)" instead of "COUNT (empno)" in the main query. The results are the same.
    It might be a little more efficient to GROUP BY in all three branches of the sub-query, and then to SUM the results in another GROUP BY in the main query. That means more code, of course, which I'll leave as an exercise for you.
    Why do you have three separate tables? I can understand that nobody else wants to be near the IT Staff, but it seems like lots of things (including this job) would be a lot simpler if all employees were all in one table, with a column to designate to which group (Adminstaff, Clerk or ITStaff) each one belongs.

  • Place Cursor not showing the (#) number of text files loaded

    Hi all,
    I´m using Indesign CS3, updated to the latest patch availabe, this is 5.0.4. I´m using Windows 7 32b.
    When trying to import text files via File > Place and I select 2 o more text files and click OK, the Place Cursor should show in parenthesis the number of files loaded right?. Well the bizarre issue I´m dealing with is that this (#) doesn´t show up. I can see the little preview of the text to be imported but not the (#) number of text files loaded. If I press the down arrow key on the keyboard the mini text updates and cicles through all the loaded texts. That's fine.
    I wanted to screen capture this issue so I installed Techsmith Snagit 9 on my computer. When I was ready to capture the Place Cursor on Indesign, Snag it captured it showing (2) documents loaded. ???? What´s going on?
    Anyone could explain this issue?
    I´ve already rebuild my Preferences with no luck.
    What I see in Indesign http://img214.imageshack.us/img214/1774/whatiseeinindesign.jpg
    What I see after the screen capture with Snag it 9 http://img299.imageshack.us/img299/6001/screencaptureinsnagit.jpg
    Thanks for your help.
    Francesc.

    I use jdk1.5 on Xp. Ok, I'll check it again

  • SQL query automation and output to text file

    The bcp utility should handle this task pretty easily for you. The documentation is available here.

    I know enough SQL to get me by with the few things I currently do in it (but would always like to know and do more).  Anyway, I was just recently asked if I could come up with a way to automate the execution of a SQL query we currently manually run, and then have the results of that query output (instead of to the screen in SSMS) to a text file with the ".dat" extension.  I've never automated a SQL query before nor have I had the results output to a file.  Can anyone give me some pointers on how to tackle this?
    The query currently calls to a stored procedure (which does all the work) and just executes it with some given dates from the query so I'm thinking the output will need to come from the stored procedure (and the code for output to a file added there?)
    This topic first appeared in the Spiceworks Community

  • SQL query to retrieve a Rich Text Memo field

    What will be the select command to retrieve a field [ToxPatMemo] which is in RTF format? I just want to retrieve the Text contents without all the characters for underline, bold, etc.
    Thanks in advance,
    Raul
    Raul Rego

    Hi jjkgr,
    We can create a function to convert RTF in a text column to plain text in SQL Server.
    As I have tested in my local environment, the following query is for your reference:
    CREATE FUNCTION dbo.fnParseRTF
    @rtf VARCHAR(8000)
    RETURNS VARCHAR(8000)
    AS
    BEGIN
    DECLARE @Stage TABLE
    Chr CHAR(1),
    Pos INT
    INSERT @Stage
    Chr,
    Pos
    SELECT SUBSTRING(@rtf, Number, 1),
    Number
    FROM master..spt_values
    WHERE Type = 'p'
    AND SUBSTRING(@rtf, Number, 1) IN ('{', '}')
    DECLARE @Pos1 INT,
    @Pos2 INT
    SELECT @Pos1 = MIN(Pos),
    @Pos2 = MAX(Pos)
    FROM @Stage
    DELETE
    FROM @Stage
    WHERE Pos IN (@Pos1, @Pos2)
    WHILE 1 = 1
    BEGIN
    SELECT TOP 1 @Pos1 = s1.Pos,
    @Pos2 = s2.Pos
    FROM @Stage AS s1
    INNER JOIN @Stage AS s2 ON s2.Pos > s1.Pos
    WHERE s1.Chr = '{'
    AND s2.Chr = '}'
    ORDER BY s2.Pos - s1.Pos
    IF @@ROWCOUNT = 0
    BREAK
    DELETE
    FROM @Stage
    WHERE Pos IN (@Pos1, @Pos2)
    UPDATE @Stage
    SET Pos = Pos - @Pos2 + @Pos1 - 1
    WHERE Pos > @Pos2
    SET @rtf = STUFF(@rtf, @Pos1, @Pos2 - @Pos1 + 1, '')
    END
    SET @Pos1 = PATINDEX('%\cf[0123456789][0123456789 ]%', @rtf)
    WHILE @Pos1 > 0
    SELECT @Pos2 = CHARINDEX(' ', @rtf, @Pos1 + 1),
    @rtf = STUFF(@rtf, @Pos1, @Pos2 - @Pos1 + 1, ''),
    @Pos1 = PATINDEX('%\cf[0123456789][0123456789 ]%', @rtf)
    SELECT @rtf = REPLACE(@rtf, '\pard', ''),
    @rtf = REPLACE(@rtf, '\par', ''),
    @rtf = LEFT(@rtf, LEN(@rtf) - 1)
    SELECT @rtf = REPLACE(@rtf, '\b0 ', ''),
    @rtf = REPLACE(@rtf, '\b ', '')
    SELECT @rtf = STUFF(@rtf, 1, CHARINDEX(' ', @rtf), '')
    RETURN @rtf
    END
    DECLARE @Sample TABLE (ID INT, data VARCHAR(8000))
    INSERT @Sample
    SELECT 1, '{\rtf1\ansi\ansicpg1252\deff0\deflang1053{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
    {\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;}
    {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 P\cf1 e\cf0 ter\par
    \cf2 L\cf0 ar\b s\b0 s\cf3 o\cf0 n\par
    }' UNION ALL
    SELECT 2, '{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
    {\colortbl ;\red0\green0\blue0;}
    {\*\generator Riched20 5.50.99.2014;}\viewkind4\uc1\pard\cf1\f0\fs18\lang1033 ~200 LF streambank stabilization to provide structural protection\par}'
    SELECT ID,
    dbo.fnParseRTF(data)
    FROM @Sample
    The result of this query is:
    1              Peter Larsson
    2              ~200 LF streambank stabilization to provide structural protection
    If you have any question, please feel free to let me know.
    Regards,
    Jerry Li

  • SQL Query...number to time

    Hi,
    I want to know how to a convert number (say, 54678) into hh:mi:ss format.
    Any help.
    Thanks.

    You can test/troubleshoot it. This may or may not be perfect, you need to reverse engineer it and find (any) mistakes/logic errors. Hint: there is one.
    set serveroutput on
    create or replace procedure get_time (sod in number) as
      v_diff number;
      v_current number;
      v_date date;
    begin
      v_current := to_number(to_char(sysdate,'SSSSS'));
    --  dbms_output.put_line('v_current is '||v_current);
      v_diff := v_current - sod;
    --  dbms_output.put_line('v_diff is '||v_diff);
      --evaluate the difference
      if v_diff < 0 then
        --means number of seconds is in the future
        v_date := sysdate - v_diff/86400;
      elsif v_diff > 0 then
        --means sod is in the past
        v_date := sysdate + v_diff/86400;
      else
        --means you got lucky
        v_date := sysdate;
      end if;
      dbms_output.put_line('At the tone, the time is '||to_char(v_date,'HH:MI:SS PM'));
    end;
    exec get_time(54678);
    At the tone, the time is 03:11:18 PM
    PL/SQL procedure successfully completed.Message was edited by:
    stevencallan
    Message was edited by:
    stevencallan

  • Set Text Item To SQL Query Result

    I am trying to set a text item to a SQL query result. Something like the following:
    (I am trying to accomplish this in the SOURCE portion, set to 'SQL Query' source type, of the text item properties)
    SELECT empno FROM emp WHERE empno = :SEARCH_EMPNO;
    This only displays as the literal text when the application renders and not the value from the SQL query.
    I apologize if this has already been posted but I could not find what I am looking for. I have seen posts that reference a pre-region computation but do not know the exact steps to accomplish the results I want.
    Thanks in advance for anyone's time to help me with my issue.
    Kyle

    Scott,
    The literal that displayed (I have fixed it) was the actual SQL statement: SELECT empno FROM emp WHERE empno = :SEARCH_EMPNO;
    I have resolved the issue, using SQL Query as the "Source Type" and Always, replacing any existing value in session state as the "Source Used" for the properties of the item.
    What I was trying to accomplish is a search text item that would return the data for that record in a table into other text items, for each column in that record, for update; based on the search text item as a unique SQL query search for that record.
    Thank you for your quick reply!
    Kyle

  • Creating a directory via a jsp page sql query return

    Is it possible to create a directory based on the results of a sql query?
    i.e.
    My sql query returns application number 1234 for a building application (BC for short).
    Is it possible to create a directory /BC/1234
    It is then proposed to use an iframe to look into the directory so users can place and access scanned documents which are captured during the approval process.
    If so how?
    An example would be great.
    Jason

    Sorry hope your still around I've been away for a while. We've created a samber share to the file server where the documents are stored and mounted it within the web file directory. It works ok if there is an existing directory but if there isn't we want it to be created when the page looks for the folder. I've done this with an asp page it basically did a directory exist test first then create folder if it didn't. The problem is can't find an example of how to do the directory exist test then directory create syntax so an example of both would be great

  • SQL Subscription field shows * only with Dynamic Text Label in SQL query

    We are using Hyperion Analyzer 7.2.x for showing budget and actual data. I have to show this financial data based on the security e.g. person in IT can see only IT dept. data. Hence I want to use dynamic text label <<userid>> for the security based on the person logging in to Analyzer.
    But when I use dynamic text label <<userid>> in the SQL query in SQL Spreadsheet, SQL Subscription field shows * only selection option. Does anyone have idea how to solve this problem?
    Thanks in advance for your help.
    -SV

    Hi
    Okay i know this is a bit crazy way.....but i think this is the solution for your issue.
    Create a report without the where clause (<<useris>>) then add a filter (sql subscription) then you can find all the values that are there in the SQL field (try to increase the query limit it is set to 250 as default) then edit the spreadsheet and add the where clause (<<userid>>).
    This will help you having the filter and the dynamic text label. I think there is an issue when you try to filter it with a where clause.
    Hope it helps.
    CK

  • Show SQL Query to be showed in Text object at the report

    Is there any way where I can take/copy the query showed in "Database->Show SQL Query" to be showed as a field in a TextBox inside the report.
    So it is a bit clearer what I am trying to do, it is to get who, when and what runs that report.
    Thanks in advance
    Tonio

    Hi Toni,
    I am not sure if I have understood your requirement. If you could elaborate what you are trying to do then i may be able to help.
    I understand you want to copy the query which is displayed in DATABASE->Show query name... I hope u are refering to SQ01 trx...
    I am not sure what next part..
    Rgds
    Abhijit

  • How can I show all the results returned by a sql query?

    Hi guys,
    I need your help.
    Let's say I have one table: TableA. Fields of TableA are aleg, anon, apes. The following sentence can return, in general, several rows: select anon from TableA where aleg = somevalue. I'd like to show the result of column anon but no luck. If I try to show the results in a TextArea and the origin is an sql query only shows the first row value. I tried Show as: show as text (based in PLSQL) and coding an anonymous plsql block as
    DECLARE
    v_anon TableA.anon%TYPE;
    CURSOR v_cur IS
         select anon from TableA where aleg = somevalue;
    BEGIN
    OPEN v_cur;
    LOOP
    FETCH v_cur INTO v_anon;
    EXIT WHEN v_cur%NOTFOUND;
    :FIELD_IN_FORM := v_anon;
    END LOOP;
    CLOSE v_cur;
    END;
    but in this case it's not shown any result.
    So the first question is what kind of field should I use to show the result. And the second one is what can I do to being able to show all the results returned by the query (provided that is more than one single row).
    regards

    Hi Denes,
    Just starting with apex. I think I know how to show the results in a report region. I've simplified the posted question.
    A more detailed question would be: Suppose you have a region where you have put several text areas to accommodate the result of a multi-column query (lets say for TableA) that only returns one row, each column value returned put in a different text area. Also you want to show the values of other fields in TableB that depends on some value just retrieved from TableA and that you want all values retrieved (from TableA and the linked TableB) to be show in the same region. Is that possible? If yes, how?
    Thank you in advance

  • Apex 4.2 Report region sql query with "apex_item.text" renders wrongly

    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name=&quot;f01&quot; size=&quot;20&quot; maxlength=&quot;2000&quot; value=&quot;111&quot;  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?
    I need that function "apex_item.text", i cannot remove it.
    Edited by: CharlesRoos on 13.02.2013 15:28
    Edited by: CharlesRoos on 13.02.2013 15:29
    Edited by: CharlesRoos on 13.02.2013 15:29

    CharlesRoos wrote:
    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name="f01" size="20" maxlength="2000" value="111"  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?Ensure that the Display As Column Attribute for the C1 column is Standard Report Column.

Maybe you are looking for