Basic PL/SQL

Is there any way by which i could see the underlying script of a stored procedure?

You can also use
dba_procedures,
all_procedures ,
user_procedures
to have more details about the procedures.Why not go the whole hog and just post this link:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_part.htm#REFRN002

Similar Messages

  • Need Help With Basics of SQL

    Hey I'm trying to get a working understanding of some of the basics behind SQL, I've composed a few questions that I think may help me with this. Anyone that can help me with any of them will greatly help me thanks.
    1. How to create synonym for tables?
    2. How to describe the structure of tables?
    3. How to list the contents of tables?
    4. How to create a table named with the same structure as another table?
    5. How to copy rows with less than a certain criteria in value (e.g. Price<$5.00) into another table?
    6. How to change the data type to e.g. NUMBER(6)?
    7. How to add a new column named with data type e.g. VARCHAR2(10)?
    8. How to change a specific field within a table (e.g. For ORDER_NUMBER 12489, change the C_NUMBER to 315)?
    9. How to delete a specific row from a table?
    10. How to declare a column as the primary key of a table and call it e.g. PK_something?
    11. How to show certain columns when another column is less than a certain criteria in value (e.g. Price<$5.00)?
    12. How to show certain columns with another column having a certain item class e.g. HW or AP?
    13. How to list certain columns when another column e.g. price is between two values?
    14. How to list certain columns when another column e.g. price is negative?
    15. How to use the IN operator to find certain columns (e.g. first and last name of customers who are serviced by a certain ID)
    16. How to find certain columns when one of the columns begins with a particular letter (e.g. A)
    18. How to list the contents of the a table sorted in ascending order of item class and, within each item class, sorted in descending order of e.g. price?
    19. How to do a count of column in a table?
    20. How to sum a column and make rename is something?
    21. How to do a count of a column in a table (without repeats e.g. if a certain number repeats more than once than to only count it once)?
    22. How to use a subquery to find certain fields in columns when the another column’s fields values are greater than e.g. its average price?

    848290 wrote:
    Hey I'm trying to get a working understanding of some of the basics behind SQL, I've composed a few questions that I think may help me with this. Anyone that can help me with any of them will greatly help me thanks.To use the terminology you have in those questions, you must already have a basic understanding of SQL, so you have exposed yourself as not being the author of such questions.
    Please do not ask homework questions without having at least attempted to answer them yourself first and show where you're struggling.

  • Misc Basic PL/SQL Application Design/Programming Questions 101 (101.1)

    ---****** background for all these questions is at bottom of this post:
    Question 1:
    I read a little on the in and out parameters and that IN is "by reference" and OUT and IN-OUT are by value. To me "by reference" means "pointer" as in C programming. So it seems to me that I could call a function with an IN parameter and NOT put it on the right side of an assignment statement. In other words, I'm calling my function
    get_something(IN p_test1 varchar2) return varchar2;
    from SP1 which has a variable named V_TEST1.
    So.... can I do this? (method A):
    get_something(V_TEST1);
    or do I have to do this (method B):
    V_TEST1 := get_something(V_TEST1);
    Also, although this may muddy the thread (we'll see), it seems to me that IN, since its by reference, will always be more efficient. I will have many concurrent users using this program: should this affect my thinking on the above question?
    -- ******* background *******
    So Far:<< I've read and am reading all over the net, read and reading oracle books from oracle (have a full safari account), reading Feurstein's tome, have read the faq's here.
    Situation Bottom Line:<< Have an enormous amount to do in a very little time. Lots riding on this. Any and all pointers will be appreciated. After we get to some undetermined point I can re-do this venture as a pl/sql faq and submit it for posting (y'alls call). Some questions may be hare brained just because I'm freaking out a little bit.
    Situation (Long Version):<< Writing a pl/sql backend to MS Reporting Services front end. Just started doing pl/sql about 2 months ago. Took me forever to find out about ref-cursor as the pipe between oracle and all client applications. I have now created a package. I've been programming for 20 years in many languages, but brand new to pl/sql. However, pl/sql sql has freed me from myriad of limitations in MS RS's. My program is starting to get big (for me -- I do a lot in a little) pks is currently 900 lines with 15 functions so far. Currently SP (pls) is back up to 800 lines. I get stuff working in the sp then turn it into a function and move it to the package.
    What does application do?:<<<< Back End for MS Reporting Services Web front end. It will be a very controlled "ad-hoc" (or the illusion of ad-hoc) web interface. All sql queries are built at run-time and executed via "open ref cusor for -- sql statement -- end;" data returned via OUT ref_cursor. Goal is to have almost 100% of functionality in a package. Calling SP will be minimalist. Reporting Services calls the SP, passes X number of parameters, and gets the ref_cursor back.
    Oracle Version: 10.2 (moving to 11g in the next 3 months).Environment: Huge DW in a massively shared environment. Everything is locked down and requires a formal request. I had to have my authenticated for a couple dbms system packages just to starting simple pl/sql programs.

    Brad Bueche wrote:
    Question 1:
    I read a little on the in and out parameters and that IN is "by reference" and OUT and IN-OUT are by value. To me "by reference" means "pointer" as in C programming. So it seems to me that I could call a function with an IN parameter and NOT put it on the right side of an assignment statement. The IN parameter is not passing by reference. It is passing by value. This means variable/value of the caller used as parameter, is copied to the (pushed) stack of code unit called.
    An OUT parameter means that the value is copied from the called unit's stack to the caller (and the current value of the caller's variable is overwritten).
    To pass by reference, the NOCOPY clause need to be used. Note that is not an explicit compile instruction. The PL/SQL engine could very well decide to pass by value and not reference instead (depending on the data type used).
    Note that the ref cursor data type and the LOB data types are already pointers. In which case these are not passed reference as they are already references.
    The NOCOPY clause only make sense for large varchar2 variables (these can be up to 32KB in PL/SQL) and for collection/array data type variables.
    As for optimising PL/SQL code - there are a number of approaches (and not just passing by reference). Deterministic functions can be defined. PL/SQL code can be written (as pipelined tables) to run in parallel using the default Oracle Parallel Query feature. PL/SQL can be manually parallelised. Context switches to the SQL engine can be minimised using bulk processing. Etc.
    Much of the performance will however come down to 2 basic issues. How well the data structures being processed are designed. How well the code itself is modularised and written.

  • Basic PL/SQL parser usage?

    First off, I have to say that the documentation (what little there is) for the pl/SQL XML parser is absolutely terrible. I've figured out the bulk of it through trial and error, and some examples, but I'm stuck on something very basic. How do I get the actual value from a node?<br>
    How would I get "PROC_CODE_GUID5" from this node? <f>PROC_CODE_GUID_5</f>.<br> I try to use xmldom.getNodeValue(nodename), but it never returns any value.

    Frank,
    I'm sorry you had to go through the pains of figuring it out. I have been working with XML for a year now and have created a great website to help newcomers get started without the pain. The website is www.webspedite.com/oracle. Let me know what you think.
    Regards,
    Jason M Cohen

  • Some basic(perhaps) SQL help please

    TABLE: LOGOS
    ID           VARCHAR2(40) PRIMARY KEY
    TITLE        VARCHAR2(100)
    FILE_NAME    VARCHAR2(100)
    RESOLUTION   NUMBER(3)
    FILE_TYPE    VARCHAR2(5)
    DATA:
    ID       TITLE   FILE_NAME            RESOLUTION   FILE_TYPE
    1001     pic1    horizon_main.jpg     72           jpg
    1002     pic1    chief_diary.jpg      300          jpg
    1003     pic2    no_image.jpg         300          eps
    1004     pic3    publications.jpg     72           jpg
    1005     pic3    chase_car.jpg        300          jpg
    1006     pic4    top_img.jpg          72           jpg
    RESULT SET:
    ID       TITLE   FILE_NAME            RESOLUTION   FILE_TYPE   ID       TITLE   FILE_NAME            RESOLUTION   FILE_TYPE
    1001     pic1    horizon_main.jpg     72           jpg         1002     pic1    chief_diary.jpg      300          jpg
    1003     pic2    no_image.jpg         300          eps
    1004     pic3    publications.jpg     72           jpg         1005     pic3    chase_car.jpg        300          jpg
    1006     pic4    top_img.jpg          72           jpgHopefully you can see what I am trying to do here. Basically where there are multiple rows for a particular TITLE (e.g. "pic1") then they should be returned side by side. The problem I am having is duplicity, i.e. I get 2 rows for "pic1" like this:
    ID       TITLE   FILE_NAME            RESOLUTION   FILE_TYPE   ID       TITLE   FILE_NAME            RESOLUTION   FILE_TYPE
    1001     pic1    horizon_main.jpg     72           jpg         1002     pic1    chief_diary.jpg      300          jpg
    1002     pic1    chief_diary.jpg      300          jpg         1001     pic1    horizon_main.jpg     72           jpgIt looks like it should be simple by my SQL brain isn't back in gear after the festive period.

    Maybe a slight modification, to remove the juxtaposed value from being displayed again:
    test@ORA92>
    test@ORA92> select * from logos;
    ID         TITLE      FILE_NAME            RESOLUTION FILE_
    WU513      pic1       horizon_main.jpg             72 jpg
    AV367      pic1       chief_diary.jpg             300 jpg
    BX615      pic2       no_image.jpg                300 eps
    QI442      pic3       publications.jpg             72 jpg
    FS991      pic3       chase_car.jpg               300 jpg
    KA921      pic4       top_img.jpg                  72 jpg
    6 rows selected.
    test@ORA92>
    test@ORA92> SELECT a.ID AS aid, a.title AS attl, a.file_name AS afn, a.resolution AS ares,
      2         a.file_type aft, b.ID AS bid, b.title AS bttl, b.file_name AS bfn,
      3         b.resolution AS bres, b.file_type bft
      4    FROM logos a, logos b
      5   WHERE a.title = b.title(+) AND a.ROWID < b.ROWID(+)
      6  /
    AID        ATTL       AFN                        ARES AFT   BID        BTTL       BFN                     BRES BFT
    WU513      pic1       horizon_main.jpg             72 jpg   AV367      pic1       chief_diary.jpg          300 jpg
    AV367 pic1 chief_diary.jpg 300 jpg
    BX615      pic2       no_image.jpg                300 eps
    QI442      pic3       publications.jpg             72 jpg   FS991      pic3       chase_car.jpg            300 jpg
    FS991 pic3 chase_car.jpg 300 jpg
    KA921      pic4       top_img.jpg                  72 jpg
    6 rows selected.
    test@ORA92>
    test@ORA92>
    test@ORA92> SELECT aid, attl, afn, ares, aft, bid, bttl, bfn, bres, bft
      2    FROM (SELECT a.ID AS aid, a.title AS attl, a.file_name AS afn,
      3                 a.resolution AS ares, a.file_type aft, b.ID AS bid,
      4                 b.title AS bttl, b.file_name AS bfn, b.resolution AS bres,
      5                 b.file_type bft, LAG (b.ID) OVER (ORDER BY 1) AS prev_id
      6            FROM logos a, logos b
      7           WHERE a.title = b.title(+) AND a.ROWID < b.ROWID(+))
      8   WHERE (prev_id IS NULL OR prev_id <> aid)
      9  /
    AID        ATTL       AFN                        ARES AFT   BID        BTTL       BFN                     BRES BFT
    WU513      pic1       horizon_main.jpg             72 jpg   AV367      pic1       chief_diary.jpg          300 jpg
    BX615      pic2       no_image.jpg                300 eps
    QI442      pic3       publications.jpg             72 jpg   FS991      pic3       chase_car.jpg            300 jpg
    KA921      pic4       top_img.jpg                  72 jpg
    test@ORA92>
    test@ORA92>cheers,
    pratz

  • Basic pl/sql doubt

    Declare
    cursor curname is select * from employees where employee_id in (100,101);
    v_emp curname%rowtype;
    begin
    open curname;--this stage the query is executed and datas are available in Active set which is the area oracle allocated for this cursor
    loop
    fetch curname into v_emp;
    exit when curname%notfound;--first value is retrieved in the above statement and the cursor is pointing to second value in the active set..so this wil result no
    --bt for the next loop here cursor should nt point to anything and this should exit.. Am i ryt? becaz there are totally two values.. tis should exit witout printing..
    -- i mean.. eventhough tis query gives two values second value should not be printed becaz we have given exit before before dbms_ouput statement.. ple help
    --mainly I am getting confused about the functionalities of exit explain please.....
    dbms_output.put_line('name:'||v_emp.first_name);
    end loop;
    close curname;
    end;
    tis is confusing somebody help please?? and gimme the link where can I find docs to clarify these doubts.. explain about for loop for the same please...
    I am starter in PL/SQL please help.....
    Edited by: user12869307 on Apr 19, 2010 2:43 PM

    Hi,
    Please don't post unformatted code.
    Indent line to show the extent of BEGIN, LOOP and similar statements.
    Don't put too much on one line.
    For example:
    Declare
        cursor curname is select  *
                           from    employees
                    where   employee_id     in (100,101);
        v_emp curname%rowtype;
    begin
        open curname;     -- this stage the query is executed and
                        -- datas are available in Active set which is
                   -- the area oracle allocated for this cursor
        loop
            fetch curname into v_emp;
            exit when curname%notfound;     -- first value is retrieved in the above
                                    -- statement and the cursor is pointing to
                             -- second value in the active set..so this wil result no
                             -- bt for the next loop here cursor should nt point to
                             -- anything and this should exit Am i ryt? becaz there
                             -- are totally two values.. tis should exit witout printing wiout
                             -- doing the below print..
            dbms_output.put_line ('name:' || v_emp.first_name);
        end loop;
        close curname;
    end;
    /Type these 6 characters:
    (small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    I'm not sure I understand your comments.  It would help if you posted the contents of your table, and the output you get, and asked a question specifically about those results, such as "Why do the results include ... ?  Isn't the code supposed to ... because of ... in the data?"
    If the query returns 2 rows, then FETCH will work 2 times with %FOUND = true.  Only after the 3rd call to FETCH will %NOTFOUND become true.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Some basic PL/SQL quesions

    Hi,
    I am new to Oracle world and I need some helps:
    I need to run a lengthly ctx_ddl.sync_index procedure in our 10g R2 production environment, and I want to start the procedure at night and kill the session early in the morning next day.
    I am having trouble in writing the PL/SQL procedure to kill the session that is running the sync index:
    Here is my try:
    CREATE OR REPLACE PROCEDURE KILL_SESSION
    AS
    MYSID INTEGER; //SID OF THE SESSION CALLING THIS PROCEDURE
    KILLSID INTEGER; //SID OF THE SESSION THAT IS RUNNING THE SYNC INDEX
    KILLSERIAL INTEGER; //SERIAL# OF THE SESSION THAT IS RUNNING THE SYNC INDEX
    BEGIN
    SELECT DISTINCT(SID) INTO MYSID FROM MY V$MYSTAT;
    ^ ^^^ V$MYSTAT COMPILATION ERROR - NO SUCH TABLE OR VIEW
    SELECT SID INTO KILLSID, SERIAL# INTO KILLSERIAL FROM V$SESSION WHERE SID NOT IN (MYSID) AND OSUSER='SYS_ADMINISTRATOR';
    ^ ^^^ V$SESSION COMPILATION ERROR - NO SUCH TABLE OR VIEW
    ALTER SYSTEM KILL SESSION 'KILLSID, KILLSERIAL';
    ^^^^^^^ CAN I USE VARIABLE NAME INSIDE A SINGLE QUOTE??????
    END KILL_SESSION;
    Any help is appreciated !

    Hi,
    Welcome to the forum!
    When you post code on this site, make sure it is formatted, and type these 6 characters
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    When you post error messages, cut and paste the entire message. Somethimes, the message number and the line/cloumn number are helpful.
    Vg is right: there's something fundamentally flawed with a job that you have to kill.
    Can you sub-divide the job, and do a different part each night?
    A KILL procedure is handy in any case. As Vg said, you (the procedure owner) have to have privileges granted directly to you. Roles don't count inside stored procedures, so merely having a role that lets you query the data dictionary views is not enough.
    Also, you may need privileges granted on the actual V_$ views, rather than the V$ synonyms. (That is, V$MYSTAT, without an underscore, is just a public synonym for the view SYS.V_$MYSTAT, with an underscore in its name. You want to GRANT SELECT ON V_$MYSTAT to proc_owner;)

  • Basic PL/SQL Question about running context

    We are trying to create some generalized tools with PL/SQL procedures that would be used by a number of different Oracle Users/Schema. The idea was to store them in an administrative schema (call it ADMIN), create public synonyms for them, and grant execute to public. Then we could run them from the user schema (call it USER) to do the work.
    It was my assumption, that while the procedures were stored in ADMIN, when they were run by USER they would run in the USER context. EG, a table (call it MYTABLE) that was referenced in the procedure without a schema reference (SELECT * FROM MYTABLE) would expect to find MYTABLE in the context of the schema which called the procedure. In other words, call the procedure from USER, I expected the procedure to look for MYTABLE in USER. However, we are getting errors that indicate that even though the procedure is called from USER, it is looking for the table in ADMIN (the procedures creation context), no in USER (the running context).
    QUESTIONS: How is PL/SQL supposed to operate in this situation? Are there any options/parameters that can be set so the procedure will use the runtime context for table lookup, or do we have to write dynamic SQL which will fully qualify the table with the owner schema?
    Thanks for your help
    John Conroy

    Hy,
    from the manual:
    The AUTHID clause is allowed only in the header of a stand-alone subprogram, a
    package spec, or an object type spec. The header syntax is
    -- stand-alone function
    CREATE [OR REPLACE] FUNCTION [schema_name.]function_name
    [(parameter_list)] RETURN datatype
    [AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
    -- stand-alone procedure
    CREATE [OR REPLACE] PROCEDURE [schema_name.]procedure_name
    [(parameter_list)]
    [AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
    -- package spec
    CREATE [OR REPLACE] PACKAGE [schema_name.]package_name
    [AUTHID {CURRENT_USER | DEFINER}] {IS | AS}
    -- object type spec
    CREATE [OR REPLACE] TYPE [schema_name.]object_type_name
    [AUTHID {CURRENT_USER | DEFINER}] {IS | AS} OBJECT
    where DEFINER is the default option. In a package or object type, the AUTHID
    clause applies to all routines.
    Note: Most supplied PL/SQL packages (such as DBMS_LOB, DBMS_PIPE, DBMS_
    ROWID, DBMS_SQL, and UTL_REF) are invoker-rights packages.

  • Basic PL/SQL help - student

    I'm a graduate student just learning to grasp PL/SQL. Does anyone have any links to suggested sample PL/SQL programs? I've been tasked to do some Oracle spatial intersection queries. I have most of the actual commands down but could use some help tieing them around the PL/SQL language.
    Many thanks.

    Best place is the documentation ...
    For pl/sql :
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
    All the best for your baby-steps in pl/sql.

  • Azure SQL DB Basic Edition Preview: "Session Request Limit Reached" Stuck and Doesn't Clear - SQL DB Bug?

    Edit: I have updated the below to reflect that it took four hours for the database to unblock. This looks like a bug to me. SQL Server seemed to believe there were 30 running sessions with open requests nearly four hours after the client
    side connections were terminated (and thus in the process blocking SQL Server from accepting new connections).
    Problem
    I am running a preview "Basic" edition SQL DB and have hit a problem with Azure SQL DB blocking database access for an extended time period.
    I was running a test, which was running normally for several hours (loading small batches of data), then suddenly lots of connection timeouts (error type 1 below).  My workload was constant over the whole test - but if the server was suddenly under
    pressure, I accept this might happen - no problem with me so far. 
    Upon retrying, the errors then changed to request limit exceeded (error type 2 below).
    I am surprised I hit the limit in the first place, since the test code closes the SQL Connection on a timeout error and reopens.  (In C#, the code is wrapped in a using{} to ensure prompt connection closure).  Still, perhaps the amount of concurrent
    work on the server did momentarily hit this limit.  Perhaps fair enough on this point too.
    BUT:  Surprisingly, nearly four hours later, I was still unable to connect to the database - it was refusing new connections.  Either from my worker role or from the Azure Management Website.  The Management Window, upon trying to connect,
    failed with exactly the same text as error type 2 below.
    Further, sys.resource_stats (from the master db, which is still accessible) is reporting that there were 30 active sessions, 30 active workers (see extract below) for four afters after the test ended.  Even though during this time period the Azure Cloud
    Service that was generating the SQL requests was stopped too (so the client side of any open requests were long since dead).  Also,
    the CPU, Log Write and Phys Data Read columns in sys.resource_stats are all showing 0 for the four hours after the test ended.  This to me suggests a fault condition that isn't clearing server-side.
    Why was the database unavailable for four hours?  Why did Azure believe that there were 30 open requests? (each request was an insert of 1000 rows, each of 400 bytes, i.e. pretty small so no way should they take this long to process).
    PS.  To be clear, none of the above is a complaint.  I completely accept that the service in in preview, different SLA, etc.  I am writing to a) check that I haven't missed anything and b) if this is a bug, to report it.
    Appendix
    Error Type 1
    System.Data.SqlClient.SqlException:  Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    Error Type 2
    SqlException: Resource ID : 1. The request limit for the database is 30 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance.
    Metrics
    The following is an extract from sys.resource_stats for the affected time period.  SQL Server seems to wrongly believe/report that there are 30 pending requests between 6:20 and 10:45.  It thus blocks any further requests during this time.  There
    were NO client connections during this time, either new or previously opened.
    start time
    end time
    sku
    session count
    worker count
    avg cpu
    avg phys data read
    avg log write
    07 Jun 11:15
    07 Jun 11:20
    Basic
      0
    0
    0
    0
    0
    07 Jun 10:50
    07 Jun 10:55
    Basic
      0
    0
    0.5
    0
    0
    07 Jun 10:40
    07 Jun 10:45
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 09:35
    07 Jun 09:40
    Basic
      30
    30
    0.02
    0
    0
    07 Jun 09:20
    07 Jun 09:25
    Basic
      30
    30
    0
    0
    0
    07 Jun 09:10
    07 Jun 09:15
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 08:40
    07 Jun 08:45
    Basic
      30
    30
    0
    0
    0
    07 Jun 08:20
    07 Jun 08:25
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 08:10
    07 Jun 08:15
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 07:55
    07 Jun 08:00
    Basic
      30
    30
    0
    0
    0
    07 Jun 07:25
    07 Jun 07:30
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 07:15
    07 Jun 07:20
    Basic
      30
    30
    0
    0
    0
    07 Jun 07:05
    07 Jun 07:10
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 06:55
    07 Jun 07:00
    Basic
      30
    30
    0
    0
    0
    07 Jun 06:45
    07 Jun 06:50
    Basic
      30
    30
    0.15
    0
    0
    07 Jun 06:20
    07 Jun 06:25
    Basic
      30
    30
    0.01
    0
    0
    07 Jun 06:15
    07 Jun 06:20
    Basic
      30
    30
    0.22
    0
    0
    07 Jun 06:10
    07 Jun 06:15
    Basic
      26
    26
    0.13
    0
    0
    07 Jun 06:05
    07 Jun 06:10
    Basic
      20
    20
    0.14
    0
    0
    07 Jun 06:00
    07 Jun 06:05
    Basic
      13
    13
    0.12
    0
    0
    07 Jun 05:55
    07 Jun 06:00
    Basic
      7
    7
    0.12
    0
    0
    07 Jun 05:50
    07 Jun 05:55
    Basic
      1
    1
    54.04
    0
    93.47
    07 Jun 05:45
    07 Jun 05:50
    Basic
      1
    0
    1.4
    0
    2.06
    07 Jun 05:40
    07 Jun 05:45
    Basic
      1
    1
    55.17
    0
    88.35
    07 Jun 05:35
    07 Jun 05:40
    Basic
      1
    0
    52.05
    0
    90.01
    07 Jun 05:30
    07 Jun 05:35
    Basic
      1
    1
    54.95
    0
    90.1
    07 Jun 05:25
    07 Jun 05:30
    Basic
      1
    1
    56.38
    0
    89.82
    07 Jun 05:20
    07 Jun 05:25
    Basic
      1
    0
    52.15
    0
    90.19
    07 Jun 05:15
    07 Jun 05:20
    Basic
      1
    0
    52.76
    0
    87.86

    Hi Chris,
    Thanks for testing the new Basic edition and for reporting this issue. Without some more investigation it is hard to tell what exactly has happened here.
    To be able to take a closer look I would need some more information from you. Could you please reach out to me via email (firstname DOT lastname AT microsoft DOT com)? I will then let you know what additional information we and will kick-off
    the investigation.
    Thanks,
    Jan

  • Stored Procedure in SQL Server 2005

    Hi Friends,
    when i execute the stored procedure , i can get below error.
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'XI_SP_KANLOGDATA_KLOGDATA' (structure 'Statement'): java.sql.SQLException: ERROR: Invalid XML document format for stored procedure: 'type="<SQL-type>"' attribute is missing for element 'table' (Setting a SQL-type (e.g. INTEGER, CHAR, DATE etc.) is mandatory !)
    My XML Message below format:
    <Statment>
    --<dbStmt action="EXECUTE">
      ---<table>storedprocedurename</table>
      ---<EMPNO isInput="true" type="char">0001</EMPNO>
      ---<EMPNAME isInput= "true type="char">Sateesh</EMPNAME>
      ---<ADDRESS isInput="true" type="char">Delhi</ADDRESS>
    --<dbStmt action="EXECUTE">
      ---<table>storedprocedurename</table>
      ---<EMPNO isInput="true" type="char">0002</EMPNO>
      ---<EMPNAME isInput= "true type="char">Sateesh1</EMPNAME>
      ---<ADDRESS isInput="true" type="char">Bangalore</ADDRESS>
    --<dbStmt action="EXECUTE">
      ---<table>storedprocedurename</table>
      ---<EMPNO isInput="true" type="char">0003</EMPNO>
      ---<EMPNAME isInput= "true type="char">Sateesh3</EMPNAME>
      ---<ADDRESS isInput="true" type="char">Hyderabad</ADDRESS>
    </Statement>

    Hi abishek,
    My scenario is basically JDBC(SQL Server)XIJDBC(ORACLE)(Synchronous)
    XI pick the date field from JDBC Sender and goes to ORACLE Database and selects records based upon the condition, and response back and put this data into JDBC(SQL Server),
    My process successfully upto receive the response from ORACLE system and after response mapping also successful.after that  response message is insert into SQL Server.
    In SQL server we have two tables,one DATA table and LOG table, If insert the data into DATA table successfully LOG table updated with DATE and STATUS field not successfully insert LOG table update with DATE and Error status field.
    So I impleted "stored procedure" in SQL side.
    Any way i solved that error.
    I am using below XML structure with out table field,i followed below blog.
    http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9618. [original link is broken] [original link is broken] [original link is broken]
    My stored procedure name is: XI_SP_KDATA_KLOGDATA
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_DB_SELECT_REQUEST_response xmlns:ns0="urn:pg-siemens-com:POCA0013:sample1">
    - <Statement_response>
    - <XI_SP_KDATA_KLOGDATA action="EXECUTE">
      <EMPNO type="CHAR">901064</EMPNO>
      <EMPNAME type="CHAR">Sateesh</EMPNAME>
      <ADDRESS type="CHAR">Hyderabad</ADDRESS>
      </XI_SP_KDATA_KLOGDATA>
    - <XI_SP_KDATA_KLOGDATA action="EXECUTE">
      <EMPNO type="CHAR">901000</EMPNO>
      <EMPNAME type="CHAR">Ashish</EMPNAME>
      <ADDRESS type="CHAR">Bangalore</ADDRESS>
      </XI_SP_KDATA_KLOGDATA>
      </Statement_response>
      </ns0:MT_DB_SELECT_REQUEST_response>
    But again i faced one error in Communication channel
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'XI_SP_KDATA_KLOGDATA' (structure 'Statement_response'): com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function XI_SP_KANLOGDATA_KLOGDATA has too many arguments specified.
    My doubt is above error is Stored procedure error or XML Structure error?
    Don't hesitate to clarify me.
    Thank you.
    sateesh
    Edited by: sateesh kumar .N on Mar 4, 2010 11:58 AM
    Edited by: sateesh kumar .N on Mar 4, 2010 11:59 AM
    Edited by: sateesh kumar .N on Mar 4, 2010 12:00 PM

  • Execute a procedure with a list of array in sql server 2008

    HI all,
    I have a procedure which has a list of values passed as an array . How can i execute my procedure with array list? how to implement this?Please help me.
    Thanks in advance
    Deepa

    Hi Deepa,
    basically Microsoft SQL Server does not support arrays as data types for procedures. What you can do is creating a type which represents a table definition. This type can than be used in a procedure as the following demo will show:
    The first script creates the environment which will be used for the execution
    -- 1. create the table as a type in the database
    CREATE TYPE OrderItems AS TABLE
    ItemId int PRIMARY KEY CLUSTERED
    GO
    -- 2. demo table for demonstration of results
    CREATE TABLE dbo.CustomerOrders
    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY CLUSTERED,
    CustomerId int NOT NULL,
    ItemId int
    GO
    -- 3. Insert a few records in demo table
    INSERT INTO dbo.CustomerOrders
    (CustomerId, ItemId)
    VALUES
    (1, 1),
    (2, 1),
    (3, 3),
    (1, 3);
    GO
    -- 4. Create the procedure which accepts the table variable
    CREATE PROC dbo.OrderedItemsList
    @Orders AS OrderItems READONLY
    AS
    SET NOCOUNT ON;
    SELECT o.*
    FROM dbo.CustomerOrders AS O INNER JOIN @Orders AS T_O
    ON (o.ItemId = T_O.ItemId);
    SET NOCOUNT OFF;
    GO
    The above script creates the table data type and a demo table with a few demo data. The procedure will accept the table data type as parameter. Keep in mind that table variable parameters have to be READONLY as parameter for procedures!
    The second script demonstrates the usage of the above scenario
    When the environment has been created the usage is a very simple one as you can see from the next script...
    -- 1. Fill the variable table with item ids
    DECLARE @o AS OrderItems;
    INSERT INTO @o (ItemId)
    VALUES
    (1), (3);
    -- 2. Get the list of customers who bought these items
    EXEC dbo.OrderedItemsList @Orders = @o;
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

  • How to acheive looping in SQL

    Hi Have below requirement,
    a.     Take the first 7 digits of a Number string and multiply the 1st digit by 8, the 2nd digit by 7 .....etc..... the 6th digit by 3 and the 7th digit by 2;
    b.     Sum up the values of the above seven multiplication;
    c.     Subtract 97 from the value at b. above until you have a negative number;
    d.     Digits 8 and 9 of the number, the “check digits”, will correspond with the absolute value of the negative number determined at c. above.
    Example:
    Passing input as number specific one, 'SK391313073'
    now first 7 digits are 3913130 and perform Sum like this (3*8)+(9*7)+(1*6)+(3*5)+(1*4)+(3*3)+(0*2) [Sum wil be 121]
    I have achieved till above through sql,
    Now the sum I should subtract with 97 till it get equal with 8th and 9th digit (here I should loop)
    in this case
    121-97=24 so this is not equal to 73 (last two digits of input)
    so now I need to again perform 24-97 which is -73 and abs(-73)=73 so I need to stop here,
    All your help is appreciated,,

    Here's a basic example of a FOR loop type structure in SQL - the pseudo column level serves as the loop variable.
    You can use the WITH clause as "programming blocks" to calculate something specific and re-use the output of that in another "programming block".
    The following example demonstrates the basic approach:
    SQL> var n varchar2(20)
    SQL> exec :n := 'SK391313073';
    PL/SQL procedure successfully completed.
    // parse the input string as per requirements
    SQL> with number_parse as (
      2          select
      3                  level as i,
      4                  substr(:n,level,1) as ch
      5          from    dual
      6          connect by level <= length(:n)
      7  )
      8  select
      9          *
    10  from       number_parse
    11  /
             I CH
             1 S
             2 K
             3 3
             4 9
             5 1
             6 3
             7 1
             8 3
             9 0
            10 7
            11 3
    11 rows selected.
    // tad more complex: using this parsing output, determine the 1st 7 digits
    SQL> with number_parse as (
      2          select
      3                  level as i,
      4                  substr(:n,level,1) as ch
      5          from    dual
      6          connect by level <= length(:n)
      7  )
      8  select i,ch from (
      9          select
    10                  rownum as rno,
    11                  n.*
    12          from    number_parse n
    13          where   ch in ('0','1','2','3','4','5','6','7','8','9')
    14  )
    15  where      rno between 1 and 7
    16  /
             I CH
             3 3
             4 9
             5 1
             6 3
             7 1
             8 3
             9 0
    7 rows selected.
    // now add the calculation as required
    SQL> with number_parse as (
      2          select
      3                  level as i,
      4                  substr(:n,level,1) as ch
      5          from    dual
      6          connect by level <= length(:n)
      7  ),
      8  first_7 as(
      9          select i,ch from (
    10                  select
    11                          rownum as rno,
    12                          n.*
    13                  from    number_parse n
    14                  where   ch in ('0','1','2','3','4','5','6','7','8','9')
    15          )
    16          where   rno between 1 and 7
    17          order by i desc
    18  )
    19  select
    20          ch,
    21          ch||' * '||to_char(rownum+1)    as calc,
    22          to_number(ch)*(rownum+1)        as result
    23  from       first_7
    24  order by i
    25  /
    CH  CALC           RESULT
    3   3 * 8              24
    9   9 * 7              63
    1   1 * 6               6
    3   3 * 5              15
    1   1 * 4               4
    3   3 * 3               9
    0   0 * 2               0
    7 rows selected.
    SQL> So SQL is capable of a FOR loop and similar type of (basic) processing that one can do in PL/SQL. However, the SQL language is not Turing Complete, and things can get messy with the above approach, in comparison with doing it in PL/SQL instead.

  • SQL: does if/else work as a query or only in a SP?

    I'd like to insert a record if it doesn't exist or UPDATE it
    if it does. I'm
    doing this through a query via my app:
    IF EXISTS (SELECT siteID
    FROM weSiteMenusXML
    WHERE siteID = 1)
    INSERT
    INTO weSiteMenusXML(siteID)
    VALUES (1) ELSE
    UPDATE weSiteMenusXML
    SET xml = 'boo'
    WHERE siteID = 1
    Enterprise manager seems to be fine with this syntax, but it
    doesn't
    actually do anything. Is SQL if/else logic only applicable to
    stored
    procedures or is there just something goofy with my syntax?
    -Darrel

    Hi Darrel,
    If your example below is the same as your actual code in your
    app then it
    won't do anything. You are basically telling SQL to look if a
    record exists
    with a siteID of 1 and if there is such a record then insert
    a record with
    the identical value. If that record doesn't exist then you
    are instructing
    it to do an update on this non-existent row (siteID of 1).
    Surely your SQL
    should look something like this:
    IF EXISTS (SELECT siteID
    FROM weSiteMenusXML
    WHERE siteID = 1)
    UPDATE weSiteMenusXML
    SET xml = 'boo'
    WHERE siteID = 1
    ELSE
    INSERT
    INTO weSiteMenusXML(siteID)
    VALUES (1)
    Pat.
    "darrel" <[email protected]> wrote in message
    news:e55h0u$jsh$[email protected]..
    > I'd like to insert a record if it doesn't exist or
    UPDATE it if it does.
    > I'm doing this through a query via my app:
    >
    > IF EXISTS (SELECT siteID
    > FROM weSiteMenusXML
    > WHERE siteID = 1)
    > INSERT
    > INTO weSiteMenusXML(siteID)
    > VALUES (1) ELSE
    > UPDATE weSiteMenusXML
    > SET xml = 'boo'
    > WHERE siteID = 1
    >
    > Enterprise manager seems to be fine with this syntax,
    but it doesn't
    > actually do anything. Is SQL if/else logic only
    applicable to stored
    > procedures or is there just something goofy with my
    syntax?
    >
    > -Darrel
    >

  • PL/SQL cursors vs. SQL*plus Select statement

    Hi folks, hope you're doing well,
    Here is a question that kept me wondering:
    Why would I use cursors when i can achieve the same thing with a SQL+ Select statement which is much easier to formulate than a cursor (e.g. you need no declaration, loops etc)?.
    Thanks so much,
    -a

    There is no such thing as a SQL*Plus SELECT statement. The SELECT command is part of the SQL Language - not part of the SQL*Plus (very limited small vocabulary) macro language.
    All SQL SELECTs (from client languages) winds up in the SQL Engine as SQL cursors. A SQL Cursor is basically the:
    - SQL source code
    - SQL "compiled" code (instructions on how to fetch the rows)
    On the client side, client cursors (not to be confused with SQL cursors) are used. A client cursor is created in the client language when it makes SQL calls via the database client driver (called the OCI/Oracle Call Interface for Oracle clients).
    Typically this is what a client does. It makes a connection to the database and gets a database handler in return. The database handler is the "communication channel" from the client to the db. In Oracle, the database handler in the client refers to the Oracle session (for that client) on db server.
    A SQL statement (source code) is used by the client. This can be a SELECT statement you type in at the SQL*Plus command line. It can be a SELECT statement for the PL/SQL cursor command in a stored procedure.
    The client creates a SQL handle for this SQL statement, by calling the Oracle client driver. Note that this SQL handle is a client handle - a client cursor for that SQL statement.
    E.g.
    a) sqlHandle = CreateSQL( databaseHandle, 'SELECT ... FROM ...')
    b) sqlHandle.Parse
    c) sqlHandle.Execute
    After the SQL handle (client cursor) has been executed, the client can fetch rows from it.
    This is what SQL*Plus does automatically for you, without you having to write the code to do it. SQL*Plus CONNECT command create a database connection handle. You enter a SELECT statement and SQL*Plus creates a SQL handle (client cursor), executes it, fetches from it, displays the rows, and closes the SQL handle when done.
    The same applies to PL/SQL. You can use a SELECT statement just like that in PL/SQL. E.g.
    declare
      i integer;
    begin
      select count(*) into i from emp where deptid = 123;
    end;This is called an implicit cursor. PL/SQL creates (just like SQL*Plus) an implicit client cursor. It creates and disposes of that client SQL handle for you - you do not need to do it.
    Or, you can create an explicit cursor. E.g. declare
      cursor c is select count(*) from emp where deptid = 123;
      i integer;
    begin
      open c;
      fetch c into i;
      close c;
    end;The question as to when to use implicit (client) cursors versus explicit (client) cursors depends on your requirements. Do you need to cycle through the results of the SQL? Etc.
    And keep in mind that in either case, the SQL Engine creates a SQL cursor anyway on its side.

Maybe you are looking for

  • Can I change my iCloud email to apple ID email?

    I changed my apple ID to a new email address. I cannot figure out how to change my iCloud email to new email as well.

  • Issue Tracker app - how to make one page public

    Hi all, We have installed and made a few tweaks to the Issue Tracker demo app, and are finding it very useful! We have just a handful of users that have logins for the application, and it is working well for them. We would like to make a modification

  • Add photo to existing catalog

    I'm sure this has been asked a thousand times, and if you can just link me to the answer, I would appreciate it. I am using LR3. How can I import additional photos to an existing gallery of images, or can't it be done? I want to shoot a football game

  • Unable to delete anything on page/form

    Hi, I seem to be having a problem with deleting objects from my form in application developer mode and in multi row deletes in form mode. I am able to add and amend objects such as buttons to the form etc but when I try and delete, nothing happens. I

  • Web app path syntax

    What is the syntax to get the path of a current web app in Java? So that no matter where my webapp is located it will generate the location and I can put images or files that I generate into this location.