cursor and dbms_output

Hi all

on 11.2.0.4,.

I have a table:

SQL > desc details

Name                                      Null?    Type

----------------------------------------- -------- ---------------

LOAN NOT NULL NUMBER (10)

NUMBER NOT NULL NUMBER (3)

ISBN                                               NUMBER(10)

COPY NUMBER (3)

RENDULE                                            DATE

This query returns a few lines:

Capture.PNG

But when I want to use that in a PL/SQL, I have nothing:

Set serveroutput on

Declare

nombre_emp number (10);

CURSOR C_EMP is

SELECT isbn

IN nombre_emp

DETAILS

Group by isbn

;

Begin

DBMS_OUTPUT. ENABLE (1000000);

C loop C_EMP

DBMS_OUTPUT. Put_line ('MCNT->' | nombre_emp);

DBMS_OUTPUT. NEW_LINE;

End loop;

End;

/

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

MCNT->

PL/SQL procedure successfully completed.

Thanks for help.

I must point out that your data model is incorrect. Numbers ISBN is strings, not numbers (they have a zero not significant, what is important - which means that it should be a varchar2 (10) and not a number (10)).

A test I always use - can you two of them add up or perform other arithmetic operations on them? If this isn't the case, it is not a number, but a string.

Tags: Database

Similar Questions

  • MacBook pro 2 logon screen starts with no arrow cursor and must be restarted

    2014 Macbook Pro screen Retina 2 13 "opening session starts with no arrow cursor and must be restarted once every five tests.  When the computer reboots, message appears asking you if it must open programs that had started to load or cancel.  It is a recent problem that does not occur two months ago.  Once restarted, everything seems to be OK.  That is what it is?

    Try the start mode by holding down the SHIFT key at startup. Secure boot is quite slow because the operating system performs some cleanup and verification tasks, so give it time. Once you're completely connected, restart normally.

  • black screen and nice white cursor and Ctrl alt del will not work, I can not update shell

    black screen and nice white cursor and Ctrl alt del will not work, I can change the shell to the Explorer, but I can't unload or load the hive, what should I do?

    Hello

    Your question I know that some of these methods is not available now, however, all
    Convenience store is included just in case where win you some access as you try to solve the problem.

    You can access Mode safe? Repeatedly press F8 as you start? If yes you can try Control Panel - device
    Manager - graphics card - Double click on - driver tab - click on UPDATE driver - then right click
    on devices and UNINSTALL - REBOOT.

    Another method to try to get to the desktop (try in normal Windows Mode without failure)
    CTRL + ALT + DELETE and on the tab process EXPLORER.exe and COMPLETE the PROCESS on this subject - then
    on the Applications tab - lower right - new task - type in EXPLORER.exe. Safe mode is reached
    by tapping F8 as you start several times.

    First check this thread in case it is simple and if not to come back to this thread.

    http://social.answers.Microsoft.com/forums/en-us/vistaprograms/thread/50247d5e-0ae0-446c-A1bd-11287fd1478a

    Black screen problems are extremely difficult to repair and all patch is usually on a base hit or miss.
    That there is no information on a black screen as it is on a blue screen just adds to the
    Difficulty. Often using a restore point or Startup Repair will have no effect. You can try a
    Google to see the proposed repairs, whom some have worked however these cover a wide
    field efforts.

    Here's a video of one of them.

    http://www.Google.com/search?hl=en&q=black+screen+of+death+Vista&btnG=search&AQ=f&OQ=&AQI=G1

    Here's another fix
    http://blogs.PCMag.com/SecurityWatch/2008/12/the_mysterious_black_screen_of.php

    You have a Vista disk? You can try restoring the system to it. If you don't have the disks your
    system manufacturer will sell them at low prices. Or try in safe mode if you can get there.

    How to make a Vista system restore
    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html

    You can create a recovery disc or use someone even version (making the system restore it)
    must be bootable).

    How to create a Vista recovery disk
    http://www.Vistax64.com/tutorials/141820-create-recovery-disc.html

    ------------------------------------------------

    These require the correct Vista discs since you can not start safe mode.

    Try the Startup Repair tool-

    This tells you how to access the System Recovery Options and/or with a Vista disk
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    Try recovery options Startup Repair

    How to do a startup repair
    http://www.Vistax64.com/tutorials/91467-startup-repair.html

    -----------------------------------------------

    Here are a few Google searches where many have found different solutions:

    Vista black screen - check that a 1st
    http://www.Google.com/search?hl=en&source=HP&q=Vista+black+screen&AQ=f&OQ=&AQI=G10

    Vista black screen Solution
    http://www.Google.com/search?hl=en&q=Vista+black+screen+solution&AQ=f&OQ=&AQI

    Vista black screen Fix
    http://www.Google.com/search?hl=en&q=Vista+black+screen+fix&AQ=f&OQ=&AQI

    -----------------------------------------------

    If necessary and you can access all ordinary Windows.

    You can try an In-Place Upgrade (hopefully save programs and data) or a repair installation
    (if all goes well, the data records and need to reinstall programs). Be sure to do a good backup or three.

    You can use another DVD that aren't copy protected but you you need to own
    Product key.

    On-site upgrade
    http://vistasupport.MVPs.org/repair_a_vista_installation_using_the_upgrade_option_of_the_vista_dvd.htm

    If nothing works, you can make a repair facility that must save the data but you will need to
    Reinstall the programs. This also requires correct Vista disks especially for OEM versions. You will be
    need to know your product Code.

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-happened-to-the-recovery-console

    How to perform a repair for Vista Installation
    http://www.Vistax64.com/tutorials/88236-repair-install-Vista.html

    ---------------------------------------------------------------------------

    Another method that works sometimes: at the command prompt, type of Vista startup disk:
    (a line type or copy and paste one line at a time and hit enter - enter a bracket)
    or "BOLD")

    c:

    cd\

    CD c:\Windows\System32\winevt (there is a space between cd and C :)

    Ren LogsOLD Logs (there are spaces between ren and newspapers and Logsold)

    RESTART Windows

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • Windows 7 screen freezes, freezes mouse cursor and keyboard freezes.

    Hi all

    About a month ago my internet kept cutting at about 02:00 in the afternoon - even if my BThub said it was a signal - and my internet access would not return until 05:00 sharp later that day here. This went on for about two weeks, it doesn't happen too much now, however, recently, something happens...

    I have a desktop HP Pavilion s5000 and all day - every day - not only freezes my screen, if I'm online or simply type in a Word doc, but my mouse cursor and keyboard freeze too, all at once. It's as if all of the computer crashes, and the only way I can "unfreeze" it is cutting off the entire batch to the switch. In this case nothing three times a day to ten times a day. Can someone tell me what could be the problem and how I can try to solve it? I did a system restore, to restore the PC to a date earlier, I did this about five times now, but the problem persists.

    Many thanks in advance,

    Danni.

    Hello Danni,

    Thank you for reaching out to us to the Microsoft Community Forum.

    When your computer hangs or freezes, it is disruptive and can slow you down. There are a few reasons your computer might hang, freeze, or crash. Try the following common methods provided for in article below as a first step to solve the problem.

    8.1 Windows, Windows 8 or Windows 7 hangs or freezes

    Note:

    The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

    Also as you use HP computer, you can try the troubleshooting provided in the link below steps and check if that helps resolve the issue.

    Computer hangs or freezes (Windows 7)

    Note:

    BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

    Important:

    In case you follow ' step 7 "in the above link from HP that speaks to recover the computer to factory settings then you will need to contact HP support and we also recommend that you back up all important data to an external drive before recovery of the computer to the factory settings.

    Hope that the information provided will help you. Do we know the State of the question, so that we can help you further.

  • Illustrator keeps loading cursor and does not

    Hello

    I'm looking for more technical help on starting Illustrator because it does not work properly. When you start Illustrator, the loading symbol (the circle next to the arrow) starts flashing quickly. I can move the cursor and start a new document from the openingscreen, but cannot click after that. Also the key combinations do not work.

    I checked for of programma old Wacom, but I believe that I have none. Just to be sure, I installed a different mouse, which changes nothing. I also started several times and used a cleaning tool.

    Photoshop and Indesign work perfectly. It was the first time I started by Illustrator, so it didn't work before.

    Someone at - it an idea on what is happening and what I could do to fix it?

    Thank you very much

    Marieke Jong

    Well it seems that we have found a solution in this thread:

    Re: The cursor flashes and deselects the menus

    Try it, so far, it works for me

  • When I use the brush or eraser, an O symbol appears next to my cursor and prevents me from drawing a line. Does anyone know a solution to this problem?

    When I use the tool brush or eraser, over every other shot, I get a sign O (circle with a line through it) next to the brush shape / cursor and can't shoot. Please help, this is very frustrating and disrupting my work flow! I paint each frame of the animation, so you can imagine, every other shot is quite often.
    There the layers locked below my active drawing layer, that makes me wonder if Flash is trying to tell me I can not shoot these layers, but I know that more I need these layers there to guide the design of my active layer. I have encountered this problem before with layers being locked and these. What Miss me?

    Any idea is appreciated.

    Thank you!

    I just realized my problem!
    Sorry, it is partially due to my impatience; I get the "illegal sign" when I press a shortcut key to switch from one tool to the other and try to make a stroke when the tool has not finished "switching". So I'm going to press my button "e" with the intention to switch to Eraser tool and I will immediately draw a line, but recently, I noticed that the toolbar did not brush Eraser still at the point where I was drawing.
    So I'll check why my computer is so slow, or I'll try to be a little more patient, or both
    Thank you for your time!

  • problem with the CURSOR and WITH clause

    Hi guys,.

    I have never created a package before. I try to run it, but I get:
    ORA-06550: line 8, column 16:
    PLS-00382: expression is of the wrong type
    ORA-06550: line 8, column 3:
    PL/SQL: Statement ignored

    I know that my problem is in the next section

    OPEN FOR V_io_cursor

    with GOT_R_NUM like)


    Is the above correct?

    When I copy paste the "heart" of the query, it works very well. I really have a problem with the CURSOR and the declaration.

    Here's the code in its entirety. I know that the code is much more then he returned, but ignore this overload that was to do some tests to make sure that I can achieve any query request.

    CREATE OR REPLACE
    PKG_SPF_NATIONALREPORTS PACKAGE BODY IS

    PROCEDURE GET_NATIONAL_TOTAL_RESULTS (P_SelectFields IN varchar2, P_SUMFields IN varchar2, io_cursor IN OUT C_RESULTS)
    IS
    v_io_cursor C_RESULTS;

    BEGIN

    OPEN FOR V_io_cursor

    with GOT_R_NUM like)
    SELECT
    -START P_SelectFields
    r.cli_served,
    r.EIER,
    -END P_SelectFields
    r.RC,
    r.Year_ID,
    r.period_id,
    r.agreement_type_ind,
    CONTRACT_NUMBER. CONTRACT_NUMBER_TEXT,
    YEARS.year_desc,
    RC_CODE.rc_code_id,
    RC_CODE.rc_code,
    AHRDA HOLDERS. AHRDA_ID,
    AHRDA HOLDERS. REGION_ID,
    AHRDA HOLDERS. PROVINCE_ID,
    AGREEMENT_TYPE. AGREEMENT_TYPE_ID,
    AGREEMENT_TYPE. AGREEMENT_TYPE_DESC_EN,
    ROW_NUMBER() over (partition R.YEAR_ID, R.CONTRACT_Number_Text
    order by
    P.PERIOD_desc
    (/ / DESC NULLS LAST) AS r_num
    RESULT r
    JOIN period p ON r.period_id = p.period_id
    JOIN CONTRACT_NUMBER ON r.contract_number_text = CONTRACT_NUMBER. CONTRACT_NUMBER_TEXT
    JOIN RC_CODE ON contract_number.rc_code_id = rc_code.rc_code_id
    JOIN AHRDA holders ON ahrda.ahrda_id = rc_code.ahrda_id
    JOIN AGREEMENT_TYPE WE AHRDAS. AGREEMENT_TYPE_ID = AGREEMENT_TYPE. AGREEMENT_TYPE_id
    JOIN the YEARS WE r.year_id = YEARS.year_id
    )
    SELECT year_desc
    -START P_SUMFields
    SUM (cli_served) AS sum_cli_served
    The SUM (eier) AS sum_eier
    -END P_SUMFields
    OF got_r_num
    GROUP BY year_desc
    ORDER BY year_desc
    ;

    io_cursor: = v_io_cursor;

    END GET_NATIONAL_TOTAL_RESULTS;

    Agree - all this talk of loops FOR is completely irrelvant.
    A refcursor is usually the exact mechanism to return a result set.

    What is C_RESULTS?

    Just use SYS_REFCURSOR.

    No need for local variable.

    OUT why? Not just walk OUT?

    PROCEDURE GET_NATIONAL_TOTAL_RESULTS
    (P_SelectFields IN varchar2, P_SUMFields IN varchar2, io_cursor OUT SYS_REFCURSOR)
    IS
    BEGIN
     OPEN io_cursor FOR ...
    END;
    
  • What is the difference between the ref cursor and the sys_refcursor.

    create or replace procedure GetEmployeesInDept (c sys_refcursor)

    Hello


    I have a query related to the above stored procedures.
    When you set the cursor, we mentioned as sys_refcursor and in some US sites I saw him as a REF CURSOR as shown

    create or replace procedure GetEmployeesInDept (Ref Cursor c)


    Please tell me what is the difference between the ref cursor and the sys_refcursor.

    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/tuning.htm#sthref2376

    Concerning

    Etbin

  • Can I create a cursor and set the values by myself

    Can I create a cursor and set the values by myself, and it has not been filled by an SQL?

    Thanks in advance

    Yes, you can.
    Use variables with a default value or nvl (some_parameter, some_variable) in your cursor WHERE predicate.
    They provide an example if it isn't clear, since that's all I can think about reading your post...

  • open cursor and drop table

    Hello

    How does this work?

    Session 1: Session 2:


    SQL > create table t (x number);

    Table created.

    SQL > insert into t values (1);

    1 line of creation.

    SQL > insert into t values (2);

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > start

    2 for f in (select * from t) loop

    3 dbms_output.put_line(sysdate||) e '|| f.x);

    4 dbms_lock.sleep (60);

    5 end of loop;

    6 end;

    7.


    SQL > drop table t;

    Deleted table.

    SQL > select sysdate to double;

    13:58:45

    13:58:34 1

    13:59:34 2


    The table has been deleted, but the line is always returned once the table is deleted. With the help of OPEN and FETCH has the same


    declare
    cursor c is select * from t;
    r t % rowtype;
    Start
    Open c;
    extract the c in r;
    dbms_output.put_line(sysdate||) e '|| r.x);
    DBMS_LOCK. Sleep (60);
    extract the c in r;
    dbms_output.put_line(sysdate||) e '|| r.x);
    end;
    /

    Is this a bug? I could even reproduce it with 1 million rows. Shouldn't this ORA-01001 invalid cursor return?


    Start
    for f in (select * from t) loop
    If f.x in (1,10,100,1000,10000,100000,1000000) then

    dbms_output.put_line(sysdate||) e '|| f.x);

    DBMS_LOCK. Sleep (5);

    end if;
    end loop;
    end;
    /

    Thank you

    Laurent

    PS: It boils down to having no consistency to the DICTIONARY level... which is ugly

    Huh? The dictionary makes perfect sense.

    Any query cursor / who uses the data dictionary will get the correct results.

    If the cursor that you use should the data dictionary, it will get the correct results - he'll notice the table disappeared and will throw an exception.

    Your 'problem' manifests only for a SELECT query. Change the cursor in UPDATES and you can't delete the table.

    SQL > drop table t;

    drop table t

    *

    ERROR on line 1:

    ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

    Even if you remove a line in this loop.

    https://docs.Oracle.com/CD/B28359_01/server.111/b28318/consist.htm#i8841

    As a request enters the implementation phase, change current system (SNA) number is determined. Figure 13-1, this system change number is 10023. As data blocks are read in the name of the query, only the blocks that are written with the observed SNA are used.

    When the cursor is opened that the SNA is determined, the data file header is read and Oracle knows where the first measure.

    The cursor can read this measure without the need of the data dictionary. So if you drop the table in another session your cursor can continue to read this measure.

    It is ONLY when the next measurement is necessary that Oracle uses the dictionary of data and notice that the table has been deleted.

    https://docs.Oracle.com/CD/B28359_01/server.111/b28318/logical.htm

    A scope is a number of blocks of contiguous data allocated for storing a specific type of information.

    The cursor can keep accessing the measure, and all these "contiguous data blocks" because he knows where the measurement begins and how many blocks there.

    So if 'million' lines fits into this extent (s) the query will keep trucking.

    It may take even more to see the missing table if a path to the index is used as the index blocks are pointers to the previous index block. These pointers can span extensions - you can read an entire table once it has been abandoned if the cursor is using the index to find all data or all the blocks table as long as the extensions/blocks being read have not been replaced or reallocated.

    It is therefore a problem for SOME ONLY.

  • implicit cursor and type oracle

    Hi all

    Is it possible to copy a rowtype of a cursor implicit to an oracle type?

    example of

    create or replace type test_123 (as_of_date date, number of contrat_number) as an object;

    declare

    help_ty test_123;

    Start

    for r1 in (select as_of_date, contract contracts) loop

    help_ty: = r1;

    end loop;

    end;

    It is said that it may not be possible, can you help me please?

    11g

    concerning

    Hello

    You can declare it in the Package specification and can use in the world through the database.

    As below

    create or replace package test_pkg
    is

    type is record (varchar2 (40) first_name, employee_id number);

    end;
    /

    declare

    l_rec test_pkg.emp_rec;

    Start

    for r1 in (select first_name, number of employees)
    loop

    l_rec: = r1;
    dbms_output.put_line (l_rec.first_name);

    end loop;

    end;
    /

    Post edited by: Suri - example added

  • Problem with cursor and Transactions

    Hi friends,

    I will carry out the sub set of orders where some records are removed as a transaction. If there is no problem with a set of transactions, this recordset is ignored and following Recordset is executed. With code below, if an error occurs in one of the statement, control passes to the exception block where it cancels the registration point and unwanted instructions are restored. So far so good. But the problem is execution stops here. I need to skip this record id and loop for remaining IDs. Help, please.


    create or replace PROCEDURE DeleteRecords
    AS
    SelectDate date: = SysDate () - 27;
    NRTSI varchar2 (100);
    CURSOR c_TrnInfoNull IS select id from trn_info where CREATED_TISTMP < SelectDate and trn_tistmp is set to null;
    BEGIN

    FOR myrows IN c_TrnInfoNull LOOP
    SAVEPOINT TrnSavePointNull;
    delete from TRN_ERROR_DETAIL where TRN_INFO_ID = myrows.id;
    Select code from NRTSI from TRN_PYMT_DETAIL where trn_info_id = myrows.id;
    delete from TRN_PYMT_ADDNL_DATA where TRN_PYMT_DETAIL_ID = NRTSI;
    delete from TRN_PYMT_DETAIL where ID = NRTSI;
    delete from trn_info where id = myrows.id;
    COMMIT;
    END LOOP;

    EXCEPTION, THEN, THEN go BACK to TrnSavePointNull.
    DBMS_OUTPUT. Put_line (dbms_utility. FORMAT_ERROR_BACKTRACE());
    END;
    create or replace PROCEDURE DeleteRecords
    AS
    SelectDate date:= SysDate()-27;
    TRNID varchar2(100);
    CURSOR c_TrnInfoNull IS select id from trn_info where CREATED_TISTMP
    
  • How to choose the maximum value in a column of a table by using the cursor and iteration

    Hello everyone
    I have a table loan_detail
    and a column inside loan_amount
    now I want to take the values in this table with the cursor, then using iteration that I want to take a max value of him using this slider
    Here is my table
    LOAN_AMOUNT
    
    100
    200
    300
    400
    500
    5600
    700
    I could make using the concepts of single loop, but when I tried to do by using the slider I wasn't able to do.
    Concerning
    Prost

    You can get the maximum value for a particular column in SQL, PLSQL needn't; Always avoid PLSQL so you can do it in SQL. But always as an example:

    declare
    number of Temp: = 0;
    Start
    for news in some loan_amt of loan_detail
    loop
    If (temp
    end if;
    end loop;
    dbms_output.put_line (temp);
    end;

    Edited by: Mahanam January 5, 2011 03:11

  • How to put a table as parameter name in the name of the cursor and the header as a variable?

    Hello

    I have the code:
    create or replace procedure transpose_table_row2column(table_source IN VARCHAR2 ,table_result IN VARCHAR2) is
    
    -- set serveroutput on;
    
    v_nazwa_kamp      varchar2(100);
    v_czas_start      date;
    v_czas_stop       date;
    err_code          varchar2(50);
    err_msg           varchar2(2000);
    
    cmd_1_drop        varchar2(50);
    cnt_1             pls_integer;
    cnt_2             pls_integer;
    cnt_3             pls_integer;
    cnt_4             pls_integer;
    v_col_name        varchar2(50);
    test              varchar2(5);
    
    -- deklaracja wyjatku dla nieistniejacej lub niedostepnej tabeli
    TableDoesNotExist     EXCEPTION;
    PRAGMA EXCEPTION_INIT(TableDoesNotExist, -942);
    
    -- nazwa pierwszej kolumny tabeli zrodlowej
    cursor first_column is
        SELECT column_name FROM USER_TAB_COLUMNS WHERE TABLE_NAME = upper(table_source) and column_id = 1;
    
    -- wartosci z pierwszej kolumny tabeli zrodlowej
    cursor first_col_data_header is
           select v_col_name from table_source;
    
    
    
    begin
    
    test := 'true';
    v_nazwa_kamp := 'transpose_table_row2column';
    v_czas_start := sysdate;
    
    
    -- sprawdzenie czy istnieje tabela zrodlowa
    BEGIN
             EXECUTE IMMEDIATE 'SELECT count(*) FROM ' || table_source INTO cnt_4;
    EXCEPTION
             WHEN TableDoesNotExist
             THEN
                 test := 'false';
                 err_code := SQLCODE;
                 err_msg := substr(SQLERRM, 1, 2000);
                 INSERT INTO log_errors (time_err, object_name, campaign_name, error_number, error_message)
                 VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
                 COMMIT;
             
             WHEN NO_DATA_FOUND
             THEN
                 test := 'false';
                 err_code := SQLCODE;
                 err_msg := substr(SQLERRM, 1, 2000);
                 INSERT INTO log_errors (time_err, object_name, campaign_name, error_number, error_message)
                 VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
                 COMMIT;
                 
             WHEN OTHERS
             THEN
                 test := 'false';
                 err_code := SQLCODE;
                 err_msg := substr(SQLERRM, 1, 2000);
                 INSERT INTO log_errors (time_err, object_name, campaign_name, error_number, error_message)
                 VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
                 COMMIT;
    END;
    
    
    
    -- jesli istnieje tabela zrodlowa to przetwarzamy
    if test = 'true' then 
    
    
    
    -- pobieram nazwe pierwszej kolumny tabeli zrodlowej
    for v_first_column in first_column
    loop
      v_col_name := v_first_column.column_name;
    end loop;
    
    
    -- sprawdzenie czy istnieje tabela docelowa, jesli tak to trzeba usunac
    select count(*) into cnt_1 from user_tables t
    where t.table_name = upper(table_result);
    
    -- jesli istnieje tabela docelowa to usuwamy
    if cnt_1 > 0 then
       cmd_1_drop := 'DROP TABLE ' || table_result;
       execute immediate cmd_1_drop;
    end if;
    
    
    
    -- pobranie liczby wierszy tabeli zrodlowej - nalezy stworzyc tyle samo kolumn w tabeli docelowej
    -- ponizej sprawdzenie czy w pierwszej kolumnie tabeli zrodlowej sa unikalne wartosci - jesli nie to nie mozna 
    -- transponowac tabeli poniewaz musi ona miec te wartosci jako naglowki nowej tabeli i musza wystepowac one tylko 1 raz
    execute immediate 'select count(' || v_col_name || ') from ' || table_source into cnt_2; 
    execute immediate 'select count(distinct ' || v_col_name || ') from ' || table_source into cnt_3; 
    
    
    -- jesli wartosci w 1 kolumnie sa unikalne to przetwarzamy dalej
    if cnt_2 = cnt_3 then
    
    
    
    -- tutaj rozpoczynamy odczytywanie tabeli zrodlowej i tworzenie nowej przetransponowanej tabeli
    
    for v_first_col_data_header in first_col_data_header
    loop
      DBMS_OUTPUT.PUT_LINE(': ' || v_first_col_data_header.v_col_name);
    end loop;
    
    
    
    
    
    
    
    
    v_czas_stop:= sysdate;
    
    insert into log_campaigns (campaign_name, time_start, time_stop, records_count, time_diff_min)
    values (v_nazwa_kamp, v_czas_start, v_czas_stop, cnt_2, round((v_czas_stop - v_czas_start) * 24 * 60, 2));
    commit;
    
    
    end if;
    end if;
    
    
    EXCEPTION
           WHEN OTHERS THEN
              err_code := SQLCODE;
              err_msg := substr(SQLERRM, 1, 2000);
    
              INSERT INTO log_errors (time_err, object_name, campaign_name, error_number, error_message)
              VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
              COMMIT;
    
    end transpose_table_row2column;
    and I don't know how to create the slider:
    cursor first_col_data_header is
           select v_col_name from table_source;
    I have error this table does not exist
    because table_name is the name of the parameter and v_col_name is variable which I initialize later in the code:
    for v_first_column in first_column
    loop
      v_col_name := v_first_column.column_name;
    end loop;
    Thanks for help

    Here is the code you are looking for:

    create or replace procedure transpose_table_row2column (table_source IN VARCHAR2, table_result IN VARCHAR2) is

    -set serveroutput on;

    v_nazwa_kamp varchar2 (100);
    date of v_czas_start;
    date of v_czas_stop;
    err_code varchar2 (50);
    err_msg varchar2 (2000);

    cmd_1_drop varchar2 (50);
    cnt_1 pls_integer;
    cnt_2 pls_integer;
    cnt_3 pls_integer;
    cnt_4 pls_integer;
    v_col_name varchar2 (50);
    test varchar2 (5);

    -deklaracja wyjatku dla nieistniejacej lub niedostepnej tabeli
    TableDoesNotExist EXCEPTION;
    PRAGMA EXCEPTION_INIT (TableDoesNotExist,-942);

    -name pierwszej kolumny tabeli zrodlowej
    l_first_column varchar2 (32767): = 'SELECT column_name FROM USER_TAB_COLUMNS WHERE TABLE_NAME = upper(:table_source) and column_id = 1';

    -z pierwszej kolumny tabeli zrodlowej wartosci
    l_first_col_data_header varchar2 (32767).
    first_col_data_header sys_refcursor;
    l_first_col_data varchar2 (32767).

    Start

    test: = "true";
    v_nazwa_kamp: = 'transpose_table_row2column ';
    v_czas_start: = sysdate;

    -sprawdzenie czy istnieje image zrodlowa
    BEGIN
    EXECUTE IMMEDIATE ' SELECT count (*) FROM "| table_source INTO cnt_4;
    EXCEPTION
    WHEN TableDoesNotExist
    THEN
    test: = "false";
    err_code: = SQLCODE;
    err_msg: = substr (SQLERRM, 1, 2000);
    INSERT INTO log_errors (campaign_name, time_err, object_name, error_message, error_number)
    VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
    COMMIT;

    WHEN NO_DATA_FOUND
    THEN
    test: = "false";
    err_code: = SQLCODE;
    err_msg: = substr (SQLERRM, 1, 2000);
    INSERT INTO log_errors (campaign_name, time_err, object_name, error_message, error_number)
    VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
    COMMIT;

    WHILE OTHERS
    THEN
    test: = "false";
    err_code: = SQLCODE;
    err_msg: = substr (SQLERRM, 1, 2000);
    INSERT INTO log_errors (campaign_name, time_err, object_name, error_message, error_number)
    VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
    COMMIT;

    END;

    -jesli istnieje image zrodlowa at przetwarzamy
    If test = "true", then

    -pobieram nazwe pierwszej kolumny tabeli zrodlowej
    run immediately l_first_column in v_col_name using table_source;

    -sprawdzenie czy istnieje image docelowa, tak jesli to trzeba usunac
    Select count (*) in the user_tables cnt_1 t
    where t.table_name = upper (table_result);

    -jesli istnieje image docelowa at usuwamy
    If cnt_1 > 0 then
    cmd_1_drop: = 'DROP TABLE ' | table_result;
    immediately run cmd_1_drop;
    end if;

    -pobranie liczby wierszy tabeli zrodlowej - nalezy stworzyc tyle samo kolumn tabeli w docelowej
    -czy sprawdzenie ponizej w pierwszej kolumnie zrodlowej his unikalne wartosci tabeli - jesli nie to nie mozna
    -transponowac tabeli poniewaz musi ona IMCs you wartosci tabeli nowej naglowki jako I musza wystepowac a tylko 1 raz
    run immediately "select count (' |)" v_col_name | ') de ' || table_source in cnt_2;
    run immediately "select count (distinct ' |)" v_col_name | ') de ' || table_source in cnt_3;

    -jesli wartosci w 1 kolumnie his unikalne to przetwarzamy dalej
    If cnt_2 = cnt_3 then

    -tutaj rozpoczynamy tabeli zrodlowej odczytywanie I create nowej przetransponowanej tabeli
    l_first_col_data_header: = 'choose ' | v_col_name | 'from ' | table_source;
    Open the first_col_data_header for l_first_col_data_header;
    loop
    extract the first_col_data_header in l_first_col_data;
    When the output first_col_data_header % notfound;
    DBMS_OUTPUT. Put_line (': ' | l_first_col_data);
    end loop;

    v_czas_stop: = sysdate;

    insert into log_campaigns (campaign_name time_start time_stop, records_count, time_diff_min)
    values (v_nazwa_kamp, v_czas_start, v_czas_stop, cnt_2, round ((v_czas_stop-v_czas_start) * 24 * 60, 2));
    commit;

    end if;
    end if;

    EXCEPTION
    WHILE OTHERS THEN
    err_code: = SQLCODE;
    err_msg: = substr (SQLERRM, 1, 2000);

    INSERT INTO log_errors (campaign_name, time_err, object_name, error_message, error_number)

    VALUES (sysdate, 'transpose_table_row2column', v_nazwa_kamp, err_code, err_msg);
    COMMIT;

    end transpose_table_row2column;

  • cursor and its problems

    create or replace package test1 is

    type rec_DropDownList_Item is MADE
    (
    VARCHAR2 (200) TEXT.
    xsVALUE VARCHAR2 (200));

    TYPE cur_DropDownList IS REF CURSOR RETURN rec_DropDownList_Item;

    procedure Getprocedure_yearreportdisplay (my_rec_parameter rec_DropDownList_Item) is

    cursor c1_ptr is

    Select 'x' as a TEXT, 'y' as xsVALUE from dual;

    Start

    Open c1_ptr;
    extract the c1_ptr in my_rec;
    If found then % c1_ptr
    c1_ptr;

    If c1_ptr % notfound then

    Dbms_Output.put_line ("' big mistake");
    end if;
    close c1_ptr;

    end Getprocedure_yearreportdisplay;
    end Test1;

    I try to create a slider that refers to a record and have this slider back, so that I can use it in c# ti display the simple, but I'm getting several errors. See the above code. Thank you.

    remove the double post...

    Published by: odie_63 on May 22, 2010 12:53

Maybe you are looking for

  • How can I change where firefox stores the logs?

    I run 'Fox on a flash drive, because it allows me to keep my history, bookmarks, etc. all together while using ' Fox on several different computers. I learned recently that Firefox was leaving newspapers on the hard drives of each computer, that I ra

  • Re: Satellite L505-S5967 - Display driver for Win7 32 bit

    I need display driver for Satellite L505 S5967 for Win7 32-bit because I can't find it on the siteI can not even find my model of my laptop and when I try to search by series said num num of invalid series so kindly advise

  • Phone call on computer viruses

    I was called today by a man with an Indian accent, claiming to be "Microsoft Services." He told me that my computer has malicious files, and I had to leave to help solve the problem. I asked for his phone number I could call him back if disconnected

  • Volume of Windows 7

    Hello I had this problem with the volume on Windows 7 Home Premium, recently (today), I started my computer as usual nothing out of the ordinary and went to change the volume, when I clicked on the icon there was a brief loading times and then nothin

  • Call the Manager greeting of maximum length?

    Can someone tell the maximum length of the salutation for a call handler?... Thank you!!