Trim function in sql

hi
Iam using the oracle 9 database.In my data base i have column like
column_name varchar2(41) but the data is 03265482036-03265482036(here both numbers are same).while processing the data how could i get only 03265482036. my data base contains 4 milion records

hi
Iam using the oracle 9 database.In my data base i
have column like
column_name varchar2(41) but the data is
03265482036-03265482036(here both numbers are
same).while processing the data how could i get only
03265482036. my data base contains 4 milion recordsAssuming, that '-' is only possible delimiter...
SELECT substr(col,1,instr(col,'-') - 1)

Similar Messages

  • Trim Function in SQL Loader

    Oracle version 10g
    I have control file like below and would like to know is there a better way to declare trim function at the top level instead of specifying at field level. I want to remove leading or trailing spaces for the field.
    LOAD DATA
    INFILE *
    TRUNCATE
    INTO TABLE TMPTUPS_POD_DLY
    ORD_NO POSITION(1:15) "TRIM(:ORD_NO)",
    CUST_PO_NO POSITION(16:37) "TRIM(:CUST_PO_NO)",
    SHP_NAME POSITION(38:72) "TRIM(:SHP_NAME)",
    SHP_ADDR POSITION(73:102) "TRIM(:SHP_ADDR)",
    SHP_CTY POSITION(103:132) "TRIM(:SHP_CTY)",
    SHP_ST POSITION(133:134),
    SHP_ZIP POSITION(135:144),
    SHP_DT POSITION(145:154) DATE "YYYY-MM-DD",
    TRCKNG_NO POSITION(155:184),
    NOU POSITION(185:192) INTEGER EXTERNAL,
    SHP_WGT POSITION(193:204) "TO_NUMBER(:SHP_WGT,'999999999999')/100",
    POD_NAME POSITION(205:234) "TRIM(:POD_NAME)",
    POD_DT POSITION(235:244) DATE "YYYY-MM-DD",
    POD_TIME POSITION(245:252) DATE "HH:MI:SS",
    AIR_BLL_PC POSITION(253:260) INTEGER EXTERNAL,
    POD_STS_CD POSITION(261:262)
    )

    user13143312 wrote:
    That's right. if I have 5 to 10 varchar2 columns I have to mention at the field level. Just like PRESERVE BLANKS or TRAILING NULLCOLS at the top level, I thought is there a way to trim all fields at the top level. I will continue to use at the field level. Thanks!http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#i1007768
    If you specify them as varchar2's the trailing blanks will be trimmed.
    Also ... to remove the leading blanks.
    Optional Enclosure Delimiters
    Leading whitespace is also removed from a field when optional enclosure delimiters are specified but not present.
    Whenever optional enclosure delimiters are specified, SQL*Loader scans forward, looking for the first enclosure delimiter. If an enclosure delimiter is not found, SQL*Loader skips over whitespace, eliminating it from the field. The first nonwhitespace character signals the start of the field. This situation is shown in Field 2 in Figure 9-6. (In Field 1 the whitespace is included because SQL*Loader found enclosure delimiters for the field.)
    "

  • Using TRIM function in select statement

    Hi All,
    I'm using the TRIM function in my select statement to eliminate the white spaces.
    But while using in select the TRIM function is not working in SQL*PLUS client(The query returns the white spaces also)
    Kindly provide some pointers regarding the issue.........
    I want to get only the data without the spaces in select statement
    Regards,
    Mohan

    Hi, Mohan,
    SQL*Plus always pads columns to make them line up nicely.
    If you have a column declared as VARCHAR2 (20), then SQL*Plus will normally display 20 characters for that column, even in the maximum actual length is, say, 5 (or even if the column always happens to be NULL).
    If you want the output to include only the actual data, without the padding that SQL*Plus adds, then concatenate all the columns into one big string column.
    People often do something like the following to generate a CSV file, with no exta spaces:
    SELECT       TO_CHAR (empno)
    || ',' || ename
    || ',' || job
    || ',' || TO_CHAR (deptno)
    || ',' || TO_CHAR (hiredate, 'DD-Mon-YYYY')     AS all_data
    FROM          scott.emp;

  • Error when trying to use trim function

    when i try to use trim function on a column it gives me following error for the below query
    select trim(first_name) name from table1@pa1;
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    DSNT408I SQLCODE = -440, ERROR: NO FUNCTION BY THE NAME TRIM HAVING COMPATIBLE ARGUMENTS WAS FOUND IN THE CURRENT PATH DSNT418I SQLSTATE = 42884 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNXORFN SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = -100 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = X'FFFFFF
    any idea gurus ???Thanks

    This might work:
    select trim(first_name) name from
      (select first_name from table1@pa1);The problem is that pa1 is a non-Oracle database and does not have a trim function. It may have another function that does the same thing but it's not called TRIM.

  • Query with trim function running more than 15 hours..

    Hi,
    I have one select query which is running more than 15 hours.I have many trim() functions in that.and i have index for some columns for the tables that i used in that query.but it is not considering those indexes..
    select
    DISTINCT
    trim(A.x) x,
    trim(B.y) y,....... from A,B
    Can anyone tell why this query is taking more time?and is there any other way for using the trim function?
    Thanks in advance..

    Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*", so only for issues with the SQL Developer tool. Please post these questions under the dedicated [SQL And PL/SQL|https://forums.oracle.com/forums/forum.jspa?forumID=75] forum.
    Regards,
    K.

  • Use Trim Function in this instance?

    Oracle 10.2g
    I have the following code (Thanks to michaels 2):
    SQL> with t as (
    select to_date('11/14/2003 7:39:00 PM','MM/DD/RRRR hh:mi:ss pm') time, 11122 home_team_id,null away_team_id,null home_team_name, 'parks' away_team_name,'Steve' offensive_player_moniker, 'Smith' offensive_player_last_name from dual union all                   
    select to_date('11/14/2003 7:32:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 24555, null, 'bombers', 'Chris', 'Carter' from dual union all                
    select to_date('12/14/2008 1:35:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 33211, null, 'carts', 'Marty', 'Booker' from dual union all  
    select to_date('12/14/2008 1:30:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Bob', 'Sanders' from dual union all
    select to_date('12/14/2008 1:38:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Marvin','Harrison' from dual
    select away_team_name || ': ' || xmlagg(xmlelement(e, offensive_player_moniker || ' ' || offensive_player_last_name || ' (' || to_char(time,'hh:mi') || '), ')).extract('//text()') x from t
    group by  away_team_name
    X                                                                              
    bombers: Chris Carter (07:32),                                                 
    carts: Marty Booker (01:35),                                                   
    parks: Steve Smith (07:39),                                                    
    sharks: Bob Sanders (01:30), Marvin Harrison (01:38),
    Desired output:
    bombers: Chris Carter (07:32)                                                
    carts: Marty Booker (01:35)                                                
    parks: Steve Smith (07:39)                                                  
    sharks: Bob Sanders (01:30), Marvin Harrison (01:38)How can i go about deleting the extra coma at the end when unnecessary. I' guessing the trim function could do it with an if-else clause, though i'm not sure what would go in the if-else clause

    Since there's an additional blank as well you need to trim it as well
    SQL>  with t as (
    select to_date('11/14/2003 7:39:00 PM','MM/DD/RRRR hh:mi:ss pm') time, 11122 home_team_id,null away_team_id,null home_team_name, 'parks' away_team_name,'Steve' offensive_player_moniker, 'Smith' offensive_player_last_name from dual union all                   
    select to_date('11/14/2003 7:32:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 24555, null, 'bombers', 'Chris', 'Carter' from dual union all                
    select to_date('12/14/2008 1:35:00 PM','MM/DD/RRRR hh:mi:ss pm'), null, 33211, null, 'carts', 'Marty', 'Booker' from dual union all  
    select to_date('12/14/2008 1:30:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Bob', 'Sanders' from dual union all
    select to_date('12/14/2008 1:38:00 PM','MM/DD/RRRR hh:mi:ss pm'), 15555, null, null, 'sharks', 'Marvin','Harrison' from dual
    select rtrim(away_team_name || ': ' || xmlagg(xmlelement(e, offensive_player_moniker || ' ' || offensive_player_last_name || ' (' || to_char(time,'hh:mi') || '), ')).extract('//text()'), ', ') x from t
    group by  away_team_name
    X                                                                              
    bombers: Chris Carter (07:32)                                                  
    carts: Marty Booker (01:35)                                                    
    parks: Steve Smith (07:39)                                                     
    sharks: Bob Sanders (01:30), Marvin Harrison (01:38)

  • Trim Function

    Hi,
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> SELECT TRIM ('OLD' FROM 'OLDMAN') FROM DUAL;
    SELECT TRIM ('OLD' FROM 'OLDMAN') FROM DUAL
    ERROR at line 1:
    ORA-30001: trim set should have only one characterDear All why this error....

    TRIM function
    TRIM is a function that takes a character expression and returns that expression with leading and/or trailing pad characters removed. Optional parameters indicate whether leading, or trailing, or both leading and trailing pad characters should be removed, and specify the pad character that is to be removed.
    Syntax
    TRIM( [ trimOperands ] trimSource)
    trimOperands ::= { trimType [ trimCharacter ] FROM | trimCharacter FROM }
    trimType ::= { LEADING | TRAILING | BOTH }
    trimCharacter ::= CharacterExpression
    trimSource ::= CharacterExpression
    If trimType is not specified, it will default to BOTH. If trimCharacter is not specified, it will default to the space character (' '). Otherwise the trimCharacter expression must evaulate to one of the following:
    a character string whose length is exactly one, or.
    NULL
    If either trimCharacter or trimSource evaluates to NULL, the result of the TRIM function is NULL. Otherwise, the result of the TRIM function is defined as follows:
    If trimType is LEADING, the result will be the trimSource value with all leading occurrences of trimChar removed.
    If trimType is TRAILING, the result will be the trimSource value with all trailing occurrences of trimChar removed.
    If trimType is BOTH, the result will be the trimSource value with all leading and trailing occurrences of trimChar removed.

  • Trim function on varchar2 data

    I just saw several programs, in which they have used TRIM function for a Varchar2 data type column. I thought it is not required. any thoughts?
    Thanks for your time.

    SQL> desc test_1;
    Name                                      Null?    Type
    SNO                                                NUMBER
    SNAME                                              VARCHAR2(13)
    SQL> select * from test_1;
           SNO SNAME
             1 abc
             2    xyz
             3 mno
             4     pqr
    SQL> select sno,sname,trim(sname),length(sname) len1,length(trim(sname)) len2 from test_1;
           SNO SNAME         TRIM(SNAME)         LEN1       LEN2
             1 abc           abc                    3          3
             2    xyz        xyz                    6          3
             3 mno           mno                   11          3
             4     pqr       pqr                   13          3
    SQL> alter table test_1 modify sname char(13);
    Table altered.
    SQL> desc test_1;
    Name                                      Null?    Type
    SNO                                                NUMBER
    SNAME                                              CHAR(13)
    SQL> select sno,sname,trim(sname),length(sname) len1,length(trim(sname)) len2 from test_1;
           SNO SNAME         TRIM(SNAME)         LEN1       LEN2
             1 abc           abc                   13          3
             2    xyz        xyz                   13          3
             3 mno           mno                   13          3
             4     pqr       pqr                   13          3
    SQL>

  • About using TRIM function...

    //I'm posting this after whole search of past discussion as everybody wants to do so. :-)
    Hi,
    I want to trim out white spaces from colums in my table when select executes.
    I've read about TRIM function, but it does not as documented I think.
    See below my pseudo-code from trimming.
    SELECT trim (' ' from col1) | | col2, FROM TH_ABLICEN WHERE..blah..blah..This SQL query return me "ORA-00907: missing right parenthesis".
    I don't know how can this returns...
    TRIM function works only when its parameter is a constant and fails always when columns were injected as a parameter.
    This situation is very obscure to me and make me wondering ORACLE's intention for this kind of inconvenience.
    And I've tried replace (col1, ' ', '') only to fail.
    So my question is...
    1. How can use trim function?
    2. What is the ordinary method being used by popular demand to trim out white spaces from a column?
    Thanks in advance
    Regards,
    Ryan

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Adinath Kamode ([email protected]):
    Hello,
    Your query is correct. I tried it with 8.1.6 sql version. I modified it as follows.
    select trim(' ' FROM ENAME)| |JOB FROM EMP;
    about syntax you can specify column name in trim.
    hope reply from you.
    <HR></BLOCKQUOTE>
    As mentioned in my first posting, it returns "ORA-00907: missing right parenthesis" error.
    Anyway thanks for your concern.
    Regards,
    Ryan
    null

  • Want to convert function in SQL Server 2000

    Hi ,
    i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
    Please following is the code for oracle.
    CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
    return number
    as  x number;
    begin
    select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
       SELECT
                       prereq_count,
                       username
                 FROM
                         table1
    group by     username ;
    return x;
    end fun;
    Regards
    Vishal

    Just take a look example below might give you idea :
    create or replace function f_makeAddress_tx (
    i_address_tx VARCHAR2,
    i_city_tx VARCHAR2,
    i_state_tx VARCHAR2,
    i_zip_tx VARCHAR2)
    return VARCHAR2
    is
    e_badZip EXCEPTION; u279E8
    pragma EXCEPTION_init(e_badZip,-20998); u279E9
    v_out_tx VARCHAR2(256);
    begin
    p_validateZip (i_zip_tx); u279E12
    v_out_tx:= i_address_tx||u2019, u2018|| u279E13
    i_city_tx ||u2019, u2018||
    i_state_tx ||u2019, u2018||
    i_zip_tx;
    return v_out_tx; u279E17
    exception
    when e_badZip then u279E19
    return i_zip_tx || u2018: Invalid zip code.u2019;
    end;
    Regards,
    Clint

  • 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

  • How do I use the TRIM function in my Query?

    I have a field that has called AP.service_user_defined_1 that houses a Code the code is like Alpha Num ie "AA01" then it has about 30 to 40 whites spaces and then the description of what the code means. I need to have the description to show in my report I don't necessarily need the code but I do need the description I tried putting the TRIM Function in as below and it will not work what do I need to do to correct this?? I need help ASAP this is due today! Thanks for any help!
    SELECT DISTINCT
              A1.AUTH_NUMBER,
    PM.LAST_NAME,
              A1.AUTH_TYPE,
              A1.PLACE_OF_SERVICE,
              A1.OVERALL_STATUS,
              A1.CLOSED_REASON,
              A1.DENIED_REASON,
    Case
    when A1.DENIED_REASON in ('HS001','HS002') then 'MED NECESS'
    when A1.DENIED_REASON in ('HS004','HS005','HS006','HS007','HS008','HS013','HS014','HS016','HS017','HS019','HS020') then 'Admin Denial'
    when A1.DENIED_REASON is NUll and ap.advisor_decision = 'AAPPR' then 'Approved'
    else 'Unknown'
    end DENIED,
    A1.admit_primary_date,
    A1.service_admit_type AS "IP ADMIT TYPE",
    A1.service_user_defined_1 AS "OP Serv Type",
    Trim (leading ('AA01                 ',)from dual,
    ap.contact_date,
    AP.decision_date,
    AP.ADVISOR_DECISION,
    PM.PROVIDER_ID,
         A1.INSERT_DATETIME,
    TO_CHAR (A1.insert_datetime,'MONTH-YY')AS "Month",
    A1.admit_primary_date,
              A1.ACTIVE_PHYSICIAN_ADVISOR,
              MV.LINE_OF_BUSINESS
    FROM Windsoradm.auth_master a1
    INNER JOIN Windsoradm.auth_phys_advisor ap
    ON a1.auth_number=ap.auth_number
    INNER JOIN windsoradm.prov_master pm
    ON ap.seq_prov_id=pm.seq_prov_id
    LEFT JOIN windsoradm.note_master nm
    ON nm.seq_memb_id=a1.seq_memb_id
    INNER JOIN windsoradm.member_mv mv
    ON mv.seq_memb_id=a1.seq_memb_id
    Where mv.Line_of_Business <>'SFS'
    /*AND A1.PLACE_OF_SERVICE IN ('11','21','22','24')*/
    /*AND a1.active_physician_advisor = 'Y'*/
    /*AND (a1.closed_reason ='A06' OR a1.closed_reason is Null)*/
    AND a1.insert_datetime Between To_Date ('04/01/2012', 'MM/DD/YYYY') and To_Date ('04/30/2012','MM/DD/YYYY')
    ORDER BY 1

    I don't know how to use this within my query I put it in as you suggest and get an error: I'm new to these functions can you show me how within my query I should code it? The field Name is A1.service_user_defined_1 There are about 50 Different Codes in a Drop down list within the application that have a different Code and Different Description it appears that the Codes are all 4 character alpha numeric then about 25 to 45 spaces and then the description. Please show me in my code how to get this I wish there was a table I could link to that housed both code and description but who ever created this did not make life easy. Thanks (I also tried the TRIM but could not get it to work ) I know it is because I do not know how to put it within my code to make it work.
    SELECT DISTINCT
              A1.AUTH_NUMBER,
    PM.LAST_NAME,
              A1.AUTH_TYPE,
              A1.PLACE_OF_SERVICE,
              A1.OVERALL_STATUS,
              A1.CLOSED_REASON,
              A1.DENIED_REASON,
    Case
    when A1.DENIED_REASON in ('HS001','HS002') then 'MED NECESS'
    when A1.DENIED_REASON in ('HS004','HS005','HS006','HS007','HS008','HS013','HS014','HS016','HS017','HS019','HS020') then 'Admin Denial'
    when A1.DENIED_REASON is NUll and ap.advisor_decision = 'AAPPR' then 'Approved'
    else 'Unknown'
    end DENIED,
    A1.admit_primary_date,
    A1.service_admit_type AS "IP ADMIT TYPE",
    A1.service_user_defined_1 AS "OP Serv Type",
    regexp_replace('AA01 Behavioral/Mental Health Service', '^[^ ]+ +')from dual,
    ap.contact_date,
         AP.decision_date,
         AP.ADVISOR_DECISION,
              PM.PROVIDER_ID,
         A1.INSERT_DATETIME,
    TO_CHAR (A1.insert_datetime,'MONTH-YY')AS "Month",
    A1.admit_primary_date,
              A1.ACTIVE_PHYSICIAN_ADVISOR,
              MV.LINE_OF_BUSINESS
    FROM Windsoradm.auth_master a1
    INNER JOIN Windsoradm.auth_phys_advisor ap
    ON a1.auth_number=ap.auth_number
    INNER JOIN windsoradm.prov_master pm
    ON ap.seq_prov_id=pm.seq_prov_id
    LEFT JOIN windsoradm.note_master nm
    ON nm.seq_memb_id=a1.seq_memb_id
    INNER JOIN windsoradm.member_mv mv
    ON mv.seq_memb_id=a1.seq_memb_id
    Where mv.Line_of_Business <>'SFS'
    /*AND A1.PLACE_OF_SERVICE IN ('11','21','22','24')*/
    /*AND a1.active_physician_advisor = 'Y'*/
    /*AND (a1.closed_reason ='A06' OR a1.closed_reason is Null)*/
    AND a1.insert_datetime Between To_Date ('04/01/2012', 'MM/DD/YYYY') and To_Date ('04/30/2012','MM/DD/YYYY')
    ORDER BY 1

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

  • APEX, BI Publisher and SQL Query (PL/SQL Function returning SQL Query)..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title changed, maybe SOMEONE has an idea on this??
    Message was edited by:
    Tony Miller

    Hi,
    1/ first check you are passing the bind variables and
    appropriate values in the call to your report - if
    the query returns no data then you get an empty page
    So if your query takes :P10_USERNAME variable then
    pass it to the report in the URL
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
    AME:::P10_USERNAME:MYUSER
    2/ try to use the Default layout first to check your
    report query really returns the data when called
    3/ if you defined a header in your rtf template check
    there is no & (ampersand) - if using & in the header
    and preview the template from word it displays data
    OK, but if you use this template in the report query
    it fails to render the data (bug in Apex-> Bi
    Publisher integration maybe?)
    4/ If using the table in the rtf template check its
    width does not overflow the page margins - there is a
    problem with pdf export
    5/ check
    /oc4j/j2ee/home/application-deployments/xmlpserver/app
    lication.log forthe information on BI Publisher runs
    RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
    Thank you,
    Tony Miller
    UTMB/EHN

  • On Submit process not firing -report (PL/SQL function returning SQL query)

    Can anyone suggest possible causes / solutions for the following problem?
    I have a report region that uses a PL/SQL function returning SQL query. The report allows the user to update multiple fields / rows and then click a button to submit the page which should run the On-Submit process to update the database. However the process does not run and I get a 'HTTP404 page cannot be found' error; and when I navigate back using the Back button I cannot then navigate to any other page in my application without getting the same error. The button was created by a wizard selecting the options to submit the page and redirect to a (same) page. The button does not actually have a redirect in its definition but the wizard created a branch to the same page which should work and the button has the text 'submit as SUBMIT' next to it so it appears to be set up correctly.
    I have recreated this page several times in my application and I cannot get the On-Submit process to run. However I have created a cut down version of the same page in the sample application on apex.oracle.com at http://apex.oracle.com/pls/otn/f?p=4550:1:179951678764332 and this works perfectly so I am at a loss to understand why it does not work in my application. I cannot post any part of the application itself but if anybody would like to check out page 30 of the sample application (Customer Update Test tab) updating the surnames only, using credentials ja, demo, demo this is pretty much what I have got in my application.
    Any ideas would be much appreciated?

    Thanks for the suggestions guys. I have now identified that the problem goes away when I remove the second table from my report query. The original report query retrieved data from two tables and the process was updating only one of the tables. I thought I had approached the task logically i.e. first get the report to display the records from the two tables, then get the process to update the first table and finally to modify the process further to update the second table.
    Can anyone point me to an example of multiple row updates on multiple tables using a PL/SQL function returning an SQL query?

Maybe you are looking for

  • Installing Windows 7 using Bootcamp?

    I got a Macbook Alumimum 13.3", release in late 2008. It's now installed with Snow Leporand 10.6.2 OS. I'd like to know if bootcamp support installing Windows 7 as well?

  • Which photoshop version works with windows 8?

    I have tried cs2 and it does not work. Does anyone know which is the most economical photoshop version works well with windows 8?

  • How to get users to start with the first episode?

    I checked my stats today and found that the most recent episode of my podcast is the one the has been hit waaay more than any of the others. But I'd really prefer listeners hit the first episode first. Do other podcasters find this? Is it worth re-or

  • Can't use phone.

    Basically, I lost all my Icloud information. ICloud Password, Username, Email Adress, and Email Adress Password. I know none of that. I did a factory reset on my phone and now I need my Icloud username and password to use it. (apple id) i tried using

  • Webdynpro ABAP: data binding for node having  subnodes and attributes

    Hello, Problem description: There is parent node (cardinality 0..n), which has some attributes and also a sub node. This parent node has to be bound to an internal table. The fields of internal table correspond to the attributes of the parent node. N