Select in plsql

Hi All,
- 11gR2 DB set as:
NLS_CHARACTERSET US7ASCII Character set
NLS_NCHAR_CHARACTERSET AL16UTF16 NCHAR Character set
- I have table column as below. It is storing the special characters like ABCµτŭXYZ
entity nvarchar2(2000)
- When I see the data in oracle SQL developer, it shows the special characters ok.
The moment I select the entity in PL/SQL, entity is losing the charset and shows ?.
That is ABC???XYZ
How do I fix this? Like using java stored procedure etc…
Any thoughts?
Thanks for your help.

user5156030 wrote:
What I meant is
after selecting the entity in PL/SQL, I am displaying it using htp.print (I am doing all this in the stored procedure and displaying using plsql web toolkit)In that case the data is rendered by the browser. PL/SQL acts as the "conduit" of data between the database and the browser.
The browser needs to support the specific charset to render. It needs to be instructed (via the HTML response created by PL/SQL) correctly. More than that I unfortunately do not know - we do not deal with anything other than standard charsets in Oracle and HTML.
I did the following test - created this procedure and called it via an Apache mod_plsql server.
create or replace procedure WebTest is
begin
        htp.prn( 'Japanese kanji (漢字) character set' );
end;The web browser displayed the following:
Japanese kanji (¿¿) character setSo it seems to be a charset issue - possibly you need to specify specifics in the Mime header of the HTML payload? But this is not a PL/SQL language or Oracle issue. As neither does the actual rendering of that string on the client. You need to make sure that your code generates the correct payload for the client to render.

Similar Messages

  • How to get the rowid and the entire record selected in PLSQL?

    The code given below does not work.
    You cannot select the record and the rowid using a cursor in one-shot.
    But you could do that in a direct SELECT in "SQL Plus" when you select records for display. Is this a bug in ORACLE PLSQL? Or is there another way to do this?
    DECLARE
    objid_ VARCHAR2(200);
    rec_ xxx_tab%ROWTYPE;
    CURSOR get_rec IS
    SELECT t.*, t.rowid
    FROM xxx_tab t;
    BEGIN
    OPEN get_rec;
    FETCH get_rec INTO rec_, objid_;
    CLOSE get_rec;
    END;
    -----------------------------------

    You cannot fetch into both a record type and a variable. You have a few options, you can declare the record a s a rowtype of the cursor like this:
    DECLARE
       CURSOR c IS
          SELECT t.*, rowid rid
          FROM t;
       l_rec c%ROWTYPE;
    BEGIN
       OPEN c;
       FETCH c INTO l_rec;
       CLOSE c;
    END;You could use an implicit cursor and let Oracle deal with the record type internally (not to mention the open fetch and close) like this:
    BEGIN
       FOR rec in (SELECT t.*, rowid rid FROM t) LOOP
          do_stuff with rec.col_name
       END LOOP;
    END;Note that in both of these you must alias the rowid column to some other name, you could also manually construct the record type to match the table and add a column od ROWID datatype to hold the rowid.
    Finally, I think, depending on what you are actually going to do with the rowid, and how you feel about having records locked, you could look at declaring the cursor as FOR UPDATE and get rhe rowid for free.. This would be most appropriate if you are planning to update the table in the cursor (a bad practce by the way). Something like:
    DECLARE
       l_rec t%ROWTYPE;
       CURSOR c IS
          SELECT t.*, rowid
          FROM t;
    BEGIN
       OPEN c;
       FETCH c INTO l_rec;
       do_whatever with l_rec
       UPDATE t
       SET whatever
       WHERE current of c;
    END;John

  • Set row select

    Hello.
    How I can set row select from PLSQL process handler after commit.In more detail  I have some set of field in my filter. I need to select all report rows which match this filter.
    Thanks in advance Andrii.

    Hi Andrii,
    I'm not sure if I understand you correct, but if your report has checkboxes, which you want to set checked when they match your filter, you could try the following:
    In your report query, where you define your apex_item.checkbox add a case stement.
    SELECT case when <your_filter_condition> then APEX_ITEM.CHECKBOX(1,<your_column>,'CHECKED')
                          else   APEX_ITEM.CHECKBOX(1,<your_column>)
                  end case as " "
    , <other_columns>
    FROM <your_table>
    regards,
    Vincent Deelene

  • Creating and selecting from a dynamic table

    Hi,
    Iam trying to create a table dynamically and selecting from it in same plsql block, but am getting "table doesnot exist" error. however if i just create a table dynamically and then do a select on it seperately it works..
    below is sample code for the same,
    working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    end;
    select count(*) from emp_bglr ...works and return me 0 rows
    Line: -----
    but when i include select in plsql block ..it throws "Table does not exists" error...(iam running below plsql block after dropping the created table)
    not working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    --COMMIT;
    END;
    Select count(*) into l_cnt from emp_bglr;
    dbms_output.put_line('cnt is '||l_cnt);
    end;
    Line: -----

    Becuase your code is first checked for syntax/object existance during compilation and throws an error saying the table does not exist.
    Try this:
    SQL> ed
    Wrote file afiedt.buf
      1   DECLARE
      2   loc VARCHAR2(20):='bglr';
      3   l_cnt pls_integer;
      4   BEGIN
      5   -- create an employee information table
      6   EXECUTE IMMEDIATE 'CREATE TABLE emp_bglr(
      7   empno NUMBER(4) NOT NULL,
      8   ename VARCHAR2(10),
      9   job VARCHAR2(9),
    10   sal NUMBER(7,2),
    11   deptno NUMBER(2)
    12   )';
    14  Select count(*) into l_cnt from all_objects where object_name = 'EMP_BGLR';
    15  dbms_output.put_line('tab cnt is '||l_cnt);
    16  IF (l_cnt = 1) THEN
    17  l_cnt := 0;
    18  EXECUTE IMMEDIATE 'SELECT count(*) from apps.emp_bglr' into l_cnt;
    19  dbms_output.put_line('data cnt is '||l_cnt);
    20  END IF;
    21* end;
    SQL> /
    tab cnt is 1
    data cnt is 0
    PL/SQL procedure successfully completed.
    SQL> Edited by: AP on Aug 5, 2010 5:51 AM
    Edited by: AP on Aug 5, 2010 5:52 AM

  • Multi Select List Item

    Hi All
    I want to have a field on my page that will be having around 80 values say Poplist.But i want to select multiple values.Like may be you would have seen some sites on which there is a field say Technologies you know and we select OAF,PLSQL etc..
    Thanks in Advance.

    Hi,
    You can use ListBox bean of OAF, you can not create it at design time so you need to create using controller, following is the sample code
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    // Create the list bean (be sure to give it a name).
    OADefaultListBean list =(OADefaultListBean)createWebBean(pageContext,
    OAWebBeanConstants.DEFAULT_LIST_BEAN,null, "positionsList");
    // Specify the view object that you will use to populate the list bean values.
    list.setListViewObjectDefinitionName("oracle.apps.fnd.framework.toolbox.poplist.server.PositionsVO");
    // Specify the display and internal value attributes in the associated viewobject.
    list.setListValueAttribute("LookupCode");
    list.setListDisplayAttribute("Meaning");
    // Configure the list box to allow selection of multiple values.
    list.setMultiple(true);
    // Even though you created the component with an ID, you must explicitly
    // make this call to setName().
    list.setName("posList");
    // In this example, we're adding the list box to a messageComponentLayoutregion, so we
    // get the declaratively defined messageLayout region that will contain this
    // component. Note that we declaratively set a prompt for the list box on the
    // messageLayout region.
    OAMessageLayoutBean listBoxLayout =(OAMessageLayoutBean)webBean.findChildRecursive("ListBoxLayout");
    listBoxLayout.addIndexedChild(list);
    To get the values selected from list box you can use following code in your PFR
    OADefaultListBean list =
    (OADefaultListBean)webBean.findChildRecursive("positionsList");
    String name = list.getName();
    String[] selectedValues = pageContext.getParameterValues(name);
    Regards,
    Reetesh Sharma

  • How to register the Discoverer workbook in Oracle Apps 12i

    I am trying to access a workbook form the Apps side. I did all the things which I got from metalink except the last step 6. I reloginned and check but it is giving the error like
    "The webpage cannot be found ".
    Please assisst me.
    1. Create the workbook.
    2. Open the workbook in the Discoverer Desktop or Plus edition and go to
    'File->Manage Workbooks->Properties' look for the value for 'Identifier'. Save this value.
    3. Create a form function. Open the Function form and create a new function.
    Define the Form Function.
    The form function definition includes the properties listed in these tabs:
    3.1 Description tab:
    3.1.1 Function Name: BIS_[X] (use something to distinguish it from seeded functions)
    3.1.2 User Function Name: This is the name that will show in the menu
    3.1.3 Description: Add a description of the function if you want.
    3.2 Properties tab:
    3.2.1 Type: Select "SSWA plsql function"
    3.2.2 Maintenance Mode Support: Leave as "None"
    3.2.3 Context Dependence: Leave as "Responsibility"
    3.3 Form tab:
    3.3.1 Form: Leave the field blank.
    3.3.2 Application: Leave the field blank.
    3.3.3 Parameters: workbook=<(workbook identifier from step2) &PARAMETERS=sheetid~worksheet id*param_parameter name One~Parameter One Value*param_parameter name Two~Parameter Two Value*
    Eg; 'workbook=TEST_WORKBOOK&PARAMETERS=sheetid~1*' would open sheet 1 of the workbook.
    # According to the Applications Administration Edition the workbook name will also work here.
    See Expanation section below for more information on setting up parameters and changes fro Discoverer Viewer.
    3.4 Web HTML tab:
    3.4.1 HTML call : Set as OracleOasis.RunDiscoverer
    3.5 Web Host tab:
    3.5.1 Leave all fields blank.
    3.6 Region tab:
    3.6.1 Leave all fields blank.
    3.7 Save the form.
    4. Open the menu form as sysadmin.
    4.1 Search for the main menu under which you want the link to appear.
    4.2 Add the information you need such as prompt, submenu, description etc.
    4.3 Enter into the Function field the name of the function you created in step 3.
    4.4 Save the menu form.
    A message will appear saying that a concurrent program will run to regenerate the menus.
    You can cancel it if you want and do step 5 below if the menu does not appear after the concurrent program runs.
    5. Use adadmin and recompile the menu information to make the changes appear.
    6. Bounce Apache and Forms.
    Thanks,
    ABR

    Hi Hussein,
    Very much thanks to you Hussein. I gone through the doc 471303.1 and came to know that the options and values which we have to take for Launching Discoverer Report from 11i & 12i is differenet. Ohh great its working and I have a question when I am selecting the Discoverer Report function from the Apps the follwoing error is coming.
    A connection error.
    - Oracle BI Discoverer is unable to complete the connection initialization.
    - Default or specified schema containing EUL tables is inaccessible and asking for the log in details.
    Can't we go directly to the Discoverer Viewer where we can see the Worksheets without coming through the login page.
    Once again thank you Hussein.
    ABR.

  • Temp segments full

    Hi,
    There is a report based on a select which includes several tables, views and an inner select. In the last several years, any date will give no more than a couple of hundred records except for one day in 2006 when there are almost 3,000 records, and November 8th of this year when there are over 7,000 records.
    The report is fine except when it includes those two days. However, running the select in plsql is no problem at all (results within a couple of seconds). It is only in Discoverer where a message will come up that the temp segments are full.
    Can anyone give me a suggestion as to what to look for in order that I can change the sql?
    Thanks.
    Leah

    Hi Srini,
    Thanks for responding. In the meantime I received a response from Metalink. Apparently the sql that is being formed by discoverer is different than the custom sql folder. I am supposed to run the sql that was executed in Discoverer in sql*plus. I am waiting for sql*plus to be installed in my computer at work.
    Thanks. I will be happy to update this thread with the results.
    Leah

  • Configuration of Oracle9iAS

    I install the Oracle9iAS on Windows 2000 Server,now I can go to
    the http://<hostname>:80 to view the Oracle AS Page,but when I
    select "Mod plsql Configuration Menu" to add DAD,the
    503 "Service Temporarily Unvaiable" error occurs.
    Version:Oracle9iAS v1.0.2.2.1 Enterprise/Standard Edition for
    WindowsNT/2000.
    Install Type:Enterprise Installation
    **The installation file is downloaded from the following web
    site:
    http://otn.oracle.com/software/products/ias/htdocs/winsoft.html#9
    ias1022nt
    Enviroment:
    OS:Windows 2000 Server
    Database:Oracle8i (Local)
    Would you like ell me why the error occurs?
    I will appreciate for your helps!
    Best Regards!

    HI
    I am not sure whether you add DAD from modplsql.
    Access http:/<machine-name>:<port>/pls/admin_/gateway.htm to
    modify or add DAD settings
    sarath

  • Suspect message

    hi,
    after i have launched query (simple select) on plsql/developer, i have had this message.
    SQL> select count(*) from myTable;
    "Cannot execute commands now"
    I have never seen that before.
    Any idea.

    if your command window is busy executing a long running command, and before it finishes, you type another SQL statement and press enter, you get this message.
    Just wait for the previous command to finish.
    Type the first select statement, press enter and while it is executing, type the second select and press enter.
    SQL> select * from a_really_big_table where rownum > 1 ;select * from dual ;
    Cannot execute commands now
    SQL> It generates an error when you try to execute a "select * from dual" while the prior select is still running.
    Message was edited by:
    Kamal Kishore

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Plsql procedure containing select statement to fill page items

    I would like to fill items :P200_A and :P200_B and so on
    with the result of a SELECT which depends on the different values of many select lists.
    E.G. :P200_list_alpha with the list of values
    STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff
    :P200_list_beta with the list of values
    STATIC:active;active,passiv;passiv,excluded;excluded
    How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).
    What is a convenient way to write the select statement ?
    I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.
    How to solve this problem in an elegant way ?
    In my opinion the CASE statement could be helpful, but how to use it in the WHERE clause with this nested conditions ?

    I think I got it:
    SELECT col1, col2, col3, ...
    INTO :P200_A , :P200_B , ....
    FROM mytable_1, mytable_2
    WHERE mytable_1.col1 = mytable_2.col1
    AND (
    CASE
    WHEN :P200_LIST_ALPHA = 'less' AND NVL(TO_COL_WITH_ALPHA, 0) < 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'equal' AND NVL(TO_COL_WITH_ALPHA, 0) = 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'above' AND NVL(TO_COL_WITH_ALPHA, 0) > 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'indiff' THEN 1
    ELSE 0
    END = 1 )
    AND
    ( CASE
    WHEN :P200_LIST_BETA = 'active' AND TO_COL_WITH_BETA IN ( 'a', 'A', 'akt', 'AKT' ) THEN 1
    WHEN :P200_LIST_BETA = 'passive' AND TO_COL_WITH_BETA IN ( 'p', 'P' ) THEN 1
    WHEN :P200_LIST_BETA = 'excluded' AND TO_COL_WITH_BETA = 'X' THEN 1
    ELSE 0
    END = 1 )
    ;Edited by: wucis on Oct 24, 2011 4:09 PM

  • Select data from plsql collections

    Hi All,
    I am not a developer but working as a DBA, so not very much familiar with pl/sql, still gone through with documentation and could come up with some solution of my problem. I need some expert advice here.
    Problem : I am writing down some kind of plsql program for monitoring of some special batch job, I know we have lot of other option to do the same including db/grid control ..etc but for some
    reason i have to do this using plsql only.
    Requirement : my requirement is to select data from table in plsql and then should have ability to query it again and again. I would not prefer to go to table rather than directly from plsql..
    I wrote down below code for sample, bulk collect data into collection type and can print using for loop.
    Declare
    type ts is table of v$session%rowtype index by pls_integer;
    tsess ts;
    begin
    select * bulk collect into tsess from v$session ;
    for i in 1..tsess.count loop
    dbms_output.put_line(tsess(i).terminal);
    end loop;
    end;
    But, is there any way same collection ( tsess in above example ) can be queried using select statement like 'select * from table ( Tsess ) ' I have searched on net and found this can be done using creating type at database level. But my problem is I can not create any object in database as being it is a production one.
    I was looking for if is there any way same can be accomplished ... like cast / multiset .. however, I could not get it through.
    your help would be appreciated !!
    Regards,

    I don't think you need to use arrays here, only SQL, have a look at subquery factors and report back if that is insufficient...
    Edited by: BrendanP on 12-Feb-2012 03:07 to add an example:
    I gather that you want to 'requery' data that you have already got from the database purely to be able to use SQL functionality such as ORDER BY in multiple ways. Here is how you can do this in the original SQL for one particular example, where you want to query v$sql ordering by CPU time and by disk reads separately (I tested this but the output won't look good here, so omitting it):
    WITH v AS (
    SELECT
        Substr (sql_text,1,500)             sql_text,
        cpu_time/1000000                    cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        CASE WHEN rows_processed != 0 THEN Round( buffer_gets / Nvl (Replace (rows_processed, 0, 1) ,1)) END Buffer_gets_rows_proc,
        Round (buffer_gets / Nvl (Replace (executions, 0, 1), 1)) Buffer_gets_executions,
        elapsed_time / 1000000              elapsed_second,
        module
    FROM v$sql s)
    SELECT
        'CPU'                order_by,
        cpu_seconds          order_val,
        sql_text,
        cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        buffer_gets_rows_proc,
        buffer_gets_executions,
        elapsed_second,
        module
    FROM v
    UNION
    SELECT
        'Disk reads',
        disk_reads,
        sql_text,
        cpu_seconds,
        disk_reads,
        buffer_gets,
        executions,
        buffer_gets_rows_proc,
        buffer_gets_executions,
        elapsed_second,
        module
    FROM v
    ORDER BY order_by, order_val DESC

  • PLSQL Funciton in SELECT query for a region in APEX

    Hello, I am developing a SQL report based on SELECT query that uses a plsql function.
    However the PLSQL Function returns a numeric value and , in addition to that, it also has one out parameter.
    How do I display this out paramete's value on APEX report?
    Thanks,
    R

    From a performance perspective, calling PL/SQL functions from SQL queries is expensive because you context switch between SQL and PL/SQL. That's ok for say 20-30 rows, but as you return more rows it gets more and more expensive. If possible write it all in SQL.
    Tyler Muth
    http://tylermuth.wordpress.com
    "Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book

  • How to select a table in plsql

    hello,
    I have to select a complete table in a plsql block . But I am facing a problem of into clause with select statement in plsql. What should i do?
    If anybody knows how to do this then please help me out.
    Thanks,

    This one also you can try.
    DECLARE
    TYPE l_mobile_no IS TABLE OF main_mast.mobile_no%TYPE;
    TYPE l_cust_name IS TABLE OF main_mast.cust_name%TYPE;
    TYPE l_email IS TABLE OF main_mast.email%TYPE;
    tab_mobile_no l_mobile_no();
    tab_cust_name l_cust_name();
    tab_email l_email();
    BEGIN
    SELECT mobile_no,cust_name,email
    BULK COLLECT INTO tab_mobile_no,tab_cust_name,tab_email
    FROM  main_mast
    where rownum<10;
    FOR z in tab_mobile_no.first..tab_mobile_no.last
    loop
    dbms_output.put_line('Mobile_no'||' '||tab_mobile_no(z)||'NAME'||' '||tab_mobile_name(z)||' '||'EMAIL'||' '||tab_email(z));
    end loop;
    END;You can write into a file using of utl_file if the table contains more number of records.
    Regards,
    Achyut K
    Edited by: Achyut K on Aug 5, 2010 2:09 AM

  • PLSQL - how cani get  folders names that much my select queries in plsql

    Hello.
    Please can somebody help me.
    i am writing a procedure that access data from some tables. when i get data in any field lets say select Name From Users e.i Name.
    i want to use the value in that field to search for a folder some where in my drive C; that bears the same name in the folders.
    eg.
    if data found and exist in Table.Name.
    search for folder using PLSQL in the directories that has the same name as the value in Table.Name.
    just like searching for pictures using the picture id in tables and looking for them in some folders. how can i do this is PLSQL.
    thank you
    Edited by: user7634976 on Jun 9, 2009 10:43 AM

    OK. So just to be crystal clear, when you say "same server," you mean that the database server is also the server where all these directories have been created. Is that correct?
    Do you have Oracle directory objects (i.e. CREATE DIRECTORY) that reference the directories you are trying to use?
    i have already created a directory that write logs to a particular folder anytime i move data.You have created an operating system directory? An Oracle directory object? Both? Neither?
    A directory does not write logs. So I'm guessing that you mean that you have code that writes data to a file via UTL_FILE using an Oracle directory object mapped to an operating system directory as a result of calling a stored procedure. Is that the case? If you already understand how UTL_FILE works, how to create and manage Oracle directories, how to read and write data from files, can you be a bit more specific about the particular problems you are having copying files from one directory to another?
    using that same directory i have the images there and i want to move them to another directory an rename the copied folder with its content in another folder by running a procedureI'm not sure I follow.
    i have the images thereYou want to use the same Oracle directory object that you are using for writing the logs as the source for the image files you want to copy?
    i want to move them to another directoryYou want to move them to another Oracle directory object? Have you created the destination directory object?
    rename the copied folder with its content in another folderI'm afraid that makes no sense to me. Can you try explaining it again?
    Justin

Maybe you are looking for