Slight problem in PL/SQL

Hello. My problem seem you probably insignificant for you, but it caught me completely, so I will be really grateful for the explanations.

I have 2 tables: DEPARTMENTS and EMPLOYEES. department_id is the primary key, foreign key of EMPLOYEES and DEPARTMENTS. Task: Write a trigger associated with a change in the value of department_id in DEPARTMENTS of the table. The trigger must assign this new value to department_id of all employees who have worked in the affected Department. I wrote this:

create or replace trigger change_dept_id_trig
after update on departments
for each line
Start
Update employees
Define department_id =: new.department_id
where department_id =: old.department_id;
end;
/

but when I write:

update set department_id = 300 departments where department_id = 30;

then he reads:

(...) integrity constraint violation - parent key is not

I thought that my trigger would prevent this error. Please tell me what I'm doing wrong? What should I change in the trigger to get it worked correctly?

CREATE OR REPLACE TRIGGER change_dept_id_trig
AFTER the UPDATE OF THE departments WE of department_id
FOR EACH LINE
BEGIN
UPDATE employees
SET employees.department_id =:NEW.department_id
WHERE the employees.department_id =:OLD.department_id;
UPDATE job_history
SET job_history.department_id =:NEW.department_id
WHERE the job_history.department_id =:OLD.department_id;
END;
/

Tags: Database

Similar Questions

  • Problem with Top SQLs report

    Hello

    I have a big problem with Top SQLs reports, when I generate a report of high SQLs, SQL, the value text is not end, I know that there is a "The SQL text size" setting on the properties of the agent (this configuration is also on the collections setting ' Ta maximum size in characters of the short collects text of the SQL statement is ") on the two options , I've incremented the value of 256 (default) 1500, but when I generate the Top SQLs postpones continue it problem, once the changes I restarted the agent but the problem persists, I generate the report on the different formats, but result is the same, could you help me please.

    Thank you.

    Best regards.

    I see this in support KB article https://support.software.dell.com/kb/109536

    "

    • Title

      SQL in DB2 Top instructions are truncated in the delivered report of Top SQL

    • Description

      SQL in DB2 Top instructions are truncated in the delivered report of Top SQL

    • Resolution

    • Resolution A DDB-3673 request improvement with Support software Dell to show the full text of SQL high in the report Top SQL for DB2.

      Workaround At this point you should be able to make a custom report by cloning the Top SQL existing and then customizing report. »

    I know that this is not the solution, more of an explanation and guidance on how to solve this problem by using customizations.

    Golan

  • Problem with migration SQL Server Oracle 11.2 2012 DB using SQL Developer Migration workbench

    Hello

    I have a problem when migrating SQL Server Oracle 11.2 2012 using SQL Developer Migration workbench, hope that someone had the same problem before and can give same advide...

    I use SQL Developer Version 4.0.1.14 and Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0. and last jtds - 1.3.

    I created the schema migration_repo, privileges, connected to the third part of Db (SQL Server) and begin a trial with assistant. In the first step of the model to Capture, I get the message from the:

    "Company Capture Capture failed.  Refer to the table MIGRLOG in the repository for more details ".

    But MIGRLOG is empty.

    Here is my log:

    <? XML version = "1.0" encoding = "windows-1252" standalone = 'no '? >

    < Log >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    < level > SEVERE < / level >

    oracle.dbtools.migration.workbench.core.logging.MigrationLogUtil < class > < / class >

    < message > Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doOnlineEnterpriseCapture(FullMigrateTask.java:758) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doCapture(FullMigrateTask.java:601) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doMaskBasedActions(FullMigrateTask.java:400) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:314) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:147) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193) < param > < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ (RaptorTaskManager.java:554) < param > RaptorFutureTask.run < / param >

    java.util.concurrent.Executors$ (Executors.java:471) < param > RunnableAdapter.call < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615) < param > < / param >

    java.lang.Thread.run(Thread.java:744) < param > < / param >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@68e69a < param > < / param >

    < exception >

    < message > oracle.dbtools.migration.workbench.core.ui.FullMigrateTask$ FullMigrateTaskException: Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 758 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 601 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    line 400 > of < < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 314 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 147 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTask < class > < / class >

    < line > 193 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ RaptorFutureTask < class > < / class >

    < line > 554 < / line >

    < / framework >

    < frame >

    java.util.concurrent.Executors$ RunnableAdapter < class > < / class >

    < line > 471 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor < class > < / class >

    < line > 1145 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor$ Worker < class > < / class >

    < line > 615 < / line >

    < / framework >

    < frame >

    java.lang.Thread < class > < / class >

    < line > 744 < / line >

    < / framework >

    < / exception >

    < / recording >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    WARNING < level > < / level >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    <>error message: ORA-06550: line 1, column 14:

    PLS-00201: identifier ' SS2K5ALLPLATFORM. STAGECAPTURE' must be declared

    ORA-06550: line 1, column 7:

    PL/SQL: Statement ignored

    : FAILED: Database Migration: FAILURE < / message >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@1e2c9b99 < param > < / param >

    < / recording >

    I try with model db (DB empty, just a single table), but the error is same. However, if I try to copy the acronym tabele from SQL Server to Oracle it works fine...

    I guess it's something with the configuration, but beacause I am new in Oracle still have no idea...

    Any help would be much appreciated

    I thank in advance

    Stefan

    Hello Stefan,

    did you create the repository Migration of your database to Oracle (Tools-> Migration-> repository management)?

    The SS2K5ALLPLATFORM package is usually created when you add the migration of the Oracle database repository and it contains the function StageCapture.

    So please make sure that you have created a repository of migration in an Oracle database and associate it with the first step of your migration.

    -Klaus

  • How to solve the problem of Oracle SQL Developer Connection?

    People,

    Hello. I use the Oracle 11 GR 1 material database. The database https://localhost.localdomain:1158 control console / em works correctly. I can create a database and a table with success.

    My OS is Linux and connects to the internet successfully.

    In order to execute SQL statements. We use Oracle SQL Developer. I connect Oracle SQL Developer in the following way:

    Connection name: DB1 (is my database name)
    User name: SYS (this is the user name I used to connect to the Console)
    Password: SYS (this is the password used to connect to the Console)
    Connection type: basic
    Host name: localhost
    Port: 1158
    SID: DB1 (it is created during the installation of the database)

    But the error message: "status: failed - IO exception Connection Reset."

    Can any folk tell me how to solve the problem of Oracle SQL Developer Connection?

    user8860348 wrote:
    People,

    Hello. I use the Oracle 11 GR 1 material database. database Control Panel https://localhost.localdomain:1158 / em works correctly. I can create a database and a table with success.

    My OS is Linux and connects to the internet successfully.

    In order to execute SQL statements. We use Oracle SQL Developer. I connect Oracle SQL Developer in the following way:

    Connection name: DB1 (is my database name)
    User name: SYS (this is the user name I used to connect to the Console)
    Password: SYS (this is the password used to connect to the Console)
    Connection type: basic
    Host name: localhost
    Port: 1158
    SID: DB1 (it is created during the installation of the database)

    But the error message: "status: failed - IO exception Connection Reset."

    Can any folk tell me how to solve the problem of Oracle SQL Developer Connection?

    user name: sys
    password: enter_your_correct_password given at the time of the installation of oracle

    role: select sysdba if you would connect as sysdba otherwise select normal for users other than the sys

    HostName: Enter your ip or hostname of the oracle example server address:-192.168.11.12

    to find the terminal/command prompt open hostname in oracle installed machine
    type---> hostname

    type ping hostname--->

    You can find the IP address of the server

    Port number: 1521 (default)---> I guess, otherwise check the port number in the file tnsnames.ora under your ORACLE_HOME/network/admin folder

    SID: DB1

    try it
    Good luck

  • Problem in the SQL because of the order by clause

    Hi all
    I am facing a problem in a sql query. I use Oracle 10 g 2.
    Query is given below:
    SELECT t1.ename
            FROM T1, T2
           WHERE T1.EMPNO = 1234
             AND T1.ACCOUNTNO = T2.ACCOUNTNO
             AND T1.SEQ = T2.SEQ
           ORDER BY T2.SEQ
    The query Plan is:
    .----------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
     ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT              |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  1 |  TABLE ACCESS BY INDEX ROWID  | T1                   |     1 |    89 |     1   (0)| 00:00:01 |
    |   2 |   NESTED LOOPS                |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| T2                   |     2 |    40 | 11715   (1)| 00:00:41 |
    |   4 |     INDEX FULL SCAN           | PK_T2_SEQ            | 58752 |       |   122   (5)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN           | FK_ACCOUNTNO         |     3 |       |     0   (0)| 00:00:01 |
     ----------------------------------------------------------------------------------------------------
    Now, I want to reduce the time of this request.

    If I remove order by clause query that the query performance is quite perfect, but with order by clause its take time.

    I already set SORT_AREA_SIZE, but still nothing improves.

    Welcome and thank you for your suggestions.

    Thank you

    Published by: BluShadow on June 23, 2011 07:55
    addition of {noformat}
    {noformat} tags and formatted explain plan to make it readable.  Please see {message:id=9360002} for details on how to post code and data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    Hey, a quick test, try:

    select ename from (
    SELECT t1.ename, T2.SEQ
    FROM T1, T2
    WHERE T1.EMPNO = 1234
    AND T1.ACCOUNTNO = T2.ACCOUNTNO
    AND T1.SEQ = T2.SEQ
    and rownum > 0)
    ORDER BY SEQ
    

    Amiel Davis

  • Problem to install SQL Server 2005

    Hi friends,
    I have Toshiba computer and I had a problem installing SQL Server 2005 when we do the connectivity to the server, it is not work properly.

    As much I know Toshiba doesn t load of SQL Server.

    By the way: Toshiba has a lot of computers. One you have?

  • problem of memory sql toolkit

    Hello

    We use CVI 2012 and SQL Toolkit 2.2. Once a minute, we're looking a record for a special SQL database and we update the data in this leaflet. After update, let's close the database. Whenever we do this procedure that we see in the Task Manager which increases the memory needs of our program.

    After a few minutes (20-30) we get an error message memory.

    Anyone know if there is a problem to know or can someone help us?

    Thanks in advance

    Oliver

    Here is a part of the code:

    //
    hdbc = DBConnect (DATABASE_STRING);

    //
    HSQL = DBActivateSQL (hdbc, "' SELECT * FROM 'data_l01'" ");

    //
    RW = DBBindColChar (hsql, SQL_DATE, 32, cDB_Date, & iDB_Date_State, "");
    RW = DBBindColChar (hsql, SQL_TIME, 32, cDB_Time, & iDB_Time_State, "");
    RW = DBBindColInt (hsql, SQL_SPEED, & iDB_Clock, & iDB_Clock_State);

    Flag, ob der entry found wurde loeschen
    iFoundFlag = 0;

    Find the folder that we want to update
    While ((rw = DBFetchNext (hsql)) == DB_SUCCESS)
    {
    //
    If ((StrICmpWithoutSurrWhiteSpace (cDB_Date, cDate) == 0) &)
    (StrICmpWithoutSurrWhiteSpace (cDB_Time, cTime) == 0))
    {
    Flag, ob der entry found wurde set
    iFoundFlag = 1;
    break;
    }
    } / / Ende von find the folder that we want to update

    Daten uebernehmen
    iDB_Clock = Mutec;

    Insert the record into the database
    RW = DBPutRecord (hsql);

    //
    RW = DBDeactivateSQL (hsql);

    //
    RW = DBDisconnect (hdbc);

    Hi Oliver,.

    To read your code, I understand that you open a connection to the database for each update that you want to run.

    Usually I would advice you to open the database connection to the start once this reference until the program is closed instead of open every time.

    This could potentially solve your problem.

    Please let me know if that solves your problem.

    Best regards

    Raphael

  • Problem of uninstalling SQL Server 2008.

    I'm trying to uninstall SQL server 2008 of Panel-> Add / Remove Programs , but I'm getting pop-up indicating 'Managed SQL Server Setup has encountered a problem and needs to close. We are sorry for the inconvinience". Is someone can provide the solution for this issue?

    Ask the question in the Sql Server Forum:
    http://social.msdn.Microsoft.com/forums/en/category/SQLServer

  • PROBLEM CONNECTING TO SQL 2008 EXPRESS WITH ASP CLASSIC BETWEEN THE WORKSTATIONS ON A PRIVATE NETWORK

    I have created a private network (no internet connection) of four workstations, each running a SQL Express 2008 installation.  All four laptops are running Windows 7 Professional.  I created a homegroup for this private network.  While I don't care sharing of files between the four workstations, I have three of them in order to connect to the SQL 2008 Express database on the fourth mobile through channels of connection in the classic ASP programs.  Each of the four laptops can see others in the network.  I can ping the ip addresses of each to the other without any problem.  When I try to launch the ASP program on three laptop computers that attempt to connect to the SQL database on the fourth, I get the server does not exist or don't access denied error '80004005'.  The same program can also run on the fourth laptop and connects to the SQL database with no problems.  I tried to use SQLOLEDB and SQLNCLI10 provider in the chain of connection on the other three.  This operation fails.  I tried to add the IP address of the computer hosting the database as a Data Source in the connection on the other three string and still fails.  Named pipes and TCP/IP are enabled.  Each laptop can connect to the instance of SQLEXPRESS executed on each, but I need three to be able to connect to the instance of SQL Express running on the fourth.  Any ideas what I can do wrong?  This connection string works fine in the ASP program to connect to the local database on each laptop:

    Connection.Open "PROVIDER = SQLOLEDB; Server = computername\sqlexpress; UID = MyUser; PWD = MyUserPassword; DATABASE = MyDatabase ".

    Nothing seems to work for the chain of connection than the other three laptops to do to connect to this database on the fourth laptop.

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.msdn.Microsoft.com/forums/en-us/home

  • What is the problem with my sql says invalid identifier

    CREATE THE TABLE PROJECT

    (proj # NUMBER (6) NOT NULL,)

    p_name VARCHAR2 (15) NOT NULL,

    p_desc VARCHAR2 (150) NOT NULL,

    p_budget NUMBER (8).

    CONSTRAINT project_proj PRIMARY KEY #pname_pk (proj #, p_name));

    CREATE TABLE WORK ORDERS

    (wo # NUMBER (6))

    proj # NUMBER (6).

    wo_desc VARCHAR2 (150).

    wo_assigned VARCHAR2 (30),

    wo_hours NUMBER (5),

    wo_start DATE,

    wo_due DATE,

    wo_complete char (1),

    CONSTRAINT workorders_wo #_pk KEY(wo#) primary SCHOOL.

    CONSTRAINT workorders_wo #_fk FOREIGN KEY (proj #)

    REFERENCES PROJECT (proj #).

    Workorders_wodesc_uk of CONSTRAINT UNIQUE (wo_desc).

    CONSTRAINT workorders_hours_ck CHECK (wo_hours > = 0).

    CONSTRAINT workorders_wocomplete_ck CHECK (wo_complete in ('Y', 'n')));

    Whenever you have an error message the best thing to do is post a copy of your session with your statement sqlplus output. Like this.

    I have no problem with your first statement regarding the syntax and semantics

    SQL> create table project
      2  (
      3  proj# number(6) not null,
      4  p_name varchar2(15)not null,
      5  p_desc varchar2(150)not null,
      6  p_budget number(8),
      7  constraint project_proj#pname_pk primary key (proj#, p_name)
      8  );
    
    Table created.
    

    Second table a problem that his tent to make reference to project.proj #. But the problem is that it doesn't have a primary or unique key defined in this topic.

    SQL> create table workorders
      2  (
      3  wo# number(6),
      4  proj# number(6),
      5  wo_desc varchar2(150),
      6  wo_assigned varchar2(30),
      7  wo_hours number(5),
      8  wo_start date,
      9  wo_due date,
     10  wo_complete char(1),
     11  constraint workorders_wo#_pk primary key(wo#),
     12  constraint workorders_wo#_fk foreign key (proj#)
     13  references project (proj#),
     14  constraint workorders_wodesc_uk unique (wo_desc),
     15  constraint workorders_hours_ck check (wo_hours >=0),
     16  constraint workorders_wocomplete_ck check (wo_complete in ('y' ,'n'))
     17  );
    references project (proj#),
                        *
    ERROR at line 13:
    ORA-02270: no matching unique or primary key for this column-list
    

    I defined a

    SQL> alter table project add constraint project_proj#_uk unique (proj#);
    
    Table altered.
    

    Now, the second table is also created correctly

    SQL> create table workorders
      2  (
      3  wo# number(6),
      4  proj# number(6),
      5  wo_desc varchar2(150),
      6  wo_assigned varchar2(30),
      7  wo_hours number(5),
      8  wo_start date,
      9  wo_due date,
     10  wo_complete char(1),
     11  constraint workorders_wo#_pk primary key(wo#),
     12  constraint workorders_wo#_fk foreign key (proj#)
     13  references project (proj#),
     14  constraint workorders_wodesc_uk unique (wo_desc),
     15  constraint workorders_hours_ck check (wo_hours >=0),
     16  constraint workorders_wocomplete_ck check (wo_complete in ('y' ,'n'))
     17  );
    
    Table created.
    
    SQL>
    

    My Version of DB's

    SQL> select * from v$version where rownum = 1;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    
    SQL>
    
  • Pool pane there problem with long sql query?

    Hello

    I use Jdeveloper 11.1.2.2.0

    In the application I'm developing, there is a long sql query to call (it's a function from a package, which may take a few minutes to run) and I want to display a progress bar for the user.

    The progress bar component is a "progress indicator" and the percentage of achivement is refreshed by a component 'pool' with 1-second interval.

    The two components are connected in a javabean.

    The function with the sql query is the javabean too.

    To run the sql query that is long on background I am calling from a thread, and the pool component get the advancement of the percentage of a pipe filled with the sql function.

    If the function to run is just a long loop of java operations the progress bar works fine, but if I put my long sql query instead, stop listener pool should be performed to stop long, s sql queryo progress are updated only at the end of the long sql query.

    You have any ideas?

    Thank you

    Thanks for your replies. Unfortunately, it was not the solution to my case, sql procedures to block the entire application while ADF awaits them at the end...

    To solve my problem, I finally used a PL SQL Job to call my sql procedure (dbms_job.submit).

    The application is released right after the call and the component of the pool is not more secure!

    Kind regards

    Yann

  • Problem with pl/sql procedure, trying to get the value of the user during execution

    Hello

    Using oracle 11.2.0.3

    Can run sql that gets the value of the user during the fine workmanship and also via an anonymous block.

    uses of SQL & Enter_Product_Number

    anonymous block using: Enter_Product_number.

    However, get problems when trying to create a pl/sql procedure, use one of the above

    relevant below tried code part & and: buit works do not error, try bad bind variable if used: and ora-600 if try use &.

    How can we have a procedure from pl/sql that can call and receives a value of user during execution?

    Only way around what I can think of is to pass parameters to the procedure

    Thank you

    create or replace procedure ins_into_issues is

    v_nd_rec_cnt number (10);

    v_normal_rec_cnt number (10);

    Start

    Select count (*)

    in v_nd_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & old_nd_product_number;

    Select count (*)

    in v_normal_rec_cnt

    refmast.issues I have

    where i.iss_product_num = & normal_product_number;

    -code below commented above works.

    end;

    Hello

    what something like this:

    create or replace procedure INS_INTO_ISSUES ( in_normal number, in_old number )  is
      v_nd_rec_cnt     number(10);
      v_normal_rec_cnt number(10);
    begin
        select count(*)
          into v_nd_rec_cnt
         from refmast.issues i
         where i.iss_product_num = in_old;
      --
        select count(*)
          into v_normal_rec_cnt
          from refmast.issues i
         where i.iss_product_num = in_normal;
    end;
    

    concerning

    Kay

  • Problem of pl/sql code

    Hi guys I'm not a programmer experienced PL/SQL, I a facin a problem in my code.

    Orders that the customer owns resulting numbering is the purpose of this code example, I use the sample table OE. ORDERS.

    I want to get the following:

    Order_ID

    Customer_id

    #Ordenes

    2458

    101

    1

    2447

    101

    2

    2413

    101

    3

    2430

    101

    4

    2397

    102

    1

    2432

    102

    2

    2414

    102

    3

    243

    102

    4

    As you can see I want to create another table in which I add a column to store dial controls that have the customer.

    My code is as follows:

    _____________________________________________________________________________________

    DECLARE

    Customer_ID ORDERS .id % type;

    CURSOR c_customers is

    SELECT DISTINCT (CUSTOMER_ID( ) DE ORDERS ;

    num_clientes NUMBER ;

    BEGIN

    Select count (distinct (customer_id))

    IN num_clientes

    de orders ;

    BEGIN

    OPEN c_customers ;

    LOOP

    Go GET c_customers in Customer_ID ;

    RUN IMMEDIATE ' create the sequence idreg with 1increment by 1' '. ; 

    Insert in almacen_ord (

    id_reg ,

    order_id ,

    order_total ,

    Customer_ID )

    Select

    idreg .nextval,

    order_id ,

    order_total ,

    customer_id

    de ORDERS

    Customer_ID = Customer_ID ;

    RUN IMMEDIATE 'drop sequence idreg' ;

    OUTPUT WHEN c_customers % NotFound;

    dbms_output.put_line ()ID_client) ;

    END LOOP;

    CLOSE c_customers ;

    END;

    /

    _________________________________________________________________________________

    But I don't understand why I'm facong a question saying line 41:

    ORA-06550: line 41, column 4:

    PLS-00103: encountered the symbol "end-of-file" during the expected in the following way:

    (begin case declare exit end exception for goto if loop mod)

    pragma raise return null select update while with

    < an ID > < a between double quote delimited identifiers of >

    Any help or a another idea will be appreciated. Concerning

    Ah yes sorry

    That's why help/tables of sample data.  I can not test, so you need to debug

    Add:

    order by order_id

    the parentheses, after the partition of customer_id

    or the order that you want to have the increment of the counter by.

  • Problem with PL/SQL variables...

    Hi, I am fairly new to this, so apologies if this is a simple question.

    I have a text field on my page (ENTITY_ACC_NO), and I'm putting a pl/sql block on it to fill with a conditional piece of treatment based on the value of another field (ENTITY_SELECT). (Its actually a drop-down list)


    So on the source of the article, I updated the source type the body of the pl/sql function with the following code piece...

    IF: ENTITY_SELECT = '%' THEN

    : ENTITY_ACC_NO: = ";

    ON THE OTHER

    Select account_no in: entity_acc_no of the entity where entity_id =: entity_select;

    END IF;

    The problem is that it does nothing... Firstly, I correctly use variables? I read somewhere that you should use the function of V, but it also seems like you use this for stored procedures, rather than a simple pl/sql.

    Either way, im actually trying to work around the error as the drop-down list has '%' in it for another database query text, and I use it here through its primary key to retrieve other information about this...

    Thank you very much

    Richard

    Source of the element is used when rendering a page - looks like you can expect as things change when a selection list option is specified.

    Discover the use of dynamic actions

    http://www.grassroots-Oracle.com/2013/10/Apex-101-dynamic-actions.html

    The other thing that I can see is the page elements, you specify is not a page number of prefix, which is worth questioning - you specify the name and why you use the conventional notation P1_ITEM_NAME?

  • Strange problem with this SQL

    Hello

    I'm trying to concatenate the value of SQL_TEXT in multiple lines in a single string using this SQL statement. The problem is that it works fine if I use the PIECE, but if I use SQL_TEXT I get this error ORA-30004: when you use the SYS_CONNECT_BY_PATH function, cannot have a separator in the value of the column. As you can see I tried a number of separators I know are not in SQL_TEXT but still error. And help would be great.

    I tested on 11 GR 2 11.2.0.3 but need to run it on 10.2.0.4 so I can't use LISTAGG. I'm open to other methods but I don't have the ability to place and PLSQL nto the database. It must be done in SQL.
    select 
      CURRENT_SID, 
      sys_connect_by_path(PIECE,'~') -- Works
      --sys_connect_by_path(SQL_TEXT,'') -- Does Not Work
      -- trim(max(sys_connect_by_path(SQL_TEXT,'~')) keep (dense_rank last order by CURR),'~') as FULL_SQL_TEXT -- Does Not Work
      --ltrim(max(sys_connect_by_path(PIECE,'!')) keep (dense_rank last order by CURR),'!') as FULL_SQL_TEXT -- Does Not Work
    from
      (
      select 
          S.USERNAME, S.SID as CURRENT_SID, S.SERIAL#, T.PIECE,
          T.SQL_TEXT,
          ROW_NUMBER() over (partition by S.USERNAME, S.SID, S.SERIAL# order by T.PIECE) as CURR,
          ROW_NUMBER() over (partition by S.USERNAME, S.SID, S.SERIAL# order by T.PIECE) -1 as PREV
      from 
        V$SESSION S,
        V$SQLTEXT_WITH_NEWLINES T
      where 
        S.SQL_ID is not null
        and S.SQL_ID = T.SQL_ID
        and S.SID = sys_context('USERENV', 'SID')
      order by 
        T.PIECE
      )
    group by 
      CURRENT_SID
    connect by PREV = prior CURR
    start with CURR = 1;

    Hi SY,
    Thanks for the reply that your SQL worked very well. You're right about the GROUP BY and AGGREGATIONS, I had tried so many different things, I had pasted in a version with a bit of my test which was a little strange looking.

    The key was just as you say I was looking at my current SQL contained now my ' ~ 'or'!' delimiter. Thanks for all the help!

Maybe you are looking for

  • Satellite Pro M30: RESTARTS REPEATEDLY

    Hi I have a TOSHIBA SATELLITE PRO M30 LAPTOP 1.7 CENTRINO that was dropped it is moved that it restarts every time (long story). Works fine if it does not move otherwise. No idea why it's happening and it can be cured?

  • HP mini 1101 computer: the bios password recovery

    My laptop is also locking me and the code that pops up isCNU9441L1Y Help, please!

  • Change the GPU and power supply turns it off a Windows OEM?

    So basically I want to replace my graphics card with a new and do I need to switch to the diet. Modification of the power supply and the GPU will disable my Windows OEM?

  • weird math

    I'm working on a calculator application simple grade, but I can't do the math at work. If I input 100 to inPossible and 50 for augL, I get 2 for finalGrade... am I missing something here? import bb.cascades 1.0 //-- create one page with a label and t

  • BlackBerry Smartphones why I receive this email every few minutes?

    I had my 8830 for two weeks. All of a sudden I get an email like this one every few minutes for the last 48 hours.  I stopped using my Blackberry, finally deleted all messages, and they keep coming.  What is and what to do about this? This message is