Question - SQL

Hello
I have the following line in a view:
SUBSTR (DECODE (f.kind, 'F', FormatCpf (f.cic) FormatCgc (f.cnpj)), 1.18) the "CPF / CNPJ"
But, the function returns the mask, even when the field is empty.
When the field is empty, I want to return null, is not the result of the function. How?

Thank you

I'm sorry Ryu, there is something I don't understand.
f.CIC and f.cnpj are numeric columns or not?

In your previous post you wrote:

When these fields are greater than zero, I want to return null and the masks...

So I assumed that they where digital, but it seems that they are not numeric the error you get.

If the only requirement is that, if f.cic and f.cnpj are null you want null otherwise you want the result of functions Format use the following syntax:

SUBSTR (DECODE (f.TIPO, 'F', decode(f.cic,null,null,FormatCpf (f.cic)),decode(f.cnpj,null,null,FormatCgc (f.cnpj))), 1,18) as "CPF / CNPJ"

Otherwise, provide the instructions CREATE TABLE and match the output of the sample.

Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/02/query-gerarchiche/]

Tags: Database

Similar Questions

  • Newb question: SQL query on an imported table

    Hi all. I'm a newb, that this issue will probably tell you!
    But I am very interested to familiarize themselves with the Oracle environment.

    I installed 10g Express.
    I was able to set up a new user (schema) profile?

    I created a new table, by importing an Excel file, saved as a CSV file. It has a PK.

    When I log in as an administrator, I can see the table 'discovers' the content.
    However, I can't run a SQL command with the new table.
    It is said Table or view does not exist.

    The table is called "Customers" and contains a column called "City" and I type City Select From Customers.

    Like the Adminisistrator, I have "given" all the rights for the new table to my profile newly created (schema).
    When I connect as long as this new person, I can't see the new table imported into the list of tables, yet alone to run an application or a SQL to it. What did I miss?

    Any tips will be appreciated. Glyn gray...

    Published by: user12501005 on February 7, 2010 11:26

    Hello

    You wrote:
    The original table is still visible to the diagram of the system, but he reports yet again as saying that the table does not exist when I try SQL.
    So is there a reason why a table imported is visible to the user DBA, but SQL does not exist?
    The other imported tables, those the DBA can run SQL still aren't visible to other users (schemas).
    The DBA has "tuned" EVERYTHING to the default HR schema.
    When I connect like HR, I'm unable to find the given table and SQL reports that the table does not exist.

    If I understand that you have created a Table in the schema of the SYSTEM, and you cannot question him by SQL.

    For example, if you then create a table A in the diagram of SYSTEM, you can view the table A if you connect to the database
    SYSTEM or any intended user he has the privilege to CHOOSE ANY TABLE.

    If you are connected to a user (for example, HR), which does not have this privilege, you can not query the Table.

    If you have a privilege to HR as follows:

    connect system/
    grant select on A to HR;
    

    Then you can query the Table has to HR:

    connect HR/
    select * from system.A;
    

    Hope this helps.
    Best regards
    Jean Valentine

  • Question SQL-Lite

    Hello, I was wondering if it would be the right way to implement a database SQL-LITE and if I had to submit my application code runs correctly?

    URI myURI = URI.create("file:///SDCard/flash.db");
    d = DatabaseFactory.create(myURI);
    d.close();
    

    I want to save a database to the SD card and was hoping that this was accomplished over there without any other necessary implementation.  For example whenever I have rn that on the Simulator, I need to create a directory for this database.  What it will be just as easy as this presentation and the database is stored on the sd card?

    Thank you

    Scientist

    Yes, this create a file named flash.db in the SD card, but outside the records.

    To save the file in the folder document from SD card, you can use

    "file:///SDCard/Blackberry/documents"+fileName;

    Hope this helps.

    ------------------------------------------------------------------------------------
    Kudo press to say thank you to the developer.
    Also, press accept it as a button when you got the Solution.

  • newbie question: sql runs under sqlplus but does not compile in pl/sql?

    I have the following two tables, I have a SQL in pl/sql packages so I can use dbms_jobs to automate it however, I get the compile time error. It seems to me that pl/sql dislikes my sql that works well in sqlplus. Here is the error message and my test case?

    mdb_user@cmd > view the error
    PACKAGE BODY DATA_QUALITY_REPORT_P errors:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    10/1 PL/SQL: statement ignored
    13/42 PL/SQL: ORA-00942: table or view does not exist





    create the table S_ORG_EXT
    (
    accnt_type_cd varchar2 (100),
    cust_stat_cd varchar2 (100)
    )
    /

    insert into s_org_ext
    Select column_name, data_type for user_tab_columns where rownum < = 100
    /

    Select * from s_org_ext
    /


    create the table data_quality_report
    (
    RunId number not null,
    report_type number of non-null, - type of report as dup dup or not other measures
    org_level number not null, - organization level nsgn, sgn, shipto
    loc_level number of non-null, - local level by city, by country, by region, grand_total
    name varchar2 (100) not null,-the line output of the tot name.
    Value number not null, - line value of the tot.
    rundate date default sysdate
    )
    /

    create sequence data_quality_report_seq with 1000
    INCREMENT BY 1
    NOCACHE
    NOCYCLE
    /


    insert into data_quality_report
    Select data_quality_report_seq.nextval, 3, 99, 99, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    )
    /

    Select * from data_quality_report
    /



    truncate table data_quality_report

    CREATE or replace PACKAGE data_quality_report_p AS
    function pull_data return data_quality_report.runid%type;
    END data_quality_report_p;
    /


    create or replace package body data_quality_report_p as
    function pull_data return data_quality_report.runid%type is

    new_rid data_quality_report.runid%type;


    Start
    Select data_quality_report_seq.nextval in the double new_rid;

    insert into data_quality_report
    Select new_rid, 3, 999999, 999999, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    );


    Return new_rid;
    exception
    When no_data_found then
    DBMS_OUTPUT. Put_line ("NO_DATA_FOUND handles the exception.");
    while others then
    DBMS_OUTPUT. Put_line ("' handling ANOTHER exception.");


    end; -end pull_data

    end data_quality_report_p;
    /

    Hello

    Sorry, I was not clear about that.
    The owner of the package needs direct privileges (not only privileges through a role) to compile the code, whehter it is DEFINE AUTHID or AUTHID CURRENT_USER. Option (3) does not help in this case; my mistake.

    I usually create packages in the same schema tables they use, which was option (2) in my previous message. There may be good reasons why you can't do that; for example, the package may reference multiple schemas tables. In this case, grant the necessary privileges directly to the owner of the whole.

  • Quick question - SQL + constraint dashboard

    Hello

    I have 3 dashboard invites you: exercise, Qtr, and month and here is my requirement...

    -All 3 dashboard guests must display only values for the past 5 years, including the current year
    -Quarter and months guests should be limited

    Now the problem is, I could achieve the requirement of the 1st or the 2nd but I am unable to make the two together since OBIEE does not show the box 'Force' if we select 'Results' rather than 'all values '. Is there a way to achieve both requirements together?

    I did a lot of searching on Google, but that did not help. So thought I'd check with the experts in this forum.

    Thank you
    Vahib

    You have three columns to the prompt year, quarter, and month, no need sql result...

    In the special effects of the year column write this
    Case when TableA.Year enters the year (current_date)-5 and year (current_date) then TableA.Year end

    Column quarter FX
    When end of TableA.Year between the year (current_date) - 5 and year (current_date) then TableA.Quarter

    special effects of the column for the month
    When end of TableA.Year between the year (current_date) - 5 and year (current_date) then TableA.Month

    Select the constraint for the quarter and month

    Thank you
    Vino

  • The question SQL generated by the motion of the Hyperion Intelligence report

    I have 2 tables and I'm pulling the column 'PRSN_NO' first table (A) and the "POOL_NM" of second column table (B).

    The join between A and B are

    A Left Outer Join B on A.PTY_ID = B.PTY_ID
    AND B.Start_dt < = A.End_dt
    AND B.Start_dt > = A.Start_dt

    The query exported the form

    SELECT DISTINCT AL1. PRSN_NO, AL2. POOL_NM
    OF VADIM_IR. AN AL1
    LEFT OUTER JOIN VADIM_IR. B AL2
    ON (AL1. PTY_ID = AL2. PTY_ID)
    WHERE
    (AL2. Start_dt < = AL1. End_dt
    AND AL2. Start_dt > = AL1. Start_dt)


    My expectation is

    SELECT DISTINCT AL1. PRSN_NO, AL2. POOL_NM
    OF VADIM_IR. AN AL1
    LEFT OUTER JOIN VADIM_IR. B AL2
    ON (AL1. PTY_ID = AL2. PTY_ID)
    AND (AL2. Start_dt < = AL1. End_dt
    AND AL2. Start_dt > = AL1. Start_dt)


    Please help me on this. I hope there is a setting in the creation of the eco file to get the outer join condition in the filter and I have not checked but still I am getting the join condition in the filter.

    Thank you
    KP

    have you try to define/set of this part of the sql ("(AL2.)") Start_dt<=>
    AND AL2. Start_dt > = AL1. Start_dt)"as a sql custom Start_dt fileld limiit?

  • Please, I want someone to answer this questions SQL?

    1. display the name, the month and the year of accession of all employees, stored on the months of their date of hiring and in that on the year, with the first year that appears first?

    Can be.

    You can explain further.

    Cordially salim

    SQL> select ename,to_char(hiredate,'mm-yyyy') month_year from emp order by hiredate;
    
    ENAME      MONTH_Y
    ---------- -------
    SMITH      12-1980
    ALLEN      02-1981
    WARD       02-1981
    JONES      04-1981
    BLAKE      05-1981
    CLARK      06-1981
    TURNER     09-1981
    MARTIN     09-1981
    KING       11-1981
    JAMES      12-1981
    FORD       12-1981
    MILLER     01-1982
    SCOTT      04-1987
    ADAMS      05-1987
    
    14 rows selected.
    
    SQL> 
    
  • Report, SQL query based on the values of the elements (question SQL)

    Hello

    I use APEX 4.0 with Oracle 10 g r2 under Windows XP Pro SP3.

    I have an interactive report and a menu with a few items to filter the report.

    It works with most of the elements, but my problem is to select lists that have additional values, for example:
    SELECT '(null)' display_value, 'NULL' return_value FROM DUAL
    UNION ALL
    select distinct(SPAT_AREA_NAME) display_value, SPAT_AREA_NAME return_value 
    from SPATIAL_POINTS
    order by 1
    and I will return null as ' (return '%').

    For example, if the user selects "(null)", the report should return all rows with a NULL value in the column AREA_NAME.
    If he chooses "", the report should return all the lines. "
    and if the user selects a value, the report should return all the lines containing the value in column AREA_NAME.

    I don't know how to build my application. I tried with the CASE statements, DECODE, etc... but I still can't!

    My report query is for now:
    select SPAT_ID,
     SPAT_ACCL_NAME,
     SPAT_AREA_NAME,
     SPAT_CLASS,
     SPAT_NUMBER,
     SPAT_PT,
     SPAT_TYPE,
     SPAT_STATUS,
    from SPATIAL_POINTS 
    where 
     upper(SPAT_AREA_NAME) LIKE upper(:P3_FILTRE_AREA_NAME)  AND
     upper(SPAT_ACCL_NAME) LIKE upper(:P3_FILTRE_ACC_NAME) AND
     upper(SPAT_CLASS) LIKE '%'||upper(:P3_SPATIAL_CLASS)||'%' AND
     instr(upper(:P3_SPATIAL_TYPE_VALUES),upper(SPAT_TYPE)) > 0 AND
     instr(upper(:P3_SPATIAL_STATUS_VALUES),upper(SPAT_STATUS)) > 0 AND
     instr(upper(:P3_SPATIAL_POINT_VALUES),upper(SPAT_PT)) > 0
    Any idea?

    Thank you!

    Yann.

    Hello

    Then, assuming that spat_accl_name is not a string value "NULL" then you can try this...

    SELECT spat_id,
           spat_accl_name,
           spat_area_name,
           spat_class,
           spat_number,
           spat_pt,
           spat_type,
           spat_status,
           ROUND(spat_cumul,
                 (SELECT up_number_precision
                  FROM   user_preferences
                  WHERE  UPPER(up_nice_login) = UPPER(v('APP_USER'))))
              AS "SPAT_CUMUL"
    FROM   spatial_points
    WHERE  :p3_filtre_acc_name IS NULL AND spat_accl_name IS NULL
           OR(CASE
                 WHEN :p3_filtre_acc_name = '%' THEN NVL(spat_accl_name,'NULL')
                 ELSE :p3_filtre_acc_name
              END = NVL(spat_accl_name, 'NULL'))
    

    See you soon

    Ben

  • SNMP, generic SQL data loader, and built-in Port adapters

    Anyone have any success with using the SNMP (default MIB) and/or adapters third generic data SQL Loader?

    I'm under vCenter operations v5.7 VAPP and test the custom UI. I have installed the SNMP card, but when adding my own MIB they do not appear in the drop-down list when you try to add a new resource. I followed the docs to update the card with your own MIB files and everything is a - ok until I actually try to add a resource.

    I saw this KB:

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 2034241

    But I loadded a few different mibs, poking around them in a mib browser, and each of them meet the requirements of that article.

    Regarding the SQL adapter. I add my instance of the adapter and the credentials and it tests fine, but when you add the resource to the environment overview screen, the 'Resource Type' dropdown is empty/non-editable. When I click ok, it of course gives me an error:

    The field 'type of Resrouce' is a required field. Please enter a value.

    Anyone who cross?

    Finally, there is documentation for the built-in Port Adapter? There is a very small excerpt in the card Guide:

    Reads a text that you set to determine the hosts and ports to monitor.

    But... where did you put this text?

    Two problems solved.

    First of all, the SNMP MIB has not picked up due to permissions on the file that I was transferred to the analytical VM. Duh. Evolution of the property of admin: admin corrects this problem. VMWare has taken this error.

    Also found a solution to the question SQL by clicking... the random button it appears that does not refresh the kind of resources until you run an auto-discovery. After crossing the Autodiscover queries, the drop-down list the type of resource is now available from the manual discovery. However, to make changes to the query/discovery files requires another automatic discovery for the changes to be picked up.

  • Why the DOF is SQL?

    Even if the DDL or DML commands do not interview at the database, why they are considered a part of SQL (Structured Query Language). I tried to find the answer to many a sites, but could not find it. Kindly help

    Thank you
    RAM

    RamGrandhi wrote:
    Even if the DDL or DML commands do not interview to the database,

    I don't agree with that. A DDL statement like this ask the database.

    create table employee_temp
    as
    select *
      from employee;
    

    And a DML statement like this query of the database as well.

    insert into employee_temp
    select *
      from employee;
    

    But to answer your question SQL is just a name representing a programming language like Java or C.

  • Questions and 10gUpgrade

    Hello

    We do the upgrade from 9.2.0.6 to 10.2.0.4 in our unique test sever and apps version 11.5.10.2
    -------------------------------------------------------------------------------------------------------------------------------------------

    (1) installed binary 10.2.0.XxXX on new location as an oracle user
    (2) Applied Patch located at the top of the Oracle_Home 10.2.0, 10.2.0.4
    (3) copied Listener.ora files Tnsnames.ora, InitSID.ora home new Oracle 10 g and and I did any major changes in the files tnsnames, istener.ora, and inistSID.ora
    (4) I used the same number of headphone port and I started with any problem,

    MY questions is,

    I copied @utlu102i.sql script in / tmp location, when I try to run *@utlu102i.sql* using 9.2.0.6. database,

    I hit below question
    ---------------------------
    SQL > startup
    ORACLE instance started.

    Total System Global Area 581506668 bytes
    Bytes of size 452204 fixed
    402653184 variable size bytes
    167772160 of database buffers bytes
    Redo buffers 10629120 bytes
    ORA-00201: controlfile version 9.2.0.0.0 incompatible with ORACLE version
    9.2.0.0.0
    ORA-00202: controlfile: ' / u01/oracle/uatqdata/cntrl01.dbf'

    -----------------------------------------------------------------------

    I found metalink note: 388604.1

    According to the note, I have no problem with compatible,

    SQL > SELECT name, value, description OF THE parameter $ v
    WHERE name = 'compatible ';
    2
    NAME
    --------------------------------------------------------------------------------
    VALUE
    --------------------------------------------------------------------------------
    DESCRIPTION
    --------------------------------------------------------------------------------
    compatible
    * 9.2.0 *.
    Database will be completely compatible with this version of the software

    Hello

    If you have not run any script upgrade, then you should not get this error. You have a backup of this instance? If so, is it possible to restore the data files and restart the database by using the 9i ORACLE_HOME env files?

    Kind regards
    Hussein

  • course of action

    Hello

    I did following steps

    step 1

    CREATE OR REPLACE TYPE  address_type as object
    (
      ad1      varchar2(50),
      ad2      varchar2(50),
      ad3      varchar2(50),
      city      varchar2(20),
      pin      varchar2(10)
    );
    

    step 2

    CREATE OR REPLACE TYPE  H_address is table of address_type;
    

    step 3

     create or replace function address_details
     (
     brcode in NUMBER,
     prd in varchar2)
     return sys_refcursor
     is
     x_cursor   sys_refcursor;
     vquery varchar2(4000);
     begin
     vquery:='SELECT ADDR1,ADDR2,addr3,citycd,pincd from d010054 where lbrcode='||brcode||' and prdacctid='||prd ||' and addrtype=1';
     open x_cursor for
     vquery;
     return x_cursor;
     IF (x_cursor%NOTFOUND) THEN
           vquery:='select add1,add2,add3,citycd,pincode from d009011 where custno='||t_cust(brcode,prd);
        open x_cursor for vquery;
     END IF;
     return x_cursor;
     end address_details;
    

    function is created without any errors

    step 4

    create or replace function address_pipe_function (i_cursor sys_refcursor)
       return h_address pipelined is
       vapxrec address_type:=address_type(null,null,null,null,null);
     begin
        loop
        fetch i_cursor into
        vapxrec.ad1,
        vapxrec.ad2,
        vapxrec.ad3,
        vapxrec.city,
        vapxrec.pin;
        exit when i_cursor%notfound;
        pipe row (vapxrec);
        end loop;
     close i_cursor;
     return;
     end;
    

    feature created without error

    then I tried the following

    SQL > select * from

    Table 2 (address_pipe_function (address_details (2, 'SB 000000000003055300000000')));

    Table (address_pipe_function (address_details (2, 'SB 000000000003055300000000')))

    *

    ERROR on line 2:

    ORA-00933: SQL not correctly completed command.

    ORA-06512: at "RECORD. ADDRESS_DETAILS', line 11

    I'm working on 11g

    Please guide

    HEMU wrote:

    Mr President

    It's for learning

    In fact, I wrote a function average monthly report giving fromdate, parameters to date, once again, it returns a single delimited string

    the problem is that I have to put the title of the column for the month are back through (fromdate, to date)

    That's why I'm creating a type based on inputdata dynamically, then the pupulate values for dérirez

    There may be a number of months from different years

    so the heads of column will be 'JAN_2013', feb_2013 and so on

    This forum will certainly helps me learn rather than copy the codes

    Thank you

    This is a misconception.

    When you start to dynamically create queries with dynamic column names, you start to need to dynamic code to process the results of the query, because you can not write static code you know not the names of columns... resulting in any of your code more dynamic... that is impassable, unperformant, and may contain bugs which will be not detectable at compile time not to mention the possibility of introducing questions sql injection.

    The only time you need to have column names from the data, is purposes, not for purposes of data processing.  Therefore, you must leave such column name up to reporting tools, which are specifically designed to query the data first, then layout of these data report and dynamically generate headings etc. as required.  Do not try and do it in SQL.

    Read this: 101 PL/SQL: cursors and Projection of SQL

  • Update statement w / Order By and other goodies

    It is a continuation of my previous post: Re: create the update with joint statement / select please see for table structure and sample data.

    OK, so this is based on my previous question SQL that has been resolved by you brilliant SQLers there. the code below will do exactly what I need it to do, but I wanted less user interaction:
    update offender_case_identifiers ociq
       set Identifier_type = 'ARN2'
     where ociq.offender_book_id in
          (select offender_book_id from v_header_block
            where offender_id_display = :ppid)
        and ociq.comment_text != :parn
       AND ociq.identifier_type = 'ARN'
    I wanted only the user having to enter in the ": pid" and have the script to take care of the rest. I found the best way to ensure that I find the most recent "RNA" of the offender_case_identifiers (which will then need to be set on ": bcyr ') is to run the following script:
    select oci.identifier_type 
    , vhb.offender_id_display
    ,oci.comment_text
    ,vhb.offender_book_id
    ,oci.offender_book_id
    from   offender_case_identifiers oci, v_header_block vhb 
    where 
    oci.offender_book_id = vhb.offender_book_id
    and vhb.offender_id_display = :ppid
    and oci.identifier_type like 'ARN'
    order by comment_text desc
    The code above was the original starting point for my last final SQL command, mentioned first in this post, however, I added the 'ORDER BY' the bottom of it. For additional examples of data, here is the result of the above statement:

    IDENTIFIER_TYPE OFFENDER_ID_DISPLAY COMMENT_TEXT OFFENDER_BOOK_ID OFFENDER_BOOK_ID_1
    RNA * 0000382183 * 01550228 * 1 011 683 * 1 011 683
    RNA * 0000382183 * 01550228 * 1 011 683 * 1 011 683
    RNA * 0000382183 * 01531810 * 823 281 * 823 281
    RNA * 0000382183 * 01531810 * 823 281 * 823 281
    RNA * 0000382183 * 01531810 * 823 281 * 823 281
    RNA * 0000382183 * 01531810 * 823 281 * 823 281
    RNA * 0000382183 * 01529717 * 804 301 * 804 301
    RNA * 0000382183 * 01525871 * 759 982 * 759 982
    RNA * 0000382183 * 01525871 * 759 982 * 759 982
    RNA * 0000382183 * 01516263 * 688 100 * 688 100
    RNA * 0000382183 * 01516263 * 688 100 * 688 100
    RNA * 0000382183 * 01516263 * 688 100 * 688 100
    RNA * 0000382183 * 01515789 * 682 680 * 682 680
    RNA * 0000382183 * 01510809 * 624 140 * 624 140
    RNA * 0000382183 * 01507681 * 590 261 * 590 261
    RNA * 0000382183 * 01507681 * 590 261 * 590 261
    RNA * 0000382183 * 01507681 * 590 261 * 590 261
    RNA * 0000382183 * 01484993 * 454 927 * 454 927
    RNA * 0000382183 * 01484993 * 454 927 * 454 927
    RNA * 0000382183 * 01484993 * 454 927 * 454 927
    RNA * 0000382183 * 01477592 * 448 231 * 448 231
    RNA * 0000382183 * 01477592 * 448 231 * 448 231
    RNA * 0000382183 * 01456544 * 428 902 * 428 902
    RNA * 0000382183 * 01456544 * 428 902 * 428 902
    RNA * 0000382183 * 01429778 * 403 175 * 403 175
    RNA * 0000382183 * 01427677 * 401 055 055 * 401
    RNA * 0000382183 * 01427677 * 401 055 055 * 401
    RNA * 0000382183 * 01427677 * 401 055 055 * 401

    I therefore, as you can see, the query to select the recording of top/1 St 'Comment_Text' in the above results, and give it the ': bcyr ' WITHOUT inviting the user to enter. So I want the script to change all the other "Identifier_Type' to"ARN2"who do not share the first 'Comment_Text'... so in this example, I want all the"RNA"replaced by"ARN2"who do not have 'Comment_text' = 01550228.


    I hope that's not too complicated, because it is to me. Thanks in advance for any assistance.

    Hello

    If you have a query that displays all rows, and you want to UPDATE the lines in this updated reuslut who do not have the highest value of comment_text. You can use the analytic DENSE_RANK function to number the separate comment_texts and then throw the lines that have been assigned to #1. the rest will be those you wqant to UPDATE.

    Here's a way to do it:

    UPDATE     offender_case_idetifiers
    SET     identifier_type     = 'ARN2'
    WHERE     (offender_book_id, comment_text)
         IN (
                WITH    got_r_num    AS
                (
                    SELECT  vhb.offender_book_id
                 ,        oci.comment_text
                 ,        DENSE_RANK () OVER (OREDER BY oci.comment_text  desc)
                                 AS r_num
                 FROM    offender_case_identifiers oci
                 ,         v_header_block           vhb
                 WHERE   oci.offender_book_id      = vhb.offender_book_id
                 AND         vhb.offender_id_display   = :ppid
                 AND        oci.identifier_type           = 'ARN'
                )
                SELECT  offender_nook_id
                ,       comment_text
                FROM    got_r_num
                WHERE   r_num     > 1
            )
    AND     identifier_type     = 'ARN'
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Unable to create the stored procedure batch Oracle Script from Windows

    Hello
    I put my code here please let me know where I have error
    Cmd
    -------
    DNAME SET = %3
    SET UerName = %1
    SET Pssword = %2
    SET Opdir = C:\Users\testuser\
    sqlplus-s '% UerName%/%Pssword%@%DNAME%' @%Opdir%procdure.sql

    procedure. SQL
    --------------
    WHENEVER SQLERROR EXIT SQL. SQLCODE ROLLBACK
    WHENEVER OSERROR EXIT SQL. OSCODE RESTORATION
    SET SERVEROUTPUT ON
    SET ECHO ON
    AUTOPRINT SET ON
    RUN THE DBMS_OUTPUT. ENABLE (1000000)
    COIL Seq.log
    SET linesize 1000
    CREATE PROCEDURE test "()" ""
    AS
    BEGIN
    NULL;
    END test;
    SPOOL OFF
    OUTPUT
    -----------

    Demostrating how I executed


    C:\Users\nikhilgk > otherobj AAA AAA TEST
    C:\Users\nikhilgk > SET DNAME = TEST
    C:\Users\nikhilgk > SET UerName = AAA

    C:\Users\nikhilgk > SET Pssword = AAA

    C:\Users\nikhilgk > SET LOG = C:\Users

    C:\Users\nikhilgk > SET Opdir = C:\Users\testuser\

    C:\Users\nikhilgk > sqlplus s 'AAA/AAA@TEST' @procdure.sql

    PL/SQL procedure successfully completed.

    ------------------------
    Journal is is created with size 0 KB.

    I connected to SQLPLUS and questioned
    SQL > select object_name from user_objects where type_objet = 'PROCEDURE '.

    no selected line.

    you have'nt actually run the code to create procedure.

    create PROCEDURE TEST()
    AS
    BEGIN
    NULL;
    END test;
    /  -- you need this 
    

    also if you want to access without double quotes all the time, do not put double quotes on the name

    And I think you should go out; rather than leave. That's why you have a size zero.

    Published by: Keith Jamieson 31 August 2012 13:21

  • Create the flat file data from the oracle table

    d_adp_num char (10)
    d_schd_date tank (8)
    d_sched_code tank (25)
    d_pay_code char (50)
    d_mil_start char (4)
    d_mil_end char (4)
    d_duration char (5)
    d_site_code char (4)
    d_dept_id tank (6)

    Select payroll_id,
    schedule_date,
    reason_code, (sched_code)
    reason_code, (pay_code)
    start_time,
    end_time,
    total_hours,
    site_code,
    department_id
    of dept_staff
    where schedule_date between (sysdate + 1) and (sysdate + 90)


    loading data for the date range instead.
    sched_code - if 'Unavailable' reason_code = 'OD' and 'THE '.

    pay_code - "Berevevement BD" If reason_code = "BD".
    "UP PTO without reasonable excuse" If reason_code = 'UP '.
    "RG" If reason_code = "SH".
    "PTO" If reason_code = "GO".
    Here are some...

    start_time and end_time - convert military time
    based on start_ampm and end_ampm

    On this basis, I need help to create a flat file. Sewing of the flat and data file in dept_staff sample

    If site_code is there so no need to get department_id (see the sample flat file)
    ------------------------------------

    examples of data to flat file

    ZZW002324006072012 PTO
    0800160008.00
    ZZW002428106072012 RG
    1015174507.50HM34
    ZZW002391606072012 RG
    1100193008.50
    ZZW002430406072012 RG
    1100193008.50 130000
    ----------------------------

    dept_staff table data

    REASON_CODE_1 PAYROLL_ID SCHEDULE_DATE REASON_CODE START_TIME, END_TIME START_AMPM END_AMPM TOTAL_HOURS SITE_CODE DEPARTMENT_ID
    ZZW0024468 08/06/2012 HS HS 730 HAS 400 850 12 P
    ZZW0000199 08/06/2012 HS HS 730 HAS 400 850 14 P
    ZZW0023551 08/06/2012 SH SH 1145 A 930 975 GH08 95 P
    ZZW0024460 08/06/2012 SH SH 515 HAS 330 P 1025 GH08 95
    ZZW0023787 08/06/2012 SH SH 630 HAS 300 850 24 P
    ZZW0024595 08/06/2012 TR TR 730 HAS 400 850 90 P
    ZZW0023516 08/06/2012 OD OD 800 HAS 400 800 95 P
    ZZW0023784 08/06/2012 OD OD 800 HAS 400 800 5 P
    ZZW0024445 08/06/2012 SH SH 1145 A GH08 930 975 5 P
    ZZW0024525 08/06/2012 OD OD 800 HAS 400 800 23 P
    ZZW0024592 08/06/2012 TR TR 730 HAS 400 850 5 P
    ZZW0024509 08/06/2012 SH SH 95 MK21 830 HAS 330 P 700

    ZZW0023916 06/14/2012 SH SH 1100 A 850 27 730 P

    How to ask questions
    SQL and PL/SQL FAQ

    UTL_FILE allows to write the OS file

Maybe you are looking for