How to call a variable in a SQL block?

Hello everyone.

I'm relatively new to the black magic of PL/SQL... I'm struggling with something that I think should be relatively easy. I hope someone can direct me as to where I'm wrong?

I have a SQL query that is basically divided into 5 different sections - all the union'ed. Each Union has a date condition in the FROM clause that requires a sub query. The sub itself query takes a long time to run, so rather than including 5 times in my code block - I think its probably much more effective to declare the output of the query to sub as a variable at the beginning of my script.

I managed to do it. What I am struggling with actually called the variable in my script SQL... Sort - the following code:

< code >
DECLARE
v_last_batch_date varchar (8);
BEGIN
SELECT MAX (C.FDP_DATA_DATE)
IN v_last_batch_date
OF TBL_DAILY_BALANCE C
WHERE C.FDP_DATA_DATE BETWEEN TO_CHAR (ADD_MONTHS (TRUNC (SYSDATE),-1), 'YYYYMM') | (' 25' AND TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE),-1)), 'YYYYMMDD'));
IMMEDIATE EXECUTION
'-UNION 1
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO > = 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES 0 OTHERWISE END) AS PROMO_CYCLES
Of
TBL_DIM_SECURITY, A.
E TBL_DIM_PRODUCT
WHERE
A.DSE_DATA_DATE = v_last_batch_date
AND A.DSE_X = E.DPT_Z
AND A.DSE_PLAN_CATEGORY = 'PURE '.
UNION ALL
-UNION 2
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO > = 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES 0 OTHERWISE END) AS PROMO_CYCLES,
Of
TBL_DIM_SECURITY HAS
E TBL_DIM_PRODUCT
WHERE
A.DSE_DATA_DATE = (SELECT MAX (C.FDP_DATA_DATE) OF BUSINT_OWNER. C TBL_FACT_DAILY_PLAN_BALANCE WHERE C.FDP_DATA_DATE BETWEEN TO_CHAR (ADD_MONTHS (TRUNC (SYSDATE),-1), 'YYYYMM') | (' 25' AND TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE),-1)), 'YYYYMMDD'))
AND A.DSE_X = E.DPT_Z
AND A.DSE_PLAN_CATEGORY = 'CC '.
UNION ALL
-UNION 3
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO > = 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES 0 OTHERWISE END) AS PROMO_CYCLES,
Of
TBL_DIM_SECURITY HAS
E TBL_DIM_PRODUCT
WHERE
A.DSE_DATA_DATE = v_last_batch_date
AND A.DSE_X = E.DPT_Z
AND A.DSE_PLAN_CATEGORY = 'BT '.
UNION ALL
-UNION 4
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO > = 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES 0 OTHERWISE END) AS PROMO_CYCLES,
Of
TBL_DIM_SECURITY HAS
E TBL_DIM_PRODUCT
WHERE
A.DSE_DATA_DATE = v_last_batch_date
AND A.DSE_X = E.DPT_Z
AND A.DSE_PLAN_CATEGORY = 'CA '.
UNION ALL
-UNION 5
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO > = 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES 0 OTHERWISE END) AS PROMO_CYCLES,
Of
TBL_DIM_SECURITY, A.
E TBL_DIM_PRODUCT
WHERE
A.DSE_DATA_DATE = v_last_batch_date
AND A.DSE_X = E.DPT_Z
AND A.DSE_PLAN_CATEGORY NOT IN ('PURE', 'CA', 'BT', 'CC')';
END;
< code >

I simplified the code SQL a bit just... someone can point me in the right direction, please?

Very much appreciated - and Merry Christmas!
Try running with

DECLARE
v_last_batch_date VARCHAR(8);
BEGIN
SELECT MAX(C.FDP_DATA_DATE)
INTO v_last_batch_date
FROM TBL_DAILY_BALANCE C
WHERE C.FDP_DATA_DATE BETWEEN TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE),-1),'YYYYMM')||'25' AND TO_CHAR(LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1)),'YYYYMMDD'));
EXECUTE IMMEDIATE'--- UNION 1
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO >= 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES ELSE 0 END) AS PROMO_CYCLES
FROM
TBL_DIM_SECURITY A,
TBL_DIM_PRODUCT E
WHERE
A.DSE_DATA_DATE =' || v_last_batch_date || '
AND A.DSE_X=E.DPT_Z
AND A.DSE_PLAN_CATEGORY = ''PUR''
UNION ALL
--- UNION 2
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO >= 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES ELSE 0 END) AS PROMO_CYCLES,
FROM
TBL_DIM_SECURITY A
TBL_DIM_PRODUCT E
WHERE
A.DSE_DATA_DATE = (SELECT MAX(C.FDP_DATA_DATE) FROM BUSINT_OWNER.TBL_FACT_DAILY_PLAN_BALANCE C WHERE C.FDP_DATA_DATE BETWEEN TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE),-1),''YYYYMM'')||''25'' AND TO_CHAR(LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1)),''YYYYMMDD''))
AND A.DSE_X=E.DPT_Z
AND A.DSE_PLAN_CATEGORY = ''CC''
UNION ALL
--- UNION 3
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO >= 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES ELSE 0 END) AS PROMO_CYCLES,
FROM
TBL_DIM_SECURITY A
TBL_DIM_PRODUCT E
WHERE
A.DSE_DATA_DATE = v_last_batch_date
AND A.DSE_X=E.DPT_Z
AND A.DSE_PLAN_CATEGORY = ''BT''
UNION ALL
--- UNION 4
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO >= 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES ELSE 0 END) AS PROMO_CYCLES,
FROM
TBL_DIM_SECURITY A
TBL_DIM_PRODUCT E
WHERE
A.DSE_DATA_DATE = ' || v_last_batch_date ||'
AND A.DSE_X=E.DPT_Z
AND A.DSE_PLAN_CATEGORY = ''CA''
UNION ALL
--- UNION 5
SELECT
(CASE WHEN A.MTHS_LFT_PUR_PROMO >= 0 THEN A.DTC_PKEY_PUR_PROMO_CYCLES ELSE 0 END) AS PROMO_CYCLES,
FROM
TBL_DIM_SECURITY A,
TBL_DIM_PRODUCT E
WHERE
A.DSE_DATA_DATE =' || v_last_batch_date || '
AND A.DSE_X=E.DPT_Z
AND A.DSE_PLAN_CATEGORY NOT IN ( ''PUR'',''CA'',''BT'',''CC'')';
END;

Tags: Database

Similar Questions

  • How to call the variables of the scene inside movieClips

    How to call the variables of the scene inside movieClips

    One way would be to use "MovieClip (root)" to target variables in the main timeline... MovieClip (root) .someVariable = someValue;

  • How can I use variable presentation logic SQL

    Hi Experts,

    How can I use variable SQL logical presentation. I need the exact syntax. Kindly help me to achieve this goal.

    "Time". "" Date "between the Date of 2014 '-1-17 'and Date' ' 2014-2-16

    Thanks in advance

    Asim

    It's done... We can use it in the logical query with the same syntax where we use in converting this filter as SQL...

  • How to assign the variable in the SQL script?

    I have the below running to generate the XML from the file.
    set long 100
    set pages 0
    set trimspool on
    set serveroutput on
    set echo off
    set terminal off
    variable out CLOB
    begin
            pack.proc('&&1','&&2',:out);
    end;
    /
    spool /dir/loc/file1.xml
    select :out from dual;
    spool off
    I'm queue in the order of the coil, the output to a file named file1.xml. I invoke this SQL script from a shell script, I will pass variable association 3rd since the shell script which I want to use in the file ' & & 3'.xml. Help me set this variable to the DIGITAL field in this SQL script and how can I add to the command of the coil?
    set long 100
    set pages 0
    set trimspool on
    set serveroutput on
    set echo off
    set terminal off
    variable out CLOB
    define var1='&1' -- to allow for more readable code
    define var2='&2'
    define var3 ='&3'
    begin
            pack.proc('&var1','&var2',:out);
    end;
    /
    spool /dir/loc/file&var3..xml -- note the substition variable has  . appended
    print out
    spool off
    

    ------------
    Sybrand Bakker
    Senior Oracle DBA

  • How to call a variable named "PI".

    I have a typedef that contains a variable named "PI" as the constant 3.1416... but it is an acronym for "information"... I can't rename it since it's a corporate typedef...

    If I need to call it from an expression, TestStand takes as the constant, but returns an error of syntax due to variable notation... example 'Step.Result.PI '.

    Is it possible to call it?

    Thank you

    Jim

    Finally, we found a solution,

    Locals.PI_Get = ThisContext.AsPropertyObject.GetValNumber("Step.Result.PI",0)

  • How to call the package from a SQL string function

    I create a SQL string in my c# application. Within the selection, I have a function call to a package in my diagram.

    ex.

    "Select id, package1.fncFormat (text) of tblText".

    If I run this within Oracle it works fine but when I run my application and the SQL runs the use of OracleDataReader I get


    «ORA-00904: "PACKAGE1".» ' FNCFORMAT': invalid identifier.

    Is this possible to do?

    It is a dynamic sql string that is built using many different options.

    Thanks for any help

    Do you run this application and directly on DB package by the same user?
    Check the privileges of the user on the application.

    Kind regards
    Bobin

  • How to call a Java method, pl/SQL from within ApEx

    I want to call a Java method, which I intend to use to add members to a collection at the ApEx of another source of data.



    How does one call a Java from ApEx method?



    Thank you

    Gregory


    Hello

    Curious, the link works fine for me.

    Anyway, here is another, a thread on AskTom site that addresses the basic concepts you need-

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:952229840241

    Hope this helps,

    John.
    --------------------------------------------
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    AWARDS: Don't forget to mark correct or useful posts on the forum, not only for my answers, but for everyone!

  • How to call a stored procedure PL/SQL of the Disqualification?

    I figured I could do this from a Groovy script but I am unable to make it work.

    Let's take the simplest scenario:

    At the end of a job, I have a need to call an once stored procedure that has no arguments.

    Translated by the logic of the stored procedure with Disqualification is not an option.

    If you must call it once at the end of a task, you must use the external task.

    If you call a procedure for each record, it can be done using a script.

  • How to call the nested in the SQL table collection

    Please see the example below, how to attach the collection vmi_emp with history_emp table

    CREATE or REPLACE type vmi_emp as an object

    (empno varchar2 (500),)

    Ename varchar2 (500),

    HireDate date,

    SAL number (20));

    CREATE or REPLACE type nested_emp is table of the vmi_emp;

    declare

    v_type nested_emp;

    Start

    Select vmi_emp (empno, ename, hiredate, sal)

    bulk collect into v_type from emp;

    ???????????????? Select * from history_emp a, b vmi_emp where a.empno = b.empno

    end loop;

    end;

    Select * from history_emp has, b table (v_type) where a.empno = b.empno

  • How to initialize the Java variable within pl/sql block in the ODi procedure

    I have a step in the procedure of odi that using oracle technology.

    I want to initialize the java variable inside that.

    Please help me for this.

    < @ if (odiRef.getOption ("USE_PUBADMIN_PARAM_TABLE").equals("1")) {@ >}

    DENIZ

    EH_FAILURE_MESSAGE_TEXT VARCHAR2 (4000);

    EH_FIXED_VERSION VARCHAR2 (4000);

    EH_ISSUE_TYPE VARCHAR2 (4000);

    EH_PRIORITY VARCHAR2 (4000);

    EH_SUMMARY VARCHAR2 (4000);

    EH_DESCRIPTION VARCHAR2 (4000);

    EH_PROJECT_ID VARCHAR2 (4000);

    EH_COMPONENT VARCHAR2 (4000);

    EH_AFFECTED_VERSION VARCHAR2 (4000);

    EH_CUSTOMPROPXML VARCHAR2 (4000);

    EH_LOG_JIRA VARCHAR2 (4000);

    EH_CONTINUE_ON_ERROR VARCHAR2 (4000);

    EH_SEND_MAIL_NOTIFICATION VARCHAR2 (4000);

    EH_NOTIFICATION_RECIPENTS VARCHAR2 (4000);

    EH_JIRAJARPATH VARCHAR2 (4000);

    BEGIN

    SELECT

    DECODE ('< % = odiRef.getOption ("FAILURE_MESSAGE_TEXT") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_FAILURE_MESSAGE_TEXT'),' < % = odiRef.getOption ("FAILURE_MESSAGE_TEXT") % >") IN EH_FAILURE_MESSAGE_TEXT.

    DECODE ('< % = odiRef.getOption ("FIXED_VERSION") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_FIXED_VERSION'),' < % = odiRef.getOption ("FIXED_VERSION") % >") IN EH_FIXED_VERSION.

    DECODE ('< % = odiRef.getOption ("ISSUE_TYPE") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_ISSUE_TYPE'),' < % = odiRef.getOption ("ISSUE_TYPE") % >") IN EH_ISSUE_TYPE.

    DECODE ('< % = odiRef.getOption ("PRIORITY") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_PRIORITY'),' < % = odiRef.getOption ("PRIORITY") % >") IN EH_PRIORITY.

    DECODE ('< % = odiRef.getOption ("SUMMARY") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_SUMMARY'),' < % = odiRef.getOption ("SUMMARY") % >") IN EH_SUMMARY.

    DECODE ('< % = odiRef.getOption ("DESCRIPTION") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_DESCRIPTION'),' < % = odiRef.getOption ('DESCRIPTION') % >") IN EH_DESCRIPTION.

    DECODE ('< % = odiRef.getOption ("project") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_PROJECT_ID'),' < % = odiRef.getOption ("project") % >") IN EH_PROJECT_ID.

    DECODE ('< % = odiRef.getOption ("ELEMENT") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_COMPONENT'),' < % = odiRef.getOption ('ELEMENT') % >") IN EH_COMPONENT.

    DECODE ('< % = odiRef.getOption ("AFFECTED_VERSION") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_AFFECTED_VERSION'),' < % = odiRef.getOption ("AFFECTED_VERSION") % >") IN EH_AFFECTED_VERSION.

    DECODE ('< % = odiRef.getOption ("CUSTOMPROPXML") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_CUSTOMPROPXML'),' < % = odiRef.getOption ("CUSTOMPROPXML") % >") IN EH_CUSTOMPROPXML.

    DECODE ('< % = odiRef.getOption ("LOG_JIRA") % >', '0', PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_LOG_JIRA'),' < % = odiRef.getOption ("LOG_JIRA") % >") IN EH_LOG_JIRA.

    Decode('%=odiRef.GetOption("CONTINUE_ON_ERROR") % > ', '0', PBA_PARAM_PKG. ("GET_PARAMETER ('EH_CONTINUE_ON_ERROR'),' < % = odiRef.getOption ("CONTINUE_ON_ERROR") % >") IN EH_CONTINUE_ON_ERROR.

    DECODE ('< % = odiRef.getOption ("SEND_MAIL_NOTIFICATION") % >', '0', PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_SEND_MAIL_NOTIFICATION'),' < % = odiRef.getOption ("SEND_MAIL_NOTIFICATION") % >") IN EH_SEND_MAIL_NOTIFICATION.

    DECODE ('< % = odiRef.getOption ("NOTIFICATION_RECIPENTS") % >', NULL, PBA_PARAM_PKG.) ("GET_PARAMETER ('EH_NOTIFICATION_RECIPENTS'),' < % = odiRef.getOption ("NOTIFICATION_RECIPENTS") % >") IN EH_NOTIFICATION_RECIPENTS.

    PBA_PARAM_PKG. GET_PARAMETER ('EH_JIRAJARPATH') IN EH_JIRAJARPATH

    Double;

    / * I want to start as it is below. idon't want to control user source and control target conecpt.

    Please help me to below concept.

    */

    < @.

    String V_EH_FAILURE_MESSAGE_TEXT = EH_FAILURE_MESSAGE_TEXT;

    String V_EH_FIXED_VERSION = EH_FIXED_VERSION;

    String V_EH_ISSUE_TYPE = EH_ISSUE_TYPE;

    String V_EH_PRIORITY = EH_PRIORITY;

    String V_EH_SUMMARY = EH_SUMMARY;

    String V_EH_DESCRIPTION = EH_DESCRIPTION;

    String V_EH_PROJECT_ID = EH_PROJECT_ID;

    String V_EH_COMPONENT = EH_COMPONENT;

    String V_EH_AFFECTED_VERSION = EH_AFFECTED_VERSION;

    String V_EH_CUSTOMPROPXML = EH_CUSTOMPROPXML;

    String V_EH_LOG_JIRA = EH_LOG_JIRA;

    String V_EH_CONTINUE_ON_ERROR = EH_CONTINUE_ON_ERROR;

    String V_EH_SEND_MAIL_NOTIFICATION = EH_SEND_MAIL_NOTIFICATION;

    String V_EH_NOTIFICATION_RECIPENTS = EH_NOTIFICATION_RECIPENTS;

    String V_EH_JIRAJARPATH = EH_JIRAJARPATH;

    @ >

    END;

    {< @} @ >

    I have corrected this problem. No need to search on that.

  • How to call two variables that are to keep several value in loop for

    Hello

    I have 4 point, two list and two checkbox select. ID and class Section are select list and student id and the id of the object are check .i want to insert more id then a topic in the table corresponding to the student id then a plus.

    for example. When I select the IDs of class 1 and section A then student of class 1 and section has come into student card (checkbox element) and all the object corresponding to the class 1 comes in the object id (item checkbox).

    now I want to insert several selected for what is, multiple student topics in at table when I press submit Button.

    My table is

    CREATE TABLE 'STUDENT_SUBJECT_DETAIL '.
    (NUMBER OF 'S_NO',
    NUMBER OF "STUDENT_ID,"
    VARCHAR2 (50) "SUBJECT_ID",.
    "SESION' VARCHAR2 (50)
    )
    /


    I use this Code

    DECLARE
    STU wwv_flow_global.vc_arr2;
    VOID wwv_flow_global.vc_arr2;

    Start
    STU: = wwv_flow_utilities.string_to_table(:P57_STUDENT_ID);
    SUB: = wwv_flow_utilities.string_to_table(:P57_SUBJECT_ID);
    I'm looping 1.STU.count
    I'm looping 1.SUB.count
    insert into STUDENT_SUBJECT_DETAIL
    values (CLA_SUB_ID_SEQ.nextval, Stu (i), (i) Sub,: p57_SESION);
    end loop;
    end loop;
    END;

    Published by: Ed on November 20, 2009 22:10
    DECLARE
        STU wwv_flow_global.vc_arr2;
        SUB wwv_flow_global.vc_arr2;
    BEGIN
        STU:= wwv_flow_utilities.string_to_table(:P57_STUDENT_ID);
        SUB := wwv_flow_utilities.string_to_table(:P57_SUBJECT_ID);
        FOR i in 1..STU.count LOOP
            FOR i in 1..SUB.count LOOP
                insert into STUDENT_SUBJECT_DETAIL
                values(CLA_SUB_ID_SEQ.nextval,STU(i),SUB(i),:p57_SESION);
            end loop;
        end loop;
    END;
    

    None good for me:

    1. you have 2 loops, and they are both using the variable I as a counter.
    2. your insert must be in the form: insert into table (column names) values (to be inserted)
    3. why not use a trigger to get the nextval in the sequence?

    Trent

    Published by: tr3nton on November 21, 2009 16:16

  • don't count elements in a variable within pl/sql block

    Hello

    I'm creating a pl/sql procedure
    declare
    ABC varchar2 (100): = '100, 20, 90';
    Start

    end;

    I want to use a loop for inside the begin-end block, such that it begins with 1 and goes up to the total no of elements in abc
    i.e. for i in 1.3 in the form abc now has the number 3.

    The value of the abc is not fixed it can have a 0r more numbers separated by a «,»

    So, how can I write that my select queries so that it returns me the number of the elements in abc.

    Thank you
    Olivier
    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    abc varchar2(100):='100,20,90';
      3    cursor cur_split is
      4      select regexp_substr(abc, '[^,]+', 1, rownum) as txt
      5      from   dual
      6      connect by rownum <= length(regexp_replace(abc,'[^,]'))+1;
      7  begin
      8    for i in cur_split
      9    loop
     10      dbms_output.put_line(i.txt);
     11    end loop;
     12* end;
    SQL> /
    100
    20
    90
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • How to declare variables in PL/SQL (dynamically)

    Hello

    Please inform me how can I declare variables in PL/SQL dynamically (I want used in other projects). I tried the following code, but this error

    SQL > /.
    declare
    *
    ERROR on line 1:
    ORA-06550: line 1, column 74:
    PL/SQL: ORA-00933: SQL not correctly completed command
    ORA-06550: line 1, column 35:
    PL/SQL: SQL statement ignored
    ORA-06512: at line 10

    -----------------------------------------
    This is the code.
    declare
    v_temp varchar2 (300);
    x varchar2 (20);
    y varchar2 (20);

    Start
    BBB: = "X varchar2 (20);"
    y : = '1' ;

    run immediately 'declare '.
    || v_temp
    || "start."
    || 'Select name '.
    || "Ali where id =: yy '.
    || ' x using the ' | There
    || ' ; '
    || ' end; ';
    end;

    concerning
    WAel

    user3098640 wrote:
    Hi, thanks a lot for all. OK I'll show you that I want to achieve. So please help me
    refer to the following table it consist of four columns and three rows.
    I only want to show the column that has a value of ZERO : like the following query

    Select REC1 IMAGE_VALUE where corr = 'x' and rec1 = '1';

    Do you want that ZERO or '1 '? Contradict you yourself.

    Good to see you're requirements are clear.

    in this case are easy, but in my case the columns may be more than 100 columns (this is will automatically create - already made the number of columns is not fixed but it start by REC1 REC2, REC3, REC4... etc)
    the question is How can I DISPLAY the columns containing only '1' for specfic "corr" is X, Y or Z in PL - SQL

    Why you have a table that automatically creates with an unknown number of columns?
    It of very bad database design and get the basics of the design by the window completely.

    When you say 'Show' to what it means? SQL and PL/SQL "shows" nothing, because it has no user interface. It simply processes the data, and if these data are not in a known structure at the time where the application has been designed, and all code must be dynamic to try to deal with it. It is simply false in many ways.

    A better structure would be something like this...

    SQL> create table image_value (corr varchar2(20), rec varchar2(10), rec_val varchar2(20));
    
    Table created.
    
    SQL>
    SQL> insert into image_value (corr, rec, rec_val) values ('X','REC1','1');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('X','REC2','0');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('X','REC3','0');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Y','REC1','0');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Y','REC2','1');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Y','REC3','1');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Z','REC1','1');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Z','REC2','0');
    
    1 row created.
    
    SQL> insert into image_value (corr, rec, rec_val) values ('Z','REC3','1');
    
    1 row created.
    
    SQL>
    SQL> commit;
    
    Commit complete.
    
    SQL>
    SQL> with r as (select '&Required_Corr' as req_corr from dual)
      2  --
      3  -- end of input
      4  --
      5  select corr
      6        ,max(decode(rn,1,rec)) as c1
      7        ,max(decode(rn,2,rec)) as c2
      8        ,max(decode(rn,3,rec)) as c3
      9        ,max(decode(rn,4,rec)) as c4
     10        ,max(decode(rn,5,rec)) as c5
     11        ,max(decode(rn,6,rec)) as c6
     12        ,max(decode(rn,7,rec)) as c7
     13        ,max(decode(rn,8,rec)) as c8
     14        ,max(decode(rn,9,rec)) as c9
     15        ,max(decode(rn,10,rec)) as c10
     16  from (
     17        select corr, rec, row_number() over (partition by corr order by rec) as rn
     18        from   image_value, r
     19        where  corr = req_corr
     20        and    rec_val = '1'
     21       )
     22  group by corr;
    Enter value for required_corr: X
    old   1: with r as (select '&Required_Corr' as req_corr from dual)
    new   1: with r as (select 'X' as req_corr from dual)
    
    CORR                 C1         C2         C3         C4         C5         C6         C7         C8         C9         C10
    -------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    X                    REC1
    
    SQL> /
    Enter value for required_corr: Y
    old   1: with r as (select '&Required_Corr' as req_corr from dual)
    new   1: with r as (select 'Y' as req_corr from dual)
    
    CORR                 C1         C2         C3         C4         C5         C6         C7         C8         C9         C10
    -------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    Y                    REC2       REC3
    
    SQL> /
    Enter value for required_corr: Z
    old   1: with r as (select '&Required_Corr' as req_corr from dual)
    new   1: with r as (select 'Z' as req_corr from dual)
    
    CORR                 C1         C2         C3         C4         C5         C6         C7         C8         C9         C10
    -------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    Z                    REC1       REC3
    
    SQL>
    

    And you support the maximum number of values REC you expect.

    Other than that, what you're really talking is a reporting requirement that requires that the data to be read once before, it is then processed and only the required data is queried with a second query. This can be done in PL/SQL using DBMS_SQL (or versions using EXECUTE IMMEDIATE), but really, that should be done by tools that are designed to query data then format and place based on the content of the reporting data.

    Yet, you have not really explained why you are trying to do. It's alright saying you are trying to achieve, but which does not justify as being the right way to do things. What you have shown us so far, is not how to design a database or application code.

  • How to call the procedure Oracle in ODI

    Hello

    I use ODI 10 g.

    Before you run the interface in a package, I wanted to place my procedure.

    I created the procedure in d/b (target)

    CREATE OR REPLACE PROCEDURE TEST_MY_NEW_PROCE
    AS
    BEGIN
    REMOVE FROM EMPLOYEE_TABLE
    WHERE EMPLOPYEE_ID LIKE '% P ';
    COMMIT;
    END;
    /

    The procedure works well in the target database.

    Now, before the execution of my interface, I want to run this procedure in my package. So can some please help me how to call this oracle (creation in target schema) ODI procedure and run it.

    Thank you.

    Hi, GRK,.

    You can create an ODI procedure, add one step, choose Oracle as technology and your target schema.
    Then just call it through a pl/sql block:

    BEGIN
     TEST_MY_NEW_PROCE;
    END;
    

    In your package, then drag this ODI procedure.

    Kind regards
    JeromeFr

  • Haow to call parent variables

    var some 'someone' is a few main.swf. MC:MovieClip.  MC in main.swf. IAM load a mainMenu.swf file in mc. How can call a variable in mainmenu.

    Your ad is a little cryptic to try to understand, for a general response is... normally, you can use MovieClip .someVariable (parent) to target a variable in the parent timeline.  If the swf file is located in a movieclip and you want the parent of the movieclip, then you would use MovieClip (parent.parent) .someVariable.  If the swf file is inside a charger inside the mc and you want to reach the parent of the mc, and then you use MovieClip (parent.parent.parent) .someVariable.

    Your best bet is to keep tying parents along until you hit the target you are aiming for.

Maybe you are looking for

  • Pavilion DV6 6154 TX: Problems after update to windows 10

    I upgraded my OS from windows edition laptop home premium windows 10. Then, I am facing so many problems with OS (black screen, striking cursor before start up and bluetooth disabled and not able to update to the new version of Bluetooth).So I think

  • HP C3180 printer

    Recently updated from Vista to 7 system. My C3180 printer not scan

  • Windows xp does not start Help!

    for some reason any start-up became very slow so I read on how to try & fix it.   all I did was remove the programs / files (?) depending on whether I was rarely used, I also read that made every thing on the net before removing: JAVA (TM) UPDATE 20

  • No NICs found on install

    I just bought a Linksys WRT160N router and the first task to load the program on my main computer has already encountered an obstacle. It says it cannot find a network adapter on my computer and I need to allow. My card work as I am on the net right

  • My PC will not restart or shut down

    Original title: problem with my pc HELO I would like to know why my pc won't restart or shut down. Can U help me?