PL/SQL code not running

Hi , Please help to get the rows which have a character in the PFNUM column for this table
EMPNU PFNUM NAME
100 222 rat
101 a33 sanu
102 4a4 rahul
our PL/SQL is
1 DECLARE
2 i number;
3 j number;
4 t varchar2(10);
5 CURSOR ratnesh_cur IS
6 select PFNUM from employee;
7 BEGIN
8 OPEN ratnesh_cur;
9 FETCH ratnesh_cur into t;
10 FOR i IN 0..LENGTH(t)
11 loop
12 FOR j IN 0..9
13 loop
14 IF SUBSTR('t',i,1)= j THEN dbms_output.put_line(t);
15 ENDIF;
16 END LOOP;
17 END LOOP;
18 CLOSE ratnesh_cur;
19* END
20 /
END LOOP;
ERROR at line 16:
ORA-06550: line 16, column 5:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
if
ORA-06550: line 19, column 3:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
following:
loop

TO APC ...
<quote>Which solution is appropriate depends on the spec details.</quote>
Indeed … that is why I provided a simple alternative answering the original question (my interpretation of it extrapolated from the actual data set provided) … I did not comment on your reply.
But let me address your answers:
<quote>The best way of checking whether a value is numeric is to test for failure of the Oracle built-in function TO_NUMBER()</quote>
That would be too strong a statement, wouldn’t it?
Let us assume a table with a varchar2 column which we know contains only alphanumeric characters … 2097152 rows … half containing only digits … half with a mix of digits, upper and lower alphabetical characters.
flip@FLOP> select count(0) from apc
2 where instr(translate(lower(v)
3 ,'abcdefghijklmnopqrstuvwxyz'
4 ,'xxxxxxxxxxxxxxxxxxxxxxxxxx'),'x') > 0
5 ;
COUNT(0)
1048576
Elapsed: 00:00:05.02
flip@FLOP> select count(0) from apc
2 where is_number(v) = 0
3 ;
COUNT(0)
1048576
Elapsed: 00:00:13.05
“is_number” is your function modified to return 1 (true) or 0 (false) instead of the Boolean.
Clearly a solution employing TO_NUMBER is not always the most performant way (as you seem to imply) … all those context switches between SQL and PL/SQL do add up.
Soooo … there is no “most performant way” to check for numeric or non-numeric values for all categories of problems … in fact there isn’t even a universal solution … one has to have some knowledge of the data domain being checked and the environment context.
So how about the ‘?’ and '@’? … Is the string ‘-1?123@99' numeric or not? Having modified your “is_number” function yet again to do “ln := to_number(pv_string,'9G999G999D99');” …
flip@FLOP> select is_number('-1?123@99') from dual;
IS_NUMBER('-1?123@99')
0
NO.
flip@FLOP> alter session set nls_numeric_characters='@?';
Session altered.
flip@FLOP> select is_number('-1?123@99') from dual;
IS_NUMBER('-1?123@99')
1
YES.
But forget about nls settings … how about ‘-123e2’? … is this numeric or not ?
flip@FLOP> select to_number('-123e2') from dual;
TO_NUMBER('-123E2')
-12300
According to TO_NUMBER, it is numeric … for the person having the knowledge of the data domain being checked that well may be a false positive.
Hope this proves the point about the universal solution and the qualities of TO_NUMBER.
As for <quote>And if the character is uppercase?</quote> … this kind of flipped me … looking at the link supplied by you … and glancing over the implementation of “StringParse” one could well ask: “and if the string contains lowercase?” … but nobody did … would’ve been a bit too picky and outside the main technique being demonstrated.
Gabe

Similar Messages

  • Can generate the TKPROF file without the SQL is not running completed ?

    Dear all:
    I want to generate the TKPROF file from the trace file, Can generate the TKPROF file without the SQL is not running completed ? Is it the TKPROF file can be used? because the report is too large. My environment is ORACLE 11.5.9
    Regards
    Terry

    When you can wait for completion, then that's the easiest route.
    When you can't wait, you'll have to use a different method. I suggest to watch the v$ views for what your session is doing. Views like v$session, v$session_wait, v$sess_io and the views starting with v$sql. Also worth mentioning is Tanel Poder's site, which contains some very useful scripts for diagnosing performance problems this way: http://tech.e2sn.com/.
    Regards,
    Rob.

  • Unit Test Variable Substitution in PL/SQL User Vailidation code not running

    Hi
    I am using new Unit Test Feature in SQL Developer 2.1.0.62.
    I have created a test implemented to test a function. The function has a VARCHAR2 parameter as input and returns a BINARY_INTEGER.
    I would like to perform 'Process Validation instead of specifying an explicit 'Result'. The check box 'Test Result' is unchecked.
    I have seen in the doc. that I can use substitution variables in my user defined PL/SQL code. I try
    IF {RETURNS$} < 0
    THEN ...
    but I always get the error
    ERROR
    <RETURN> : Expected: [Any value because apply check was cleared], Received: [-103]
    Validation User PL/Sql Code failed: Non supported SQL92 token at position: 181: RETURNS$
    Obviously, the program doesn't recognize {RETURN$}.
    Am I missing something?
    br
    Reiner

    Hi all,
    I have installed the latest version of SQL Developer (2.1.1) that fixed the problem - must have been a bug.
    The only problem was that I got an ORA-904 TEST_USER_NAME... error. I export my tests, dropped the repository, created a new one and reimported everything. Now it works as it should.
    br
    Reiner

  • SQL Code not working in Forms Developer?

    Hi all,
    I'm using Oracle 10g and I have th following code running on iSQL+ but not working on Forms and I got the following erro
    The SQL code:
         select returningreason
            from (
                     select returningreason,
                     dense_rank() over (partition by 1 order by count(*) desc) as drnk
                     from returned_goods
                     group by returningreason)
           where drnk = 1;And the error happens near the word over to the right and the error statement is:
    Error 103 at line 18, column 19
       Encountered the symbol "(" when expecting one of the following:
             , formThanks in advance :)

    Triggers are compiled in forms so need to use only the features available to forms, which doesn't include all the new stuff in the database.
    select over partition
    NVL2They don't work in forms and reports too.
    Also if you use them in record Group
    Forms/SQL Compiler was not lined up to the database(10G).
    Meanwhile,for example. Pipelined TABLE and relative Select work in Reports AND Forms.

  • Bug: Validate PL/SQL code not working?

    Hallo,
    in the newer versions of Apex there seems to be an issue with Process code validation.
    It doesn't make any difference if i check the
    "Do not validate PL/SQL code (parse PL/SQL code at runtime only)" option or if i don't.
    There is no parsing of the code and i can write the worst syntax without any problem resulting in bad runtime errors. However the parsing of Region SQL and PL/SQL is working well.
    Anybody knows what this is ?
    Thanks,
    Jochen
    Message was edited by:
    Jochen.Zehe

    I think I know what is happening.
    On the Create Process wizard, when you enter your PL/SQL code in
    http://i14.tinypic.com/4qxai38.jpg
    and click the Next button, the code is parsed and throws an error if it has syntax errors. But if you click on the Create Process button, the process is created, regardless of whether it has syntax errors or not!
    Similarly, the Edit Page Process page also doesn't appear to validate the code, it happily saves the process with any nonsense in the Process Source box, even when the "Do not parse code" checkbox is unchecked (default)
    Definitely a bug (not sure if it is regression from 2.x or not)

  • SQL code not working inside Java

    Below is my code from java. here, i'm trying to execute below sql code inside my java coding. its preety straight -
    ResultSet rs = null;
    PreparedStatement prepStmt = null;
    String statement="select * from TIMINGTABLE WHERE COUNTRY = 'USA' AND RE_DATE >= TO_DATE('04/11/2012','MM/DD/YYYY') order by COUNTRY";
    prepStmt = con.prepareStatement(statement);
    rs = prepStmt.executeQuery();
    dats it. but, its giving this error ---- SQL syntax error: the token "(" was not expected here
    now, here, when i simply remove this part from the above sql line ----- AND RE_DATE >= TO_DATE('04/11/2012','MM/DD/YYYY') -----the code works perfectly.
    RE_DATE is a date field in the sql table.
    I even tried this option too - TO_DATE(RE_DATE, 'MM/DD/YYYY') >= TO_DATE('04/11/2012','MM/DD/YYYY')
    which is giving same error
    please help
    -prodyut

    927428 wrote:
    Below is my code from java. here, i'm trying to execute below sql code inside my java coding. its preety straight -
    ResultSet rs = null;
    PreparedStatement prepStmt = null;
    String statement="select * from TIMINGTABLE WHERE COUNTRY = 'USA' AND RE_DATE >= TO_DATE('04/11/2012','MM/DD/YYYY') order by COUNTRY";
    prepStmt = con.prepareStatement(statement);
    rs = prepStmt.executeQuery();
    dats it. but, its giving this error ---- SQL syntax error: the token "(" was not expected here
    now, here, when i simply remove this part from the above sql line ----- AND RE_DATE >= TO_DATE('04/11/2012','MM/DD/YYYY') -----the code works perfectly.
    RE_DATE is a date field in the sql table.
    I even tried this option too - TO_DATE(RE_DATE, 'MM/DD/YYYY') >= TO_DATE('04/11/2012','MM/DD/YYYY')
    which is giving same error
    please help
    -prodyutWhat kind of DB you use?
    How do you connect to it?
    (If you use ODBC for example, that won't work)

  • T-code not running

    Hi Gurus,
    I m trying to following t-code but message display t-code not exists, I m using country grouping 99.
    RHINTE10
    THINTE30
    THINTE00
    THINTE20
    RHINTECHECK
    THINTE20_ALT
    Please help how I can run above t-code.
    Thanks

    Hello Maaz,
    First of all to confirm you the items you have listed are not transaction codes.
    They are the programs using which OM & PA integration is done.
    Now how to use these programs we have two methods :
    1) Go to t.code SE38 or SA38 give the program name and execute (F8).
    2) The following transaction codes you can use corresponding to the programs
    RHINTE00 -> OOPH(set up PA-PD integration)
    RHINTE10 ->OOHP(Set up PD-PA integration)
    RHINTE20 -> OOPP(Consistency check for integration)
    RHINTE30-> OOHQ(Integration)
    RHINTECHECK->S_PH0_48000128(Consistency check for OM-PA Integration)
    RHINTE20_ALT.
    Last but not the least just to correct your question, the program name series is RHINTE** and not THINTE**
    Best Regards
    Santosh

  • PL/SQL Code not working without debug statements

    Hi Guys,
    I have a pl/sql code in a procedure, logic iterates through almost 40K records, conditional delete and update.
    When I execute this code, I dont see the deletes and updates happening, though procedure executes for 8 minutes and exits wihtout any error, execption.
    In same procedure when I write some debug statements like dbms_output, then everything seems to be working fine.
    I know this scenario happens in Oracle Forms, wehre we use SYNCHRONIZE.
    But this is plain pl/sql procedure.
    any thoughts on this?
    Av.

    COMMIT ?
    Aside from that, no idea what your procedure looks like, what it does, what version of Oracle you are using, how you are determining "I dont see the deletes and updates happening". etc...
    You'd need to provide a slew of information for anyone to give you any meaningful help.
    I can only assure you that DBMS_OUTPUT doesn't do magic :)

  • SQL Code not working in Forms Developer without Functions?

    Hi all,
    I've write this code into Forms at it's work correctly in SQL and the following error occurened
    The PL-SQL Code:
    DECLARE
         Product_Name Products.Name%TYPE;
         Most_Occurence NUMBER(10);
    BEGIN
         SELECT *
         INTO Most_Occurence, Product_Name
      FROM (SELECT   COUNT (returned_goods.ID) AS "Max Occurence", products.Name
      FROM Returned_Goods
      JOIN Products
      ON returned_goods.productId = products.Id
             GROUP BY returned_goods.productId, products.Name
             ORDER BY COUNT (returned_goods.ID) DESC)
    WHERE ROWNUM = 1;
    END;The error message (appears near JOIN Products) :
       Encountered symbol "PRODUCTS" when expecting one of the following:
          ), with group having intersect minus order start union where connectThanks in advance
    Edited by: ZiKaS on Dec 30, 2008 8:57 AM

    Now...obviously you can't use ansi join syntax in that forms module. So rewrite your query with
    FROM returned_goods, products
    WHERE returned_goods.productId = products.id
    hth

  • Calling Console Application that uses WebBrowser from SQL Server - Not Running

    Hi there. I am working in a program automation that needs to get files from a website and put it in a database. It is done but as I need a console application and need webbrowser that comes from Windows Forms, I am trying to call it from the SQL Server using
    the xp_cmdshell but when it runs the .exe, it execute the block that is before the Application.Run() command but when it reaches this line, it stay running on Task manager but it not execute my code. How can I fix this? I had first created a Windows form application
    but it was not working anyway and then I tried a console application and then I use the [STAThread] and Application.Run(). At least it runs the file from SQL Server but is not executing all my code, I think that it stops on Application.Run() line. Any help
    will be very useful.
    Thanks for now.

    Thanks for the response. What I mean is that it just run the part of the code that is just using the Console, that's the code:
    // Main Method
    [STAThread]
    public static void Main()
    clearDatabase(myConnection);
    Console.Title = "Suframa Itens Robot";
    //If log file exists, it is deleted
    if ( File.Exists(@"suframaLog.txt") )
    File.Delete(@"suframaLog.txt");
    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(loginWebsite);
    try
    //It is called as the program uses the WebBrowser Class from Windows Forms namespace
    //and it is a console Application
    Application.Run();
    catch ( Exception ex )
    Log(ex.Message);
    As you can see, I call a function on start named ClearDatabase, when I call the file from sql server it executes, the tables are cleared, but what I think is that the problem stop when reach the line Application.Run() as it is the line that allows the remaining
    code to execute as it uses events from WebBrowser class. 
    It is a program automation that needs to get a lot of files from a website that needs login and read line by line from the files and put on server, if I call it from the executable it runs fine, the only problem is when calling from SQL Server, Do you know
    how to fix this?
    Thanks.

  • SQL Agent not running Script in Package which calls an Excel containing Macro

    I have a script task in SSIS package which calls Excel VBA file containing Macro, this file is on the local drive, when I run this package through SSDT the package works ok and the macro does what it needs to. However when I set up a
    sql agent job to call the package then it fails at the Script task. I have created a credentials and proxy user as my self so I should Have full rights.
    But it fails through the job and not through SSDT, can you advise ?

    Hi Asad,
    Since the error message “Script Task Run Excel: Error: Exception has been thrown by the target of an invocation” is too generic, we should find a way to return full error details from SQL Server Agent job. Firstly, configure logging for the steps you wish
    to keep log data for. Secondly, create a stored procedure to return details of the step at which a job failed based on the job name. Finally, execute the stored procedure. For more details, please refer to the following blog:
    http://www.sqlservercentral.com/articles/SQL+Server+Agent/67726/
    In addition, the following similar two threads are for your references:
    http://sornanara.blogspot.jp/2014/04/code-0x00000001-exception-has-been.html
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/4a20219e-4a90-41be-acfe-b8846dc2c38a/error-while-executing-a-ssis-package-which-contains-a-script-task-through-sql-server-agent-job?forum=sqlintegrationservices
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Help with html code. not running properly once on server

    The video works fine in captivate and works once i publish it, but when I try to upload it onto the server it does not. This is my first time using captivate 4, and when I matched the codes from my old movies they were quite different. So I just messed with the code I had and made it lok like the old vodes and it runs fine on the server.
    I was wondering if anyone had any ideas on what is going on with the code that it does not work on the server?
    Thank you!!!!!
    -danielle

    Hello Sue. It's very easy actually.
    If you have the lastest update of Muse CC from Nov 2013, there is a FREE Muse Library by musegrid.com that you can download from the Adobe Muse Exchange page that does this specifically using Google Analytics.  Here is the direct link should you like to check it out: 
    http://muse.adobe.com/exchange-library/add-google-analytics
    Start by "Right Clicking" on the "Master Page Icon" in the "Plan View" and choose "Page Properties" from the list of menu options available. 
    This will open up the "Page Properties Dialog Box" for the entire site. Once that dialog box is open, paste your code into the "Metadata" tab section (I believe that tab is displayed at default - at least on the Mac it is - I'm pretty sure it's the same on the Windows platform).
    All anaytics embed code goes in the <head> tag of an html page (note: it actually says "HTML for <head>" at the top of the embed window area - making it helpful to know you're in the right area). This is also where you would add any <meta> tags too like facebook's OpenGraph code etc.
    If using more than one master, included it to all masters.  If just using it on a specific page - say like a landing page, just go to that particular page in your site's "Plan View" and paste it there instead.
    Incase i get too "wordy" i've attached screen shots of what these should look like. 
    Good luck Sue!
    And congratulations on a nice new computer too - its got "juice".

  • Sql will not run... ORA-01874

    The SQL given below works perfect from the SqlPlus command line outside of SqlDeveloper.
    If I try and run it using the same login from with SD I get...
    Ora-01874: time zone hour must be between -12 and 13
    ORA-02063: preceding line from <SID_NAME>
    Here is the SQL
    SELECT
    Case_Task.TASK_ID,
    Case_Task.SCHED_START_DATE,
    Case_Task.TASK_DESCRIPTION,
    Case_Task.CASE_ID
    FROM
    CASE_TASK,
    TASK_TYPE,
    TASK_ACTIVITY
    WHERE
    (Case_Task.TASK_TYPE=Task_Type.TASK_TYPE AND Case_Task.TASK_ACTIVITY=TASK_ACTIVITY.TASK_ACTIVITY)
    AND (
    Case_Task.TASK_ID>='68365276'
    AND Case_Task.CASE_id = '64877131'
    AND Task_Type.DESCRIPTION='Administration'
    AND TASK_ACTIVITY.DESCRIPTION='Follow up'
    AND Case_Task.TASK_STATUS NOT IN ('Cancelled', 'Completed, Closed', 'Unresolved, Closed')
    )

    You can use the "alter session set nls_date_format = 'format'; " command, but I think that this will only affect your Oracle 10 session and not the Oracle 9 session you are accessing via the db link.
    What happens if you select to_char(case_task.sched_start_date, 'DD-Mon-YYYY') instead of selecting the date value?
    What about selecting count(*)?
    I vaguely remember some earlier posts on timezone problems across database links - you may want to try searching the forum.

  • PL/SQL code not working

    why is this code giving me error?
    declare
    type dept_tab_type is table of departments%rowtype;
    index by binary_integer;
    dept_tab dept_tab_type;
    v_counter number(3):= 270;
    begin
    for i in 10..v_count
    loop
    select * into dept_tab(i)
    from departments
    end loop;
    for i in dept_tab.first..dept_tab.last
    loop
    DBMS_OUTPUT.PUT_LINE(dept_tab(i).department_name);
    end loop;
    end;
    i got this error
    ORA-06550: line 3, column 5:
    PLS-00103: Encountered the symbol "INDEX" when expecting one of the following:
    begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> form
    current cursor

    I think its you DEPT_TAB_TYPE deceleration which was incorrect.
    I think this might do it;
    set serveroutput on
    declare
      type dept_tab_type is table of departments%rowtype index by binary_integer;
      dept_tab dept_tab_type;
      v_counter number(3):= 270;
    begin
      for i in 10..v_counter loop
        select *
        into dept_tab(i)
        from departments
      end loop;
      for i in dept_tab.first..dept_tab.last loop
        DBMS_OUTPUT.PUT_LINE(dept_tab(i).department_name);
      end loop;
    end;
    /BUT
    UNTESTED!

  • To run a piece of PL/SQL code,  in TT  is much slower than   in ORACLE.

    A piece of PL/SQL code , about 1500 lines, package is named rtmon_event, function in it is named rtmon_SHOLD_CUS_RPT;
    the PL/SQL code is run in ORACLE.
    Now I want to get fast speed, I think of TT.
    I rewrite the PL/SQL code by grammer in TT.
    But the speed in TT is much slower than the speed in ORACLE.
    In ORACLE, to run the PL/SQL code, it need 80 seconds; but In TT, to run the PL/SQL code, it need 183 seconds;
    How can I resolve the problem?
    Btw: there are some joins of 2 tables, or 3 tables in rtmon_event.rtmon_SHOLD_CUS_RPT, and some complex DML in it.
    The run method is :
    declare
    a number;
    begin
    a := rtmon_event.rtmon_SHOLD_CUS_RPT ;
    end;
    Thanks a lot.

    The easiest way to view a plan is to use ttIsql and issue the command:
    explain SQL-statement;
    For example:
    explain select a.ol1, b.col2 from taba a, tab b where a.key = b.key;
    See the documentation that 'hitgon' pointed you to to help you interpret the plans.
    Chris

Maybe you are looking for

  • Obsolete Signatures Inheritance IPS IOS 7

    Hello all, I found that on older IPS IOS 5 is possible to inherit previously tuned signatures settings even if new signature update pack from Cisco is downloaded. Descriptipon of that how-to is available here. I'd like to know, if the same feature is

  • Can't redeem an app

    A software developer has given me a promo code to redeem a free copy of his app in the Mac App Store, but the process isn't working.  I am logged into the Mac App Store...click on "Redeem" under "Quick Links" and put in the code and get the following

  • Where can i find my iphone backup password?

    where can i find my iphone backup password?

  • Problems with new alum keyboard and orig acrylic keyboard on eMac

    Hi , I need help , pls. I just got an alum keyboard to use w/ my eMac. I've upgraded software as instructed. My numbers pad do not work. ALso using a logitech wireless/laser opt. mouse. I had to download logitech's software ( never had to do this bef

  • How To see Document By Trans Type

    Hi All, In MIRO there are 4 kind of transaction type. invoice, credit memo, subsequent debit and credit. I checked in table RBKP and also tcode MIR6 by document type yet I not able to choose document that created by transaction type credit memo and s