SQL Starter

1.How to connect to different databases from sql???
2.How to view list of different databases through sql???
3.How to retrive password if you forget of sql???
4.How to create tablespace ???
5.How to view the list of Users of a specific database???
6.How to know Users password information???
7.How to change from one user to another user with out exiting from the sql???
kindly advice
Regards.

Hi,
Welcome to the forum!
user10624123 wrote:
1.How to connect to different databases from sql???
2.How to view list of different databases through sql???Look up "database links"
4.How to create tablespace ???"CREATE TABLESPACE" command.
3.How to retrive password if you forget of sql???
5.How to view the list of Users of a specific database???
6.How to know Users password information???All users and their encypted passwords are in the view dba_users. There's no way to get unencrypted passwords.
7.How to change from one user to another user with out exiting from the sql???Depends on what "the sql" means.
The SQL*Plus command CONNECT changes user and/or database, without exiting from SQL*Plus.

Similar Messages

  • PLS-00201 when executing insexcpr.sql starter

    Receiving a PLS-00201 on wwutl_htp.scriptclose when executing @insexcpr.sql with the suggested schema in the May PDK of starter. Followed the prior instructions. Also tried granting execute on wwutl_htp to starter.

    Thanks Maxim & Rakesh, that worked.
    It does look like a bug. The return on it's own works with other functions e.g. ASCII etc. but not ORA_HASH.
    The select from dual version is painfully slow (e.g. 25 x times) though so I think I'll use dbms_utility.get_hash_value instead for now. I was planning to use that version in 9i anyway as my app still needs to run on 9i - but I was trying to get the ORA_HASH working for 10g as it is incredibly fast.
    Will definitely log it though.

  • Oracle 8i SQL+ Start up...

    Recently, I downloaded 8i on Win98 platform. It is a "trial" version, but I am unable to run anything as it asks for a user name, password and host string. I tried using the following user name and passwords but to NO SUCCESS. I have given up hope trying to find a simple solution. Can you please help?
    User Name Password
    scott tiger
    system manager
    sys change_on_install
    internal oracle
    demo demo
    system null
    PLEASE HELP!!!!!

    You will have to be a bit more specific about the error messages you get. Did you start the database and listener?

  • SQL 2005 Express will not start

    Service just would not start after a reboot I have approximately 30 clients this has happened to basically out of the blue and they started happening approximately 6/17/2014. The SQL log and event log errrors are below. Uninstall reinstall only fails, switching
    to local service account throws WMI Provider Error, Can't find object or property" [0x80092004]. The common issue seems to be a malware infection of Search Protect. Please advise before this gets worse. Thank you.
    SQL 2005 wont start error logs
    FallBack certificate initialization failed with error code: 1.  17190
    TDSSNIClient initialization failed with error 0x80092004, status code 0x80.  17182
    TDSSNIClient initialization failed with error 0x80092004, status code 0x1.  17182
    Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.  17826
    SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.  17120
    The SQL Server (VSDOTNET) service terminated with service-specific error %%-2146885628.  7024
    FallBack certificate initialization failed with error code: 1.  17190
    INFO-Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.  26017
    Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.  17826
    SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems. 17120
    WMI Provider Error
    "Can't find object or property" [0x80092004]
    SQL Start up log
    2014-06-26 09:18:54.83 Server      Microsoft SQL Server 2005 - 9.00.5000.00 (Intel X86)
        Dec 10 2010 10:56:29
        Copyright (c) 1988-2005 Microsoft Corporation
        Express Edition on Windows NT 6.1 (Build 7601: Service Pack 1)
    2014-06-26 09:18:54.83 Server      (c) 2005 Microsoft Corporation.
    2014-06-26 09:18:54.83 Server      All rights reserved.
    2014-06-26 09:18:54.83 Server      Server process ID is 2716.
    2014-06-26 09:18:54.83 Server      Authentication mode is MIXED.
    2014-06-26 09:18:54.83 Server      Logging SQL Server messages in file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
    2014-06-26 09:18:54.83 Server      This instance of SQL Server last reported using a process ID of 4936 at 6/26/2014 9:13:53 AM (local) 6/26/2014 2:13:53 PM (UTC). This is an informational message only; no user action is required.
    2014-06-26 09:18:54.83 Server      Registry startup parameters:
    2014-06-26 09:18:54.83 Server           -d c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
    2014-06-26 09:18:54.83 Server           -e c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
    2014-06-26 09:18:54.83 Server           -l c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
    2014-06-26 09:18:54.84 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
    2014-06-26 09:18:54.84 Server      Detected 2 CPUs. This is an informational message; no user action is required.
    2014-06-26 09:18:54.94 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
    2014-06-26 09:18:54.95 Server      Database mirroring has been enabled on this instance of SQL Server.
    2014-06-26 09:18:54.96 spid4s      Starting up database 'master'.
    2014-06-26 09:18:55.11 spid4s      SQL Trace ID 1 was started by login "sa".
    2014-06-26 09:18:55.13 spid4s      Starting up database 'mssqlsystemresource'.
    2014-06-26 09:18:55.15 spid4s      The resource database build version is 9.00.5000. This is an informational message only. No user action is required.
    2014-06-26 09:18:55.32 Server      Error: 17190, Severity: 16, State: 1.
    2014-06-26 09:18:55.32 Server      FallBack certificate initialization failed with error code: 1.
    2014-06-26 09:18:55.32 spid4s      Server name is '2UA1371VFY\VSDOTNET'. This is an informational message only. No user action is required.
    2014-06-26 09:18:55.32 spid8s      Starting up database 'model'.
    2014-06-26 09:18:55.32 Server      Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.
    2014-06-26 09:18:55.32 spid4s      Starting up database 'msdb'.
    2014-06-26 09:18:55.32 Server      Error: 17182, Severity: 16, State: 1.
    2014-06-26 09:18:55.32 Server      TDSSNIClient initialization failed with error 0x80092004, status code 0x80.
    2014-06-26 09:18:55.32 Server      Error: 17182, Severity: 16, State: 1.
    2014-06-26 09:18:55.32 Server      TDSSNIClient initialization failed with error 0x80092004, status code 0x1.
    2014-06-26 09:18:55.32 Server      Error: 17826, Severity: 18, State: 3.
    2014-06-26 09:18:55.32 Server      Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
    2014-06-26 09:18:55.33 Server      Error: 17120, Severity: 16, State: 1.
    2014-06-26 09:18:55.33 Server      SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.
    James Ball

    This is what I found by someone else;
    I know it's probably too late to help with the original poster, but we had this same issue and nothing we tried resolved the problem. Finally, we opened a technical incident with Microsoft and this is the solution that we were provided:
    Take backup of below registry key.
    HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid This key should ideally have the GUID of the machine without curly braces, so {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} becomes xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    Then delete the braces.
    Try to reboot and start the SQL service . If service don’t start then Uninstall and reinstall SQL.
    The above solution worked on two separate machines exhibiting this problem.
    Monday, June 30, 2014 3:03 PM
    jawg
    (Partner)
    10 Point
    James Ball

  • SQL Service with Domain Logon fails to Auto Start but starts Manually

    I have set the SQL Service Logon to a Domain account. SQL Starts manually just fine, but it fails to start on reboot.
    I see these four errors in the Windows System Log:
    Event 1014 (Warning), DNS Client Events:
    Name resolution for the name .... timed out after none of the configured DNS servers responded.
    Event 5719, NETLOGON:
    This computer was not able to set up a secure session with a domain controller in domain ... due to the following:
    There are currently no logon servers available to service the logon request.
    This may lead to authentication problems. Make sure that this computer is connected to the network. If the problem persists, please contact your domain administrator. 
    Event 1055, GroupPolicy:
    The processing of Group Policy failed. Windows could not resolve the computer name. This could be caused by one of more of the following:
    a) Name Resolution failure on the current domain controller.
    b) Active Directory Replication Latency (an account created on another domain controller has not replicated to the current domain controller).
    Finally: Event 7000, Service Control Manager:
    The SQL Server service failed to start due to the following error:
    The account name is invalid or does not exist, or the password is invalid for the account name specified.
    Apparently there is a delay between NETLOGON starting and "being aware" of the Domain. Apparently it still is not resolved by the time the SQL Service tries to start.  However it is resolved by the time the user logs in, so SQL Service successfully
    starts manually.
    For various reasons I cannot make the SQL Service DelayedAuto. Is there any way to configure NETLOGON Service or DNS Client to not return from the Startup process untl the DNS is resolved?

    A moderator can move it. I have no idea whether you can move it on your own. You can only delete your own post.
    I would suggest that you repost manually to the Windows Server forum, so that you can change the title to something which fits better there. Maybe the text can also benefit from a review. Your original problem was that SQL Server does not start directly,
    but you have already found out that you real issue is the DNS thing.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Creating PL/SQL function in SQL plus which will display desired output

    Hello PL/SQL experts,
    I am not skilled on PL/SQL so want you help for one of the PL/SQL requirement.
    Requirement: We have a database purge jobs which deletes the records from our application database on daily basis. Our Client wants a verification PL/SQL to be created which they will run pre and post the purge job to identify the number of records deleted/processed by purge job. It should do a SELECT operation and find out the number of records in table based on the where clause and give the output to the user.
    The result of PL/SQL should be something like this (considering the PL/SQL is processing multiple select statements):
    ****Verification SQL Start*****
    30 records from table S_SRV_REQUEST selected
    45 records from table S_SRV_REQUEST_X selected
    15 records from table S_SRV_REQUEST_XM selected
    *****Verification SQL complete*****
    For this I am thinking of a simple PL/SQL which will diplay the count of records from each table but I am not sure how to display the count on screen as an output. Can I request PL/SQL experts to put some light on this?
    Regards
    Sumit

    PL/SQL is a server side process running on your database server.  It is not connected to a display or a keyboard, so cannot output any results from within the code itself.
    What you need is a client application that the user can run which will query the database, or call procedure(s) to get results and then the client application will display those results appropriately.
    One of the simplest client tools you can use to build such a user-friendly application is Oracle Application Express (APEX).
    Bear in mind that if you're going to 'identify' record for deletion prior to actually deleting them, then you may also have a need to store the keys of those identified records somewhere so that only those records are deleted.  Consider the situation where the user requests the information and the application queries the records to say there are 30 records from S_SRV_REQUEST with the correct criteria to be deleted.  By the time the user confirms they are happy and want the records deleted, some other record(s) may have been updated and also meet the criteria, so just doing a delete based on the criteria itself could result in more than 30 records being deleted.  However if you've identified the records and marked them in some way for deletion or stored the keys of those records on a queue somewhere to indicate the ones to be deleted, then your actual deletion process can just deal with those records and ignore any that have met the criteria since that time.  Of course that depends on your individual requirements, but it's something to bear in mind.

  • Can some one please tell me what is the problem in the below pl/sql block

    Hi, I have problem with the following pl/sql block, I need this with bulk operation.
    -- Assume the following scenario, we are validating dept (master) and emp(child) which are my temporary tables and updating the status back to
    -- dept ( for all the validation errors, even if we have any validation at child  it has to update the header record with error message),
    -- upon successful validation insert the data into dept3, and emp3 interms of batches
    -- I have give the sample example with dept and emp, but i have around 10 million records which has around 30-40 validations,
    -- I would like to process them in terms of batches using bulk collection as this would do fast processing
    -- Can some one please tell me how to insert them in terms of bulk with every set of 1000 records in each batch in this example,for every set of 1000 records
    -- i need update batch id with unique number in dept table
    -- with current data i can have 50 batches , I need to pass, deptno as parameter to my emp cursor. 
    -- can some one please tell me how to make this validation and insertion more efficient. so that while inserting the data for every batch it should insert batch id
    -- Tried with LIMIT clause as well but not working
    -- I am correcting the code as per your comments Request you to please suggest me so that I can correct , I am new to PL/sql, started learning now.
    step - 1:
    CREATE TABLE DEPT
           (DEPTNO NUMBER(6) primary key,
            DNAME VARCHAR2(25),
            LOC VARCHAR2(23),
            batch_id number );
    INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK', null);
    INSERT INTO DEPT VALUES (20, 'RESEARCH',   'DALLAS', null);
    INSERT INTO DEPT VALUES (30, 'SALES',      'CHICAGO', null);
    INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON', null);
    step - 2:
    declare
    begin
    for i in 1..50000 loop
    insert into dept values(40+i, 'OPERATIONS'||i,'BOSTON'||i, null);
    end loop;
    commit;
    exception
    when others then
    dbms_output.put_line('Exception occured:'||SQLERRM);
    end;
    step - 3:
    create sequence emp_seq start with 1 increment by 1;
    step - 4:
    CREATE TABLE EMP
           (EMPNO NUMBER(15) NOT NULL primary key,
            ENAME VARCHAR2(20),
            JOB VARCHAR2(20),
            MGR NUMBER(4),
            HIREDATE DATE,
            SAL NUMBER(7, 2),
            COMM NUMBER(7, 2),
            DEPTNO NUMBER(6));
    INSERT INTO EMP VALUES
            (7369, 'SMITH',  'CLERK',     7902,
            TO_DATE('17-DEC-1980', 'DD-MON-YYYY'),  800, NULL, 20);
    INSERT INTO EMP VALUES
            (7499, 'ALLEN',  'SALESMAN',  7698,
            TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600,  300, 30);
    INSERT INTO EMP VALUES
            (7521, 'WARD',   'SALESMAN',  7698,
            TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250,  500, 30);
    INSERT INTO EMP VALUES
            (7566, 'JONES',  'MANAGER',   7839,
            TO_DATE('2-APR-1981', 'DD-MON-YYYY'),  2975, NULL, 20);
    INSERT INTO EMP VALUES
            (7654, 'MARTIN', 'SALESMAN',  7698,
            TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
    INSERT INTO EMP VALUES
            (7698, 'BLAKE',  'MANAGER',   7839,
            TO_DATE('1-MAY-1981', 'DD-MON-YYYY'),  2850, NULL, 30);
    INSERT INTO EMP VALUES
            (7782, 'CLARK',  'MANAGER',   7839,
            TO_DATE('9-JUN-1981', 'DD-MON-YYYY'),  2450, NULL, 10);
    INSERT INTO EMP VALUES
            (7788, 'SCOTT',  'ANALYST',   7566,
            TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
            (7839, 'KING',   'PRESIDENT', NULL,
            TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
    INSERT INTO EMP VALUES
            (7844, 'TURNER', 'SALESMAN',  7698,
            TO_DATE('8-SEP-1981', 'DD-MON-YYYY'),  1500, NULL, 30);
    INSERT INTO EMP VALUES
            (7876, 'ADAMS',  'CLERK',     7788,
            TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
    INSERT INTO EMP VALUES
            (7900, 'JAMES',  'CLERK',     7698,
            TO_DATE('3-DEC-1981', 'DD-MON-YYYY'),   950, NULL, 30);
    INSERT INTO EMP VALUES
            (7902, 'FORD',   'ANALYST',   7566,
            TO_DATE('3-DEC-1981', 'DD-MON-YYYY'),  3000, NULL, 20);
    INSERT INTO EMP VALUES
            (7934, 'MILLER', 'CLERK',     7782,
            TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);
    commit;
    step :- 5
    declare
    cursor c1 is select * from dept;
    k number:=0;
    m number:=0;
    begin
    for i in  c1 loop
    k:=k+1;
    --dbms_output.put_line('k:'||k);
    --dbms_output.put_line('i.deptno:'||i.deptno);
    m:=0;
    for j in 1..5 loop
    m:=m+1;
    --dbms_output.put_line('m:'||m);
    --dbms_output.put_line('i.deptno:'||i.deptno);
    insert into emp values
            (9000+emp_seq.nextval, 'SMITH'||'_'||emp_seq.currval,  'CLERK'||'_'||emp_seq.currval,     7902,
            TO_DATE('17-DEC-1980', 'DD-MON-YYYY'),  800, NULL, i.deptno);
    end loop;
    end loop;
    commit;
    exception
    when others then
    dbms_output.put_line('Exception occured:'||sqlerrm);
    end;
    step :-6
    create table dept3 as select * from dept where 1=2;
    create table emp3 as select * from emp where 1=2;
    alter table dept add object_id number;
    alter table dept add status varchar(20);
    alter table dept add err_msg varchar2(200);
    alter table emp add object_id number;
    -- I have not included the alter statements in the inital creation because i dont want them to insert into dept3 and emp3
    CREATE OR REPLACE
    PACKAGE test_b
    AS
      g_batch_id NUMBER;
      PROCEDURE emp_ins(
          p_EMPNO    NUMBER,
          p_ENAME    VARCHAR2,
          p_JOB      VARCHAR2,
          p_MGR      NUMBER,
          p_HIREDATE DATE,
          p_SAL      NUMBER,
          p_COMM     NUMBER,
          p_DEPTNO   NUMBER);
      PROCEDURE dept_ins(
          p_DEPTNO NUMBER,
          p_dname  VARCHAR2 ,
          p_LOC    VARCHAR2,
          p_batch  NUMBER);
      PROCEDURE validate_prc;
      PROCEDURE main;
    TYPE dept_t
    IS
      TABLE OF dept%ROWTYPE;
      hdr_tbl dept_t;
    TYPE emp_t
    IS
      TABLE OF emp%ROWTYPE;
      line_tbl emp_t;
    TYPE dept_i_t
    IS
      TABLE OF dept3%ROWTYPE;
      hdr_ins_tbl dept_i_t;
    TYPE emp_i_t
    IS
      TABLE OF emp3%ROWTYPE;
      line_ins_tbl emp_i_t;
    END;
    -- pacakge body
    CREATE OR REPLACE
    PACKAGE body test_b
    AS
    PROCEDURE emp_ins(
        p_EMPNO    NUMBER,
        p_ENAME    VARCHAR2,
        p_JOB      VARCHAR2,
        p_MGR      NUMBER,
        p_HIREDATE DATE,
        p_SAL      NUMBER,
        p_COMM     NUMBER,
        p_DEPTNO   NUMBER)
    IS
    BEGIN
      INSERT
      INTO EMP3
          EMPNO ,
          ENAME ,
          JOB ,
          MGR ,
          HIREDATE ,
          SAL ,
          COMM ,
          DEPTNO
        VALUES
          P_EMPNO ,
          P_ENAME ,
          P_JOB ,
          P_MGR ,
          P_HIREDATE ,
          P_SAL ,
          P_COMM ,
          P_DEPTNO
    EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('EXCEPTION AT EMP INSERT'||SQLERRM);
    END;
    PROCEDURE dept_ins
        p_DEPTNO NUMBER,
        p_dname  VARCHAR2 ,
        p_LOC    VARCHAR2,
        p_batch  NUMBER
    IS
    BEGIN
      INSERT
      INTO DEPT3
          DEPTNO ,
          DNAME ,
          LOC ,
          batch_id
        VALUES
          p_DEPTNO ,
          p_DNAME ,
          p_LOC ,
          p_batch
    EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('EXCEPTION AT DEPT INSERT'||SQLERRM);
    END ;
    PROCEDURE validate_prc
    IS
      CURSOR c1
      IS
        SELECT * FROM dept WHERE status IS NULL ;--AND rownum <25;
      CURSOR c2(p_dept NUMBER )
      IS
        SELECT * FROM emp WHERE deptno=p_dept;
      e_validation EXCEPTION;
    BEGIN
      OPEN c1;
      LOOP
        FETCH c1 BULK COLLECT INTO hdr_tbl limit 5000;
        SELECT emp_seq.nextval INTO g_batch_id FROM dual;
        EXIT
      WHEN hdr_tbl.count = 0;
        dbms_output.put_line('batch'||g_batch_id);
      END LOOP;
      CLOSE c1;
      dbms_output.put_line('C1 closed');
      --------- Loading data into the inv line table type -------------------------------
      FOR i IN 1 .. hdr_tbl.count
      LOOP
        dbms_output.put_line('started validation');
        -- do header level validations
        IF hdr_tbl(i).dname  IS NULL THEN
          hdr_tbl(i).status  := 'ERROR';
          hdr_tbl(i).err_msg :=',DNAME is null';
        END IF;
        OPEN c2(hdr_tbl(i).deptno);
        LOOP
          FETCH c2 BULK COLLECT INTO line_tbl;
          -- EXIT WHEN c2%NOTFOUND;
        END LOOP;
        CLOSE c2;
        FOR j IN 1 .. line_tbl.count
        LOOP
          -- do line validations
          IF line_tbl(j).ename IS NULL THEN
            hdr_tbl(i).status  := 'ERROR';
            hdr_tbl(i).err_msg :=',ENAME is null';
          END IF;
          BEGIN
            FORALL j IN line_tbl.FIRST .. line_tbl.LAST
            SAVE EXCEPTIONS
            UPDATE EMP
            SET object_id =3
              -- I have multiple columns to update based on validations
            WHERE deptno =hdr_tbl(i).deptno------------
            AND empno    =line_tbl (j).empno;
            COMMIT;
            line_tbl.DELETE;
            dbms_output.put_line( 'Successfully updated emp temp table.');
          EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            dbms_output.put_line( 'Error while updating line temp table. ' || sqlerrm );
            FOR j IN 1 .. sql%BULK_EXCEPTIONS.COUNT
            LOOP
              DBMS_OUTPUT.put_line(' occurred during line temp table updation ' || sql%BULK_EXCEPTIONS(i).ERROR_INDEX );
            END LOOP;
            raise e_validation;
          END;
        END LOOP; -- j
        --CLOSE c2;
        IF hdr_tbl(i).err_msg IS NULL THEN
          hdr_tbl (i).status  := 'VALID';
          hdr_tbl (i).err_msg := NULL;
        END IF;
        -- even if I have line validation failed I have to update header status and erorr msg
        BEGIN
          FORALL i IN hdr_tbl.FIRST .. hdr_tbl.LAST
          SAVE EXCEPTIONS
          UPDATE DEPT
          SET object_id =4,
            status      = hdr_tbl (i).status,
            err_msg     = hdr_tbl (i).err_msg
            --  batch_id =
            -- I have multiple columns to update based on validations
          WHERE deptno = hdr_tbl (i).deptno
          AND status  IS NULL; ------------
          COMMIT;
          hdr_tbl.DELETE;
          dbms_output.put_line( 'Successfully updated dept temp table.');
          --close c1;
        EXCEPTION
        WHEN OTHERS THEN
          ROLLBACK;
          dbms_output.put_line( 'Error while updating hdr temp table. ' || sqlerrm );
          FOR i IN 1 .. sql%BULK_EXCEPTIONS.COUNT
          LOOP
            DBMS_OUTPUT.put_line(' occurred during line temp table updation ' || sql%BULK_EXCEPTIONS(i).ERROR_INDEX );
          END LOOP;
          raise e_validation;
        END;
      END LOOP; --i
    EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('EXCEPTION AT validate'||SQLERRM);
    END ;
    PROCEDURE main
    IS
      CURSOR dept_ins_cur
      IS
        SELECT * FROM dept WHERE status='VALID';
      CURSOR emp_ins_cur(p_deptno NUMBER)
      IS
        SELECT * FROM emp WHERE deptno= p_deptno;
    BEGIN
      validate_prc;
      OPEN dept_ins_cur;
      LOOP
      FETCH dept_ins_cur BULK COLLECT INTO hdr_ins_tbl limit 1000
      EXIT
      WHEN dept_ins_cur%NOTFOUND;
      END LOOP;
      CLOSE dept_ins_cur;
      --------- Loading data into the inv line table type -------------------------------
      FOR i IN 1 .. hdr_tbl.count
      loop
      dept_ins(hdr_ins_tbl(i).deptno ,
      hdr_ins_tbl(i).DNAME ,
      hdr_ins_tbl(i).LOC , emp_seq.nextval);
      commit;
      OPEN emp_ins_cur(hdr_ins_tbl(i).deptno);
      LOOP
      FETCH emp_ins_cur BULK COLLECT INTO line_ins_tbl;
      --EXIT WHEN emp_ins_cur%NOTFOUND;
      END LOOP;
      CLOSE emp_ins_cur;
      for j in 1..line_ins_tbl.count loop
      emp_ins(line_ins_tbl(j).EMPNO ,
      line_ins_tbl(j).ENAME ,
      line_ins_tbl(j).JOB ,
      line_ins_tbl(j).MGR ,
      line_ins_tbl(j).HIREDATE ,
      line_ins_tbl(j).SAL ,
      line_ins_tbl(j).comm ,
      line_ins_tbl(j).DEPTNO );
      end loop;
      end loop;
      commit;
      BEGIN
      forall i IN hdr_ins_tbl.first .. hdr_ins_tbl.last
      SAVE exceptions
      UPDATE dept
      SET status   = 'INSERTED',
      err_msg  = null
      WHERE deptno=hdr_ins_tbl (i).deptno
      AND status   = 'VALID';
      COMMIT;
      hdr_ins_tbl.delete;
      dbms_output.put_line( 'inserting into temp tables.');
      EXCEPTION
      WHEN OTHERS THEN
      rollback;
      end;
    EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('exception in main' ||SQLERRM);
    END ;
    END;
    Thanks in advance...
    Message was edited by: 888025

    Hi, I have problem with the following pl/sql block
    Well, as Hoek already said, that is the understatement of the century.
    I can't be absolutely certain but I think that set of DDL and code that you posted has just about every possible error and design issue that there is! It would make an excellent addition to BluShadow's FAQs an an example of what NOT to do.
    I don't think it is even possible to 'fix the basics first' as Hoek suggested. IMHO the first step needs to be to create a functional requirements document (FRD) that explains in detail WHAT needs to be done. That doc should also contain info about how any errors/recovery/restart is to be handled. It is premature to try to implement ANY solution without first knowing what is needed functionally.
    Once the FRD is done you should do a walk-through based on your current architecture and sample data to make sure that the document really covers ALL of the steps that need to be performed and that it adequately explains how to deal with any processing or data issues that might arise.
    The next document you need is the TRD - Technical Requirements Doc that covers the different technical implementions of the FRD that can be done and the advantages/disadvantages of each.
    Then you can start working on a prototype.
    1. The DDL you posted isn't coherent - there are CREATE table statements and then later ALTER statements that add additional columns. There doesn't appear to be any reason for not including ALL of the columns in the CREATE table statement.
    2. You are using PL/SQL types instead of SQL types. That makes it impossible to use those types in SQL statements and makes it much more difficult to test since it is much easier to test a query in SQL (e.g. using sql*plus) that to embed the query in PL/SQL.
    3. You are defining the same type twice but giving it different names.
    TYPE dept_t
       IS
          TABLE OF dept%ROWTYPE
             INDEX BY binary_integer;
    TYPE dept_i_t
       IS
          TABLE OF dept%ROWTYPE
             INDEX BY binary_integer;
    Those are both based on the same DEPT table! Why the duplication?
    Also you are using associative arrays instead of just using nested tables. Get rid of the INDEX BY clause.
    4. You have some serious architectural and data model issues
    -- Assume the following scenario, we are validating dept (master) and emp(child) which are my temporary tables and updating the status back to
    -- dept ( for all the validation errors, even if we have any validation at child  it has to update the header record with error message),
    Why would you do that? You say 'it has to update the header record ...'. Says who? That is just one indication that you are trying to implement a 'solution' before you have adequately defined the 'problem'.
    Typically you would NOT alter any of the data tables; any validation errors/issues would get inserted into a table specifically designed to hold/log those issues. That table would contain key field values to correlate with the source of the error.
    Those 'master' and 'child' entities are two SEPARATE things. Issues with a 'master' row have NOTHING to do with any possible child rows.
    And issues with a 'child' row have NOTHING to do with any possible master rows. The ONLY connection between 'child' and 'master' is the foreign key that correlates them.
    So you don't necessarily have to validate the 'child' rows in sync with their 'master' row. In many cases you would have a procedure that performs validation of the entire set of 'master' rows and log those issues/problems. You would use a different procedure to validate the entire set of 'child' rows and log their issues.
    Those validation procedures can often work with ALL of the data using SQL statements instead of bulk processing.
    5. You are using loop constructs that are not valid for the type of processing you are using
    LOOP
        FETCH c1 BULK COLLECT INTO hdr_tbl;
        EXIT
      WHEN c1%NOTFOUND;
      END LOOP;
    There can be NO exit since the bulk collect with either get EVERYTHING or NOTHING. Possibly that is just a holdover from your attempt to use the LIMIT clause but you removed that clause from the FETCH; I don't know.
    There is so much wrong with what you posted it is really rather pointless to try to 'fix' it.
    I suggest you start over and clarify and DOCUMENT the actual requirements without prejudice about the solution that someone seems to want to force on you.

  • Differences between ANSI SQL and Oracle 8/9

    Hallo,
    i'm looking for good online texts or books concerning the problem "Differences between ANSI SQL and different database implementations (ORACLE, Informix, MySQL...)" I want to check a program written in C (with ESQL) that works with an Informix-DB. In this code i want to find code that is specific to the Informix-DB. I want to change the database, so all the code should be independent from a DB. Does anybody know texts or books concerning this problem?
    thx
    Marco Seum

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • Duplicating Effort in SQL functions

    Hi, If I have a piece of SQL such:
    SELECT
          SUBSTR(really complex nested functions [no PLSQL function / context switching however]) AS COL1,
          LENGTH(SUBSTR(really complex functions [no PLSQL function / context switching however])
    AS COL2
    FROM mytableThe second column is obviously just the length of COL1
    Does SQL engine when processing the function for COL2, execute the "really complex function" again - before getting the LENGTH? Or does it just reuse what it already calculated in COL1?
    If not, is there anyway of allowing the "Really complex function" result resued by other COLs?
    I do not wish to use a PLSQL function.
    Thanks for any help

    Well the CBO is pretty clever, it won't do two passes if it realises it's not necessary. Here's a bit of simple obfuscation SQL with and without inline view explained:
    EXPLAIN PLAN
    SET STATEMENT_ID='ORIG'
    FOR
    SELECT last_name, '555' || Translate (Substr (phone_number, 4),
                        '0123456789',
                        '5678901234') tel,
              Length ('555' || Translate (Substr (phone_number, 4),
                        '0123456789',
                        '5678901234')) len
    FROM employees;
    EXPLAIN PLAN
    SET STATEMENT_ID='ILV'
    FOR
    SELECT last_name, tel, Length (tel) len
    FROM (
    SELECT last_name, '555' || Translate (Substr (phone_number, 4),
                        '0123456789',
                        '5678901234') tel
    FROM employees);
    SQL> START XPLAIN
    Explained.
    Explained.
    Original
    Query Plan
    SELECT STATEMENT Cost = 3
    TABLE ACCESS FULL EMPLOYEES
    Inline View
    Query Plan
    SELECT STATEMENT Cost = 3
    TABLE ACCESS FULL EMPLOYEES
    Rollback complete.
    SQL>
    You might also look at the 11g virtual column feature where you define columns of a table as functions of other columns.

  • Set SPN for a local SQL Server 2008 R2 Express database used for local "Offline Mode" application

    Hi - I have tried searching the web for tips on this situation. Basically, I am trying to recreate a previous employee's client Image. This image is used for one of our companies client application that features and "Offline Mode" where it connects
    (Using Kerberos) to the local DB instead of the central DB server.
    The custom image connects without issue. I cannot seem to recreate his configuration. I am sure of these things:
    - Both images are using the same SQL Server 2008 R2 Express version.
    - Both images have the same user accounts setup.
    - Both images have "Remote Connections" setup with TCP/IP enabled in the Configuration Manager.
    - Both images are joined to the same Domain server currently.
    - Both images has the SQLServer service set to use "NETWORK SERVICE" account.
    This is the error message I get when SQL starts up for the non-working image:
    The SQL Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b, state: 3. Failure to register an SPN may
    cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies.
    Thank you for any assistance given.

    Hi Gribbled,
    Could you please change the SQL Server Service to run under 'LocalSystem' account and restart SQL Server? Then check if the error still occurs. When the SQL Server service account is configured to use the LocalSystem account, the server will automatically
    publish the SPN.
    Alternatively, to work around this issue, you can manually create the SPN for the SQL Server Service account  using the SETSPN tool. For more details, please review this
    blog.
    Thanks,
    Lydia Zhang

  • How to compile a procedure from Sql*Plus?

    Dear friends,
    I couldnt find the way how to compile my invalid procedure through sql*Plus.
    I know this is very awkward,but I m in need of that command only.
    Thanks
    Ritesh Sharma

    Pls check it --
    SQL>
    SQL>
    SQL> @C:\RND\Oracle\Function\a.sql;
    11  /
    Function created.
    SQL>
    SQL>
    SQL> start C:\RND\Oracle\Function\a.sql;
    11  /
    Function created.
    SQL> Regards.
    Satyaki De.

  • What is Difference between ANSI SQL and ORACLE SQL

    Hi,
    I am going to take the assesment test for ANSI SQL Programming before that i want to know any difference between ANSI SQL and ORACLE SQL?
    I am studying for SQL but the test will be ANSI SQL please let me give an idea about the both.
    Thanks
    Merina Roslin

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • Procedure not checking each sql statement.

    Hi All,
    I have created 2 tables names are A1 and B1. A1 table has some fields. Fields are no,sal,comm.,load_date. In A1 table NO (column) is the primary key.
    Second table is B1. this table has id,phone_no and load_date. In this table constraint
    ID column is the Not null.
    After that I have created 2 procedures one for A1 and one for B1. with in those procedures I used SQL insert statements.
    In procedures I used some valid sql statements and some invalid statements ( invalid statements means that I have specified constraint that’s why I specified duplicated and null values). While executing the procedures procedure shows error because of invalid statement and in that procedures I did not specify any Exceptions.
    If I specify Exceptions in procedures executing successfully some records are not loading procedure is comeing out. How do we mention server needs to be check and every insert sql startement.
    EX:
    If I give 6 records from 1 to 3 valid statements. I mentioned 4 th record copy of previos record( duplicated). 5 th record and 6 th valid records.
    Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
    create or replace procedure a_proc as
    --declare
    begin
    insert into a1 values (100,2000,300,sysdate);
    insert into a1 values(200,1000,400,sysdate);
    insert into a1 values(300,3000,500,sysdate);
    insert into a1 values(400,6000,600,sysdate);
    insert into a1 values(400,900,700,sysdate);
    insert into a1 values(400,10000,1200,sysdate);
    insert into a1 values(900,11000,1300,sysdate);
    commit;
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
    end a_proc;
    In B1 table colums are ID,PHONE_NO and Load_date. ID is not null column.
    For B1 population I have created one procedure
    create or replace procedure b_proc as
    --declare
    begin
    insert into b1 values(1,123456,sysdate); -- 1 record
    insert into b1 (phone_no,load_date) values (7896538,sysdate); --2 record
    insert into b1 (phone_no) values(6763723458); ----3 record
    insert into b1 (phone_no) values(453465778); --4 record
    insert into b1 values(400,72894894,sysdate); --5 record
    insert into b1 values(500,72894894,sysdate); --6 record
    commit;
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
    end b_proc;
    if I execute above procedure procedure executing successfully but procedure inserting only first record not inserting 5th and 6th record. How do we exception for 5th and 6th records also.
    Thanks and Regards,
    Venkat

    {color:#808080}{color:#333300}Hi,
    Please find answer to your question below:{color}
    Venkat: Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
    {color}
    {color:#0000ff}Guna: The procedure hits an exception after 4th record, and does not process anymore as it exits out of the procedure, I believe the data is not committed as well. You need handle exceptions if the processing has to continue. Same is the belwo case as well
    {color}{color:#333300}Regards,
    Guna{color}

  • How return parameter ref Cursor from procedure using dynamic SQL?

    I sorry, but i very need help.
    I using Oracle 8.0.6
    I need to return parameter of type ref Cursor from procedure.
    create or replace package PlanExp is
    type cursortype is ref cursor;
    procedure ShowPlan (cursorparam out
    cursortype.............);
    end PlanExp;
    create or replace package body PlanExp is
    procedure ShowPlan (cursorparam out cursortype,
    .............) Is
    sql_str varchar2(1000);
    sql_str_select varchar2(100);
    sql_str_from varchar2(100);
    sql_str_where varchar2(500);
    Return_Code integer;
    Num_Rows integer;
    cur_id_sel integer;
    tSum_Plan DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Ch DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Day DBMS_SQL.NUMBER_TABLE;
    begin
    /* calculating string variables ........... /*
    sql_str := 'select ' || sql_str_select ||
    'from ' || sql_str_from ||
    'where ' || sql_str_where ||
    'group by ' || sql_str_select;
    cur_id_sel := dbms_sql.open_cursor;
    dbms_sql.parse(cur_id_sel, sql_str, dbms_sql.native);
    dbms_sql.define_array(cur_id_sel, 1, tSum_Plan, 20, 1);
    dbms_sql.define_array(cur_id_sel, 2, tSum_Plan_Ch, 20, 1);
    dbms_sql.define_array(cur_id_sel, 3, tSum_Plan_Day, 20, 1);
    Return_Code := dbms_sql.execute(cur_id_sel);
    delete from TEMP_SHOWPLAN;
    Loop
    Num_Rows := dbms_sql.Fetch_Rows(cur_id_sel);
    dbms_sql.column_value(cur_id_sel, 1, tSum_Plan);
    dbms_sql.column_value(cur_id_sel, 2, tSum_Plan_Ch);
    dbms_sql.column_value(cur_id_sel, 3, tSum_Plan_Day);
    if Num_Rows = 0 then
    exit;
    end if;
    Exit When Num_Rows < 20;
    End Loop;
    dbms_sql.close_cursor(cur_id_sel);
    end;
    end PlanExp;
    How return cursor (cursorparam) from 3 dbms_sql.column_value-s ?

    I am using Oracle 8.1.7, so I don't know if this will work in
    8.0.6 or not:
    SQL> CREATE TABLE test
      2    (col1                    NUMBER,
      3     col2                    NUMBER,
      4     col3                    NUMBER)
      5  /
    Table created.
    SQL> INSERT INTO test
      2  VALUES (1,1,1)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (2,2,2)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (3,3,3)
      3  /
    1 row created.
    SQL> CREATE TABLE temp_showplan
      2    (tSum_Plan               NUMBER,
      3     tSum_Plan_Ch            NUMBER,
      4     tSum_Plan_Day           NUMBER)
      5  /
    Table created.
    SQL> EDIT planexp
    CREATE OR REPLACE PACKAGE PlanExp
    IS
      TYPE CursorType IS REF CURSOR;
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2);
    END PlanExp;
    CREATE OR REPLACE PACKAGE BODY PlanExp
    IS
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2)
      IS
        sql_str                VARCHAR2 (1000);
        cur_id_sel             INTEGER;
        return_code            INTEGER;
      BEGIN
        DELETE FROM temp_showplan;
        sql_str := 'INSERT INTO   temp_showplan '
               || ' SELECT '   || sql_str_select
               || ' FROM '     || sql_str_from
               || ' WHERE '    || sql_str_where;
        cur_id_sel := DBMS_SQL.OPEN_CURSOR;
        DBMS_SQL.PARSE (cur_id_sel, sql_str, DBMS_SQL.NATIVE);
        return_code := DBMS_SQL.EXECUTE (cur_id_sel);
        DBMS_SQL.CLOSE_CURSOR (cur_id_sel);
        OPEN cursorparam FOR SELECT * FROM temp_showplan;
      END ShowPlan;
    END PlanExp;
    SQL> START planexp
    Package created.
    Package body created.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC PlanExp.ShowPlan (:g_ref, 'col1, col2,
    col3', 'test', ' 1 = 1 ')
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    TSUM_PLAN TSUM_PLAN_CH TSUM_PLAN_DAY
             1            1             1
             2            2             2
             3            3             3

  • Any EVAL() equalant functions in SQL or PL/SQL

    good day
    i have 2 loops ,
    outer loop has the real data from a table
    and
    inner loop has the column name to be selected from outer loop.
    so in runtime, i need to select the columns dynamically .thats why i use inner loop. please see below.
    for i in data Loop
    for j in col_name Loop
    --column name of data loop should be selected from this col_name loop.
    dbms_output.put_line(i.||j.col_name);
    End Loop;
    End Loop;
    But this should not work.
    is there any eval function in plsql like in java and javascript to resolve this?
    please advice.
    thanks

    > so in runtime, i need to select the columns dynamically .thats why i use
    inner loop.
    There are two basic approaches to dealing with dynamic projections. (projection = the columns and data types returned by a SELECT)
    One is to use an interface that allows you, at run-time, to describe the projection. This is called a cursor's describe interface. In PL/SQL, that requires you to create a DBMS_SQL cursor. Details are in the [url
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref7370]Oracle® Database PL/SQL Packages and Types Reference guide.
    The other approach is to deal with the projection as a collection. This is illustrated below. The two problems with this approach is that you must use the collection's constructor in the projection, and that you must deal with implicit conversions or hardcode explicit data type conversions.
    SQL> create or replace type TStrings as table of varchar2(4000);
    2 /
    Type created.
    SQL>
    SQL> declare
    2 cursor c is
    3 select
    4 TStrings( object_id, object_name, object_type, created )
    5 from user_objects
    6 where rownum < 3;
    7 colValue TStrings;
    8 begin
    9 open c;
    10 loop -- data loop
    11 fetch c into colValue;
    12 DBMS_OUTPUT.put_line( '**start of row**' );
    13 for i in 1..colValue.Count
    14 loop -- column loop
    15 DBMS_OUTPUT.put_line( 'column '||i||' value='|| colValue(i) );
    16 end loop;
    17 DBMS_OUTPUT.put_line( '**end of row**' );
    18 exit when c%NOTFOUND;
    19 end loop;
    20 close c;
    21* end;
    SQL> /
    **start of row**
    column 1 value=12108
    column 2 value=BIN$OU4aqY4cfvXgQPsKOl1I1A==$0
    column 3 value=TABLE
    column 4 value=2007/08/31 12:20:47
    **end of row**
    **start of row**
    column 1 value=11753
    column 2 value=BONUS
    column 3 value=TABLE
    column 4 value=2007/08/27 14:26:57
    **end of row**
    **start of row**
    column 1 value=11753
    column 2 value=BONUS
    column 3 value=TABLE
    column 4 value=2007/08/27 14:26:57
    **end of row**
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for