How a Variable are assigned just by being declared.

Hello

I'm new here. We use the Oracle 11.2. I have a question of PL/SQL.

There is code below that takes variables in the DECLARE section and declares the variable v_sum_prcs_end that see you it used in the following select statement.

Is there WAY TO this variable might have gotten one assignment by default other than NULL if not initialized? This variable is not mentioned anywhere before in this procedure. It is a procedure doesn't not part of a package.
          LOOP
               <<Execute_Rule>>
               DECLARE
               v_sum_prcs_start DATE := TO_DATE ('19000101', 'YYYYMMDD');
               v_sum_prcs_end DATE;

               CURSOR PRD_DIM IS
                    SELECT *
                    FROM (
                         SELECT *
                         FROM (
                                SELECT *
                                FROM PRD_DIM_SRC
                                WHERE wk_ending_dt BETWEEN v_sum_prcs_end - ((v_row_PRD_DIM_RUL.span_num_wks * 7) - 7 ) AND v_sum_prcs_end
                                ORDER BY wk_ending_dt)
                         WHERE ROWNUM <= v_row_PRD_DIM_RUL.max_num_wks)
                    WHERE wk_ending_dt > v_sum_prcs_start
                    ORDER BY wk_ending_dt ASC;
It is in a loop, as you can see, and he get initialized after this. Of course when the loop returns once again, it will have a value, but at the first pass, it is just ZERO? and if so the query returns all rows?

Thank you

Hello

963236 wrote:
Hello

I'm new here. We use the Oracle 11.2. I have a question of PL/SQL.

Whenever you have any questions, please post a complete script that people can use to recreate the problem and test their ideas. Include a full procedure or ananoymous PL/SQL block, and, if it is a procedure or a function, the code that calls it. Include CREATE TABLE and INSERT all necessary tables for instructions. See the FAQ forum<>
Simplify the code you post as much as possible. In this case, the problem seems to depend on if or how a DATE variable to get the value before using a cursor. You can probably show only with a slider to 5 lines, without any of subqueries, using the column hiredate in scott.emp, which is widely available, so you don't have to post CREATE TABLE and INSERT statements for her.

There is code below that takes variables in the DECLARE section and declares the variable v_sum_prcs_end that see you it used in the following select statement.

Is there WAY TO this variable might have gotten one assignment by default other than NULL if not initialized? This variable is not mentioned anywhere before in this procedure. It is a procedure doesn't not part of a package.

What you are showing is the DECLARE section. You're not showing how the cursor is open. If v_sum_prcs_end has a value when the cursor is actually used, then you must be giving the value before opening the cursor. (Add a few calls to dbms_output.put_line to display its values at various points in the code.) If there is nothing mysterious past, it will happen in the BEGIN section, which has no validation, and not DECLARE section.

The only ways I know to which gives a value to a variable in a PL/SQL are:
(1) using the variable on the left side of the: operator, =
(2) use it in the clause of SELECT INTO... IN
(3) if it is an argument, which gives a default value (which is clearly not the case in this issue.)
(4) use it as an OUT or IN ARGUMENT to another procedure. (This is not really a separate way to set the value, because the procudeure must assign the new value using first 3 methods, or call another procedure that does.)
Again, if the variable has a value when you open the slider, then I think you're one of the foregoing, before opening the cursor.

Moreover, why you open a cursor inside a loop? There is almost always a more efficient way to get rid of the loop and do everything in the cursor. Like a lot of work as long as you can in the SQL statement and only use PL/SQL constructs, such as loops, when there is no other choice.

Tags: Database

Similar Questions

  • How drive letters are assigned to external drives and file path names?

    How drive letters are assigned to external drives and file path names? MyBook is a drive letter (M) when it is connected to my desktop computer and another letter (L) when it is connected to my husbands office, USB key has the same letter, no matter what usb port is used. Is the letter assigned when the file is created and does not change? or is it to the port to which it is connected to? in what computer?

    Each computer assigns the player to the first drive letter not used in alphabetical order.  It makes no difference what port it connects to.

    Boulder computer Maven
    Most Microsoft Valuable Professional

  • You can wrap text around a picture in E10 by using the rich editor? You cannot superimpose an image and an area of just text, so how would this work?

    You can wrap text around a picture in E10 by using the rich editor? You cannot superimpose an image and an area of just text, so how would this work?

    Amy,

    You must place the image in the text box to wrap around him, or a heavier way test, you can use text several boxes and place them strategically around the image, but if you want to hyperlink the image you have to place it inside the text box and you can not overlap images and text in e-mail boxes.

    Hope this helps,

    Leigh

  • Satellite L650 - 1 k 2 - How many watts are the speakers?

    I got the l650 1 k 2 with "Toshiba Bass Enhanced Sound System puts Dolby® Audio advanced" but how many watts are the speakers?

    Hi mate

    There is no details about watt speaker.
    I found just the notice that it's stereo speakers

  • Global variables are accessible from the local computer

    While he was trying to use RT project, I can deploy the file to the RT target and communicate with the host using a shared variable.

    But the host VI file returns an error stating that the shared in the pattern-block VI host variable is illegal.

    (RT.lvib\Link reqd\ 'shared variable' node is illegal)

    It also gives a description mentioning that global variables are accessible only to local machines.

    What is the cure?

    Hi Shan21,

    I think your problem with communication between the aim of RT and the host PC might be caused by how your deployment of your variables. Please take a look at the following and let me know what you think,

    Kind regards

    ******************************************************************************************************************************************

    When you make the executable of a project using shared variables, you must have a local copy of the variables on the deployment computer that are then linked to the 'real' shared variables stored on the target - cRIO, in this case.

    This means that the display of your project should look like this:

    Note: Two libraries, which can have variables with the same name because they aren't both on the local computer.

    The steps required are:

    1. create variables shared in the normal Manor on the cRIO:

    a. right click on the target
    b. new > Variable
    c. properties of the variables enter the name (stop); Data type (Boolean) and the Variable type (always in network-published).

    2. create variables shared on the host PC:
    a. follow the steps 1 a - c
    b. right click on the box to enable anti-aliasing

    c. linking to the URL of the PSP, click on Browse - and select variable on the target:

    d. click Ok.

    Note: Remember also to deploy the shared manually variable llb. See the related links for more information.

    It's from a base of knowledge to write soon.

    Note:3UCBHM8T knowledge base: how to deploy network Variables shared a compiled executable

  • How can I open .doc files without being encrypted?

    original title: open .doc files

    How can I open .doc files without being encrypted?

    How can I open .doc files without being encrypted?

    What program are you trying to open them in? If you don't have MS Word, then you need this program.

    Word Viewer
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=3657CE88-7CFA-457A-9AEC-F4F827F20CAC&displaylang=en

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • How to remove private photos just returns

    How to remove private photos just returns

    Unwanted duplicates have file names
    who are before of "copy of".

    If Yes, they are created when you multiple
    Select all in now the Ctrl or Shift keys. If the
    you drag (even a single selected group
    bit) when you release the mouse button... copies
    all photos will be displayed.

    Just to check... Here's how to reproduce the
    the unwanted copying...

    Hold down your CTRL key and select multiple files...

    Place your pointer over the selected group
    (holding the key ctrl) and left click / drag
    the group even just the slightest bit... now
    release the mouse button. (what happens by)
    accident in the quick selection of the files)

    Duplicates 'Copy of xxx.jpg' will appear.

  • How the records are selected in the database

    Hello

    How the records are selected in the database


    Thank you.

    Read articles on JDBC, here is what I understand...

    If I set LignesMax = 1 (in out select adapter DB) and I have 30 record in the table that satisfy the select query then what line is picked up? the first in the table or randomly any folder?

    The query returns the first line of the result set.  Not just a random line.  However, to get the rows to return in the result set in a specific order, you must include an order by clause, or the query will return rows in random order.

    And if I set LignesMax = 0 (unbounded, means any number registration) in this case if my select query satisfy 100 million documents so all million records will be picked up once, in one cycle?

    The answer to this depends on the size of the extraction of the query.  If the size of the extraction is > = 100 million, everything goes back in a single cycle of the DB.  If< 100="" million,="" then="" it="" will="" be="" divided="" into="" multiple="" trips="" to="" the="">

  • Actions and Variables are duplicated when I create the new model project

    My organization uses a standard model for our courses.  In this model, I added a few variables and advanced actions to enable to the learner to customize the course a bit and support our "test-out" option

    What I found however, is that when I create a new project of this model that all stocks advanced and variable are... reproduce some several times.

    And ideas on how to make this stop?

    Jay

    Unfortunately, this is a known issue.  I pointed out about it here:

    Problems of duplication in Adobe Captivate Cp7 Cp8 Templates | Infosemantics Pty Ltd

    As far as I know, the problem persists even in Captivate 9 If you create a template that has advanced Actions, and these actions are used by no slides in this model.  When you create a file CPTX of this model, Variables and advanced Actions are duplicated by about the same number of times that the advanced initial Action is used.

    You can test this by creating a simple project with two blades, a variable and a Standard Action that affects this variable with values. Define the event on slide enter on the second slide to run the Standard Action. Save the project as a model CPTL and then use this model to start another project CPTX file.  When you check the list of Variables and advanced Actions you will find that there is a duplicate of each.

  • I can't reinstall or uninstall CS4 on Windows 7. I get a message indicating one or more CS4 applications are running and neet being closed, which is not.

    How can I reinstall or uninstall CS4 on Windows 7. I get a message indicating one or more CS4 applications are running and neet being closed, which is not.

    Hello

    Please close the process below the monitor activity/task manager and try again:

    Kind regards

    Sheena

  • Reports of ventilation are grayed out despite being member of more Adobe, please help

    Reports of ventilation are grayed out despite being member of more Adobe, please help.  Don't know how to access or why they are greyed out both in the project and authorizing sections.

    Yes that's correct. If the project has been drafted by a story only (free) account holder and then shared with you, you will not be able to access the functions of production. You need create the project to access these features. Unlike those with which share you your project must have Story more to access these features of production. Are they only (free) story, then it's a no-go. Sorry Ryan, I assumed that you were the author.

  • Please help: why my variables are not displayed in the subtemplate?

    Hi all

    We use BEEP 11.1.1.6 (build 5.12.110)

    We have several models of rtf and some with templates.

    In this case, I declared a variable var1 in the upper part of the main model.
    I also said variable var2 in the subtemplate.

    In the subtemplate, I added this command:
    var1:<?xdoxslt:get_variable($_XDOCTX, 'var1')?>
    var2:<?xdoxslt:get_variable($_XDOCTX, 'var2')?>
    var2 always displays normally.
    var1 is always null (RC = NaN when I pass it as a parameter to the submodel)
    The value appears correctly the second main folder of XML data.


    Is there something wrong in my code?
    Is there a reason why the variable is NULL in the first record of the main loop?

    Please find attached an example with different variables and params:
    https://FTS.Capgemini.com/pubpwd/66814124735400/XML_Publisher_test.zip link is valid until 2013-05-13 13:00 UTC (access with local public password)
    Username: ijtzggnrz
    Password: uP8YrdRPKc

    I hope my explanation is clear.
    Thanks in advance,
    Olivier

    Look at the response of amri in Obtaining Variable in footer of RTF
    >
    Variables when declared in the body section are not available in the scope of the header/footer.
    So you can't put in the body section and see the same thing in the header/footer.

    I think you want to have the header/footer conditional for some sets of pages. If you can explain your condition here we offer if this is possible.
    >

    and the response of the Vetsrini in the use of variables within a foot of the RTF template
    >
    Footer is in a different context,

    If you will not be able to use the variable declared in the page inside the footer,

    try to create a sample footer variable is assign a value and displays
    you will be able to display that correctly...

  • How to do the updates just announced for Photoshop CC?

    How can I get updates just announced for Photoshop CC because my version is 14.2.1 x 64 and also shows to date. However, there is no sign of the new direction selection tool or fuzzy, etc. in the program.

    You should have seen a lot of updates in the application creative cloud with the label '2014' after them. Once download you them, they are actually quite distinct from the installed instances, so you will have both 'Adobe Photoshop CC' and 'Adobe Photoshop CC 2014 "on your system. Be sure to run the version of 2014 to see what's new.

  • Asked what games are assigned to responsibilities

    Is it possible to use PLSQL to shoot the sets to which are assigned to our custom responsibilities? I found the table FND_REQUEST_GROUP_UNITS but am looking on how to assemble the code to remove the name of responsibility, asks for the value name, and any other relevant information.

    Any help would be appreciated.

    Thank you

    You are nearby.
    Try
    >
    SELECT e.application_id, a.responsibility_id, a.responsibility_name,
    b.request_group_id, c.request_group_name,
    e.user_request_set_name, e.description
    Fnd_responsibility_tl a.,
    b fnd_responsibility,
    fnd_request_groups c,
    fnd_request_group_units d,
    e fnd_request_sets_tl
    WHERE a.LANGUAGE = 'en '.
    AND a.responsibility_id = b.responsibility_id
    AND b.request_group_id = c.request_group_id
    AND c.request_group_id = d.request_group_id
    AND e.request_set_id = d.request_unit_id
    AND e.LANGUAGE = 'Fr '.
    AND a.responsibility_name = '< name="" of="" custom="" responsibility="">'

  • ORA-01008 that not all variables are related

    Hi I have a question for follwing procedure
    DECLARE 
    V_ERR_CODE VARCHAR2(1);
    V_ERR_DESC VARCHAR2(250);
    V_CC_NO VARCHAR2(20);
    STR VARCHAR2(4000);
    CURSOR C1 IS
       SELECT *  FROM TABLE_S;
    
    C1_REC C1%ROWTYPE;
    
    BEGIN
    STR := 'INSERT INTO P_1(A,B,C) VALUES(c1_rec.cc_no, :V_ERR_CODE, :V_ERR_DESC)';
    FOR C1_REC IN C1
    LOOP
    IF CHKSTR_CHG_PRIV_IND_VAL(C1_REC.C1) = 1 THEN
    V_ERR_CODE := 'O';
    V_ERR_DESC := 'CHARGING  NOT IN Y,N';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_NULL_VAL (C1_REC.c2) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'OPEN DATE  IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_NULL_VAL (C1_REC.SSN) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'SOCIAL SECURITY NUMBER IS NULL';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NULL_VAL (C1_REC.FIRST_NAME) = 1 THEN
    V_ERR_CODE := 'O';
    V_ERR_DESC := 'FIRST NAME IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_NULL_VAL (C1_REC.SURNAME) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'LAST NAME IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_LOST(C1_REC.c3) = 1 THEN
    V_ERR_CODE := 'O';
    V_ERR_DESC := 'LOST  IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NULL_VAL (C1_REC.DOB) = 1 THEN
    V_ERR_CODE := 'O';
    V_ERR_DESC := 'DATE OF BRITH IS NULL';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    
    IF CHKSTR_CC_NO_LENGTH (C1_REC.CC_NO) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'CREDIT CARD LENGTH IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_NUMERIC_VAL  (C1_REC.CC_NO) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'CREDIT CARD IS NON NUMERIC';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMERIC_VAL  (C1_REC.SSN) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'SOCIAL SECURITY NUMBER IS NON NUMERIC';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_SSN_LENGTH (C1_REC.SSN) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'SOCIAL SECURITY NUMBER LENGTH IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_CC_NO_VAL(C1_REC.CC_NO) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'CREDIT CARD <> 4264 AND <> 4313';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_DATE(C1_REC.DOB) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'DATE OF BIRTH IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_DATE(C1_REC.OPEN_DATE) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'OPEN DATE (ISSUE DATE) IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    
    IF CHKSTR_DATE(C1_REC.c4) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' CHANGE DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_DATE(C1_REC.c5) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'CODE CHANGE DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_DATE(C1_REC.c6) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'REISSUE DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_DATE(C1_REC.dDATE) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' PAYMENT DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_DATE(C1_REC.DATE) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'LAST ACTIVITY DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_DATE(C1_REC.c7) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' PAYMENT DUE DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_DATE(C1_REC.c8) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'CONVERSION DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_DATE(C1_REC.c9) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'TRANSFER DATE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.LIMIT) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' LIMIT IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    
    IF CHKSTR_NUMBER (C1_REC.TOTAL) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'TRANSACTION TOTAL  IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.c10) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'c10 TOTAL IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.c11) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'c11 TRANSACTION IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.c12) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'c12 TRANSACTION IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.c13) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'c13 TOTAL IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.AMT) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' AMOUNT IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.BALANCE) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := ' BALANCE IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.CARDS) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'NUMBER OF CARDS IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    
    IF CHKSTR_NUMBER (C1_REC.c14_CARDS) = 1 THEN
    V_ERR_CODE := 'M';
    V_ERR_DESC := 'c_14 NUMBER OF CARDS  IS WRONG';
    EXECUTE IMMEDIATE STR;
    END IF;
    COMMIT;
    END LOOP;
    END;
    I get following error when I try to run
    ORA-01008 that not all variables are related
    Table (p)
    a varchar (20),
    b varchar (1).
    c varchar2 (250))

    also there are 50 columns to 3 not only inserted but the column values for the other will be the same for all conditions. then to test, I added only 3 columns.

    Please help me how can I solve this problem...
    Thank you very much

    Published by: user10647455 on January 14, 2009 14:04

    Change your code to:
    ...
    EXECUTE IMMEDIATE STR WITH THE HELP OF V_ERR_CODE, V_ERR_DESC;
    ...

    Explanation:
    Dynamic SQL bind variables using variable names.
    in your case
    STR: = "INSERT INTO P_1 (A, B, C) VALUES (c1_rec.cc_no,: V_ERR_CODE,: V_ERR_DESC)";
    does not say that the variables: V_ERR_CODE,: V_ERR_DESC are automatically linked.
    In dynamic SQL variable binding is done using the syntax 'USE '.

    Look at:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/dynamic.htm#LNPLS01102

    HTH
    Thomas

Maybe you are looking for