PL/SQL parameter in fusion by using the clause

Hi all

I need to create a procedure where I use the Merge clause. However, by using the condition, I have to put value user_define (V_LOCALE_CD). This value checks table of locale and then to make a match with table of flex_labels_test.

There is no specific requirement and I don't have the test data.

My only question how do I use user set the value using the condition. Here is the procedure I created as follows.

create or replace the PROCEDURE UPSERT_FLEX_LABEL_3 (V_LOCALE_CD IN VARCHAR2,

V_VALUE IN VARCHAR2,

V_FIELDVALUE IN VARCHAR2,

V_FIELDNAME IN VARCHAR2,

V_TABLENAME IN VARCHAR2,

N_FLEX_TYPE NUMBER,

V_COLOR IN VARCHAR2 DEFAULT NULL,

N_IMAGE_LIBRARY_ID IN THE NUMBER DEFAULT NULL,

N_HIERARCHY_ID IN DEFAULT NUMBER 5237260000000000001,

N_IS_INHERITED IN THE DEFAULT NUMBER 1)

AS

L_COUNT NUMBER;

NUMBER OF N_LOCALE_ID;

NUMBER OF NN_HIERARCHY_ID: = 5237260000000000001;

NUMBER OF NN_IS_INHERITED: = 1;

NUMBER OF INSERTCOUNT;

UPDATECOUNT NUMBER;

NUMBER OF ERR_CODE;

ERR_MSG VARCHAR2 (100);

BEGIN

-SELECT ID IN N_LOCALE_ID OF PLACES WHERE LOCALE_CD = V_LOCALE_CD;

/ * IT WILL CHECK DUPLICATES, IF THEY ARE PRESENT, THEN IT WILL UPDATE RECORD ELSE IT WILL INSERT A NEW RECORD * /.

BEGIN

Merge into fl flex_labels_test

using (select locale id where locale_cd = V_LOCALE_CD) L

on (l.id = fl.locale_id)

When matched then

GAME UPDATE

HIERARCHY_ID = NVL (N_HIERARCHY_ID, NN_HIERARCHY_ID),

IS_INHERITED = NVL (N_IS_INHERITED, NN_IS_INHERITED),

FLEX_TYPE = N_FLEX_TYPE,

VALUE = V_VALUE,

IMAGE_LIBRARY_ID = N_IMAGE_LIBRARY_ID,

COLOR = V_COLOR

WHERE TABLENAME = V_TABLENAME

AND FIELDNAME = V_FIELDNAME

AND FIELDVALUE = V_FIELDVALUE

When not matched then

INSERT (HIERARCHY_ID, ID_PARAMETRES_REGIONAUX, IS_INHERITED, FLEX_TYPE, TABLENAME, FIELDNAME, FIELDVALUE, VALUE, IMAGE_LIBRARY_ID, COLOR)

VALUES (NVL (N_HIERARCHY_ID, NN_HIERARCHY_ID), N_LOCALE_ID, NVL (N_IS_INHERITED, NN_IS_INHERITED), N_FLEX_TYPE, V_TABLENAME, V_FIELDNAME, V_FIELDVALUE, V_VALUE, N_IMAGE_LIBRARY_ID, V_COLOR);

UPDATECOUNT: = NUMBER OF ROWS SQL %;

EXCEPTION

WHILE OTHERS THEN

ERR_CODE: = SQLCODE;

ERR_MSG: = SUBSTR (SQLERRM, 1, 200);

DBMS_OUTPUT. PUT_LINE ("ERRORS" |) ERR_CODE | ' AND ' | ERR_MSG);

END;

COMMIT;

DBMS_OUTPUT. PUT_LINE ('RECORD INSERTCOUNT =' |) NVL(INSERTCOUNT,0));

DBMS_OUTPUT. PUT_LINE (' UPDATECOUNT RECORD ='|) NVL(UPDATECOUNT,0));

EXCEPTION

WHEN NO_DATA_FOUND THEN

RAISE_APPLICATION_ERROR (-20001, "ID NOT FOUND REGIONAL SETTINGS");

END;

I guess that's what I was looking for. Thank you guys for your efforts.

FUSION using parameter variables

Tags: Database

Similar Questions

  • Selection of the list of clients using the clause "EXISTS".

    Dear all,

    I have 3 tables, say,

    TABLE1:

     

    CUST_CODE

    (PRIMARY KEY)

    CUST_NAME

    CUST_COUNTRY_CODE

    CUST_CITY_CODE

    CUST_AREA_CODE

    A

    CUST1

    COU1

    CIT1

    A1

    B

    CUST2

    COU2

    CIT2

    A2

    C

    CUST3

    COU2

    CIT2

    A3

    D

    CUST4

    COU3

    CIT4

    A4

    E

    CUST5

    COU3

    CIT5

    A5

    TABLE2

     

    STOCK_SYS_ID

    (PRIMARY KEY)

    STOCK_CUSTOMER_CODE

    STOCK_CUSTOMER_

    COU_CODE

    STOCK_

    CUSTOMER_

    CIT_CODE

    STOCK_

    CUSTOMER_

    ARE_CODE

    STOCK_DOC_

    CREATED

    1

    A

    [Leaving empty as we have reference only to the customers and the date here...]

    10/15/2015

    2

    B

    15/09/2015

    3

    A

    16/08/2015

    4

    C

    18/08/2015

    5

    E

    22/07/2015

    6

    C

    31/01/2015

    7

    A

    15/10/2014

    TABLE 3

     

    AREA_CODE

    AREA_COUNTRY_CODE

    AREA_CITY_CODE

    A1

    COU1

    CIT1

    A2

    COU2

    CIT2

    A3

    COU3

    CIT2

    A4

    COU3

    CIT3

    A5

    COU4

    CIT5

    How can I find the list of clients of TABLE1, which are present in TABLE2 by 2015 and have country-city-zone, both correct mapping as specified in section TABLE3 using the clause "EXISTS".

    Is that my output will be like,

     

    CUST_CODE

    (ONLY CORRECT CUSTOMER CODES)

    CUST_NAME

    A

    CUST1

    B

    CUST2


    Thanks in advance,

    Séverine Suresh

    Hello

    So, you want to see 3 columns in table1 correspond to 3 columns in t3.  It is not enough for only 1 column equal:

    Area_Code must be equal

    country_code and must be equal

    city_code and must be equal.

    Here's a way to encode that, by using the EXISTS operator in a WHERE clause:

    SELECT cust_no, cust_name

    FROM table1 t1

    WHEN THERE IS)

    SELECT 0

    Table 3 T3

    WHERE t3.area_code = t1.cust_area_code

    AND t3.area_country_code = t1.cust_country_code

    AND t3.area_city_code = t1.cust_city_code

    )

    ;

    I hope that answers your question.

    If not, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results you want to start from these data (otherwise what you've posted already).

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • SQL Server 2005 unattended install using the script fails on Windows 2003 Cluster

    We strive to perform the installation without SQL Server 2005 via the script assistance, but the installation fails on Windows 2003 Cluster, we use Windows 2008 with HyperV running a DC with two nodes (all Win 2003). Script is...

    Start/wait setup.exe/qb VS = INSTALLVS SQLTEST = SQL_Engine INSTANCENAME = SQL123 ADDLOCAL = SQL_Engine ADDNODE = sqlnode-1, sqlnode-2 GROUP = SQL1 IP = 192.168.1.85, SQLNetwork ADMINPASSWORD = Windows8! SAPWD = Windows8! INSTALLSQLDIR=%ProgramFiles%\Microsoft SQL Server\ INSTALLSQLDATADIR = G:\SQLDATADIR\ SQLACCOUNT = SQLPASSWORD lab\sql_svc = Windows8! AGTACCOUNT = lab\sql_svc = Windows8 AGTPASSWORD! SQLBROWSERACCOUNT = SQLBROWSERPASSWORD = Windows8 lab\sql_svc! SQLCLUSTERGROUP = "lab\sql_grp" AGTCLUSTERGROUP = "lab\sql_grp" FTSCLUSTERGROUP = "lab\sql_grp" ERRORREPORTING = 1 SQMREPORTING = 1 SQLCOLLATION = SQL_Latin1_General_CP1_CI_AS

    Errors on the nodes:

    SQLSetup0008_SQLNODE1_Core (Local)

     Running: InstallSqlAction to the: 4/14/2012 22:56:39

    Installation: sql on target: SQLNODE1

    Waiting for remote setup (s) to prepare

    Remote Setup (s) is ready

    Problem of determining the State of the virtual server for the package: '1' because of the exception of data store:

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: CachedPropertyCollection::findProperty

    The source line number: 63

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

    Could not find the property 'VsDataPath' {'PackageIdStateScope', ' ', '1'} in the cache.

    Source the name of the file: datastore\packageidstatescopecollector.cpp

    Compiler timestamp: Wed Aug 24 13:40:04 2005

    Function name: PackageIdStateScopeCollector::collectProperty

    The source line number: 115

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

    dataPathValue is empty

    Cluster functionality detected: SQL_Engine

    Loaded DLL:C:\Program SQL Server\90\Setup Bootstrap\sqlsval.dll Version: 2005.90.1399.0

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: CachedPropertyCollection::findProperty

    The source line number: 130

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

    Unable to find property 'IPResources' {"VirtualServerInfo", "", "SQLTEST"} in the cache

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: VirtualServerInfo.IPResources

    The source line number: 113

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

    Could not collect the property 'IPResources' {"VirtualServerInfo", "", "SQLTEST"}

    Transact package threw an exception.

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\highlyavailablepackage.cpp

    Compiler timestamp: Mon Aug 29 01:18:42 2005

    Function name: sqls::HighlyAvailablePackage:manageVsResources

    The source line number: 490

    ---- Context -----------------------------------------------

    SQLs::HighlyAvailablePackage:preInstall

    SQLs::HighlyAvailablePackage:manageVsResources

    m_dataDirPath is empty

    Cluster API threw an exception during operations of virtualization.

    Package first notify: 13

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\highlyavailablepackage.cpp

    Compiler timestamp: Mon Aug 29 01:18:42 2005

    Function name: sqls::HighlyAvailablePackage:manageVsResources

    The source line number: 490

    ---- Context -----------------------------------------------

    SQLs::HighlyAvailablePackage:preInstall

    SQLs::HighlyAvailablePackage:manageVsResources

    m_dataDirPath is empty

    Cluster API threw an exception during operations of virtualization.

    SQLSetup0008_SQLNODE2_Core (Local)

     

    Local configuration can complement

    Running: InstallSqlAction at: 4/2012/14 23:23:57

    Installation: sql on target: SQLNODE2

    Informs the package is ready to start: 0

    Waiting for notification start installation

    Local configuration can begin installation

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: remotepackageengine\remotepackageinstallersynch.cpp

    Compiler timestamp: Wed Aug 24 13:40:17 2005

    Function name: sqls::RemotePackageInstallerSynch:preInstall

    The source line number: 128

    ---- Context -----------------------------------------------

    SQLs::InstallPackageAction: perform

    SQLs::RemotePackageInstallerSynch:preInstall

    Abandonment of the package: "sql", due to an error from the configuration of the host: 13

    Notify all ready to commit: 13

    Notify all ready to put end to: 13

    Waiting for notification complete installation

    Local configuration can complement

    Packaging return code: 13

    Complete: InstallSqlAction at: 4/2012/14 23:23:59, returned false

    Error: The 'InstallSqlAction' Action failed during execution.  Error during execution information:

    Target collection includes the local machine.

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

    Error: The 'UninstallForRS2000Action' Action failed during execution.  Error during execution information:

    Action: "UninstallForRS2000Action" will be marked as failed due to the following condition:

    The condition 'rs has been correctly upgraded level.' returned false.

    Package installation: 'patchRS2000' failed due to a precondition.

    Running: ReportChainingResults at: 4/2012/14 23:24:1

    Error: Action "ReportChainingResults" threw an exception during execution.

    One or more packages could not be installed. See logs for details of the error. : 13

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\sqlchainingactions.cpp

    Compiler timestamp: 1 Thu Sep 22:23:05 2005

    Name of the function: sqls::ReportChainingResults: perform

    The source line number: 3097

    Please notify.

    Assani

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums. You can follow the link to your question:

    http://TechNet.Microsoft.com/en-us/WindowsServer/bb512923

    Hope this information helps.

  • Performance problem on the SQL query that does not use the primary key index

    Hello!

    I have some performance issues on a single SQL query (Oracle 10 g).
    I could solve the problem by using the INDEX indicator, but I would like to know WHY this is happening.

    * Tables *.
    create table jobs)
    ID number (5) not null,
    name varchar2 (100),
    primary key constraint Job_PK (id)
    )
    /
    -Record count: 298

    create table Comp)
    integer ID not null,
    name varchar2 (100),
    primary key constraint Comp_PK (id)
    )
    /
    -Record count: 193

    -Relation m: n
    create table JobComp)
    integer ID not null,
    id_job integer not null,
    id_comp integer not null,
    primary key constraint JobComp_PK (id),
    unique key constraint JobComp_UK (id_job, id_comp),
    Constraint JobComp_FK_Job foreign key (id_job) refers to Job (id),
    Constraint JobComp_FK_Comp foreign key (id_comp) makes reference Comp (id)
    )
    /
    create index JobComp_IX_Comp on JobComp (Cod_Comp)
    /
    create index JobComp_IX_Job on JobComp (Cod_Job)
    /
    -Record count: 6431

    * Ask *.

    When I run this query, the execution plan shows the index using (JobComp_PK and JobComp_IX_Comp).
    No problem.

    Select JobComp.*
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    But when I add the field 'name' of the work table the plan uses full access table to the table of work

    Select JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in the 2.70 dry

    With the help of the index

    Select / * + INDEX (Job Job_PK) * /.
    JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    * Doubt *.

    This behavior is correct?

    PS. : I tried to recalculate the statistics, but nothing changes:

    analyze the job calculation table statistics.
    /
    change the statistical calculation of index Job_PK reconstruction;
    /
    Start
    dbms_utility.analyze_schema (sys_context ('userenv', 'current_schema'), 'CALCULATE');
    end;
    /

    [of]
    Gustavo Ehrhardt

    Gus.EHR wrote:
    Hello.
    I'm sorry for the plan unformatted.
    The execution time of the querys "without field name' and 'with the field name with suspicion" are equal.
    He has no problem caching, because I get the plans of the sequence different from the querys and repeated the performance. The result is always the same.

    I don't think that there is no problem with oracle crossing LOOP IMBRIQUEE to the HASH JOIN when you include the field name and this should be the expected behavior. But it seems that your WORKING table has a degree of parallelism set against what is causing the query to run in parallel (as JOB table is now available with full table scan, instead of indexed access earlier). It could be that the parallel execution is contributor to extra Runtime.
    (a) do you know why the degree of parallelism on the WORK table has been defined? Do you need it?

    You can see if the following query provides a better response time?

    select /*+ NOPARALLEL(JOB) */ JobComp.*, Job.Name
      from JobComp
      join Job
        on Job.id = JobComp.id_job
     where JobComp.id_comp = 134
    
  • ORA-19102: literal string XQuery waited while xmltable reading using the clause of passage

    Hello

    I have the following XML in the column tmp_xml in the tmp_medimail_accounts table:

    " < = xmlns:env env:Envelope ' http://schemas.xmlsoap.org/SOAP/envelope/ ">

    < env:Header / >

    < env:Body >

    " < its: findAccountByCriteriaResponse xmlns: its = ' http://session.kernel.CMP.com/ ">

    < return >

    < detailedInfo > accounts found: 1 < / detailedInfo >

    < operationResult > MPROXY_RESULT_OK < / operationResult >

    < value >

    < authCertificate / >

    < autocertificationActive / >

    < boolAck > true < / boolAck >

    < caDomain > BE_AUTO < / caDomain >

    < certified > false < / certified >

    < City > BELSELE < / City >

    < commercialAction / >

    < country / >

    < description > MediMail 3.7.4 < / description >

    other < dmi > < / dmi >

    < emailForward > false < / emailForward >

    < enabled > true < / enabled >

    < encCertificate / >

    medidoc < encodingType > < / encodingType >

    < etk / >

    < fax > LDAP this field is masked by the SECURITYFILTER < / fax >

    PC < firstName > < / name >

    < inami > 72091883000 < / inami >

    < institution > pc sint hieronymus < / institution >

    < language > NL < / language >

    < name > sint-hieronymus < / lastName >

    < lastconnectiondate > 20140115090051Z < / lastconnectiondate >

    < localeStr / >

    PC.Sint - hieronymus of < connection > < / login >

    < mail > [email protected] < / mail >

    < mexiAddress > pc.sint-hieronymus.72091883@BE_AUTO < / mexiAddress >

    < mexiBackup / >

    < mobilephone > LDAP this field is masked by the SECURITYFILTER < / mobilephone >

    < niss / >

    < oldIP / >

    < oldSystemId > 720918 < / oldSystemId >

    < packageName > M < / packageName >

    This LDAP is hidden by the SECURITYFILTER field < password > < / password >

    < pin / >

    < pkey / >

    < pkeyehealth / >

    < main > false < / main >

    < principalUserName / >

    the province <>FLANDRE_ORIENTALE < / province >

    < registrationDate > 20101213093341Z < / registrationDate >

    < role > HOSPITAL < / role >

    < sender > true < / sender >

    < senderInvisible > true < / senderInvisible >

    < subscriptiondocs > false < / subscriptiondocs >

    This LDAP is hidden by the SECURITYFILTER field < phone > < / phone >

    < improved / >

    < userpublic / >

    < usetranscodor > true < / usetranscodor >

    < version / >

    < / value >

    < / return >

    < / its: findAccountByCriteriaResponse >

    < / env:Body >

    < / env:Envelope >

    I want to read the XML column and display it as a relational table.  I have the following SQL code:

    Select x.*

    of tmp_medimail_accounts t

    xmltable)

    xmlnamespaces ('http://schemas.xmlsoap.org/soap/envelope/"as" env" )

      , ' http://session.kernel.CMP.com/ ' as 'his'

    )

    , ' env:Envelope / env:Body / its: findAccountByCriteriaResponse return value '

    in passing t.tmp_xml

    path of varchar2 (30) columns "firstName", firstName

    path varchar2 (30) LastName "lastName."

    rizivnr varchar2 (11) path 'inami ',.

    path of varchar2 (50) address "mexiAddress."

    path of varchar2 (100) email "mail."

    Gemeente varchar2 (50) path 'city') x;

    But I have error: ORA-19102: literal string XQuery WAITED

    Can someone help me?

    Best regards, Hans

    Hello

    What is your version of the database?

    It looks like an old problem related to the CURSOR_SHARING parameter.

    See if the solution given here helps: How to use a web service xml document

  • How to use the clause type conditionally create new lines

    This question is just for learning - no object other than to start real world to create versions of some queries known to learn how to measure the performance of the MODEL clause clause of the MODEL versions.

    The question is: How can you write a STANDARD clause that pivots (updates) ONLY the lines that actually need to rotate and do NOT change the lines that have no value and cannot be rotated.

    I found a good site that has about two dozen example articles on different pieces. This first link is the beginning of the series.

    SQL features tutorials - Clause TYPE

    http://www.sqlsnippets.com/en/topic-11663.html

    This link is to a clause of FAQ of BluShadow MODEL version "how to convert rows to columns."

    Line - MODEL method string

    http://www.sqlsnippets.com/en/topic-11987.html

    The solution to this link uses this line of source:

    POSITION KEY VAL

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

    R08 0 v1, v2, v3,.

    and this result set:

    POSITION KEY VAL

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

    R08 1 v1

    R08 2 v2

    R08 3 v3

    The reason why it produces that result set is this clause of the statement of MODEL

    RETURN THE UPDATED LINES

    If you comment on this article, you will see that the original lines are all in position 0. This means that the solution reproduced EACH SOURCE LINE even if there is only one item in the list of values.

    Thus, even a line source with a single value (for example, the r01 'a') will be updated and updated this line is returned.

    For a large number of data sources with only a few lines that actually need to rotate it would be a great performance of infringement.

    This is the sample data source

    with t as (button 1, 'a' value 'abc' col2, col3 'def' of the double
    Select Union all 2, 'b', 'ghi', 'jkl' from dual
    Union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
    Union all select 4, 'f', 'stu', 'vwx' from dual
    )
    Select the key, value, col2, col3
    t

    KEY, VALUE, COL2, COL3
    1, a, abc, def
    2, b, GHI, jkl
    3, "c, d, e, mno, pqr.
    4, f, stu, vwx

    Lines 1, 2 and 4 only have a value of (a, b, c respectively.

    Only line 3 must rotate. It contains "c, d, e" and which must become 3 lines in the result set

    Value of the key, col2 col3
    1 an abc def
    2B ghi jkl
    3 c mno, pqr
    3 d mno, pqr
    3 e mno, pqr
    4 f stu vwx

    The nut of the problem is that if the clause 'RETURN UPDATED ROWS' is used, then the lines 1, 2 and 4 must be updated in order to be returned in the result set. And if this clause is NOT used, then line 3 must be updated by 'c', d, e 'c' and two new product lines: one line for a ' and one for 'e '.

    How can you do this with the TYPE clause without the help of the clause "Return LINES UPDATE"? I don't have a solution to sample showing what I tried because I can't understand what it takes to even try.

    I have a solution that uses "RETURN UPDATED ROWS" but I want to compare this performance to the exercise, when this clause is NOT used.

    We ask BluShadow to add the solution of MODEL clause to this FAQ with other similar solutions.

    Like this?

    SQL > with t as
    () 2
    3 select the 1 key, 'a' val, 'abc' col2, col3 'def' of the double


    Select 4 Union all 2, 'b', 'ghi', 'jkl' from dual
    5 union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
    Select 6 Union all the 4 'f', 'stu', 'vwx' from dual
    7)
    8. Select the key
    9, key_1
    10, val
    11, regexp_substr (val, ' [^,] +', 1, key_1) val_new
    12, col2
    13, col3
    14 t
    model 15
    16 partition by (key)
    dimension (1 key_1) 17
    18 measures (val, col2, col3, (length (val) - length (replace (val, ",")) + 1) as len)
    19 rules
    (20)
    21 val [for 1 to increment of len key_1 [1] 1] = val [1]
    22, col2 [for 1 to increment of len key_1 [1] 1] = col2 [1]
    23, col3 [for 1 to increment of len key_1 [1] 1] = col3 [1]
    24)
    25 order
    26 by key
    27, key_1;

    KEY KEY_1 VAL VAL_N NECK NECK
    ---------- ---------- ----- ----- --- ---
    1 1 has an abc def
    2 b 1 b ghi jkl
    3 1 c, d, e c mno pqr
    3 2 c, d, e d mno pqr
    3 3 c, d, e e mno pqr
    4 1 f f stu vwx

    6 selected lines.

  • Join natural vs using the Clause

    Hello everyone,

    I am pretty new to SQL and Oracle and have been practicing with data sample provided with the Oracle installation.

    I'm having some difficulty understanding why, when I use the following query, I have received only one result:

    SELECT last_name, department_id, department_name

    Ministries of NATURAL JOIN employees

    WHERE department_id = 20;

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

    LAST_NAME, DEPARTMENT_ID DEPARTMENT_NAME

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

    Fay 20 Marketing

    Yet, when I run the query below I have two results:

    SELECT last_name, department_id, department_name

    Employees JOIN departments USING (department_id)

    WHERE department_id = 20;

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

    LAST_NAME, DEPARTMENT_ID DEPARTMENT_NAME

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

    Fay 20 Marketing

    Hiba 20 Marketing

    It was my understanding that these two queries must have generated the same results.

    Out of curiosity, I also tried to run the next and received a null value for the second entry:

    SELECT last_name, department_id, department_name

    Ministries of NATURAL LEFT JOIN employee

    WHERE department_id = 20;

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

    LAST_NAME, DEPARTMENT_ID DEPARTMENT_NAME

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

    Fay 20 Marketing

    20 Hartstein (null)

    Any help would be greatly appreciated. Thanks in advance.

    Hello

    I assume you mean the tables provided by Oracle in the HR schema.

    HR. Employees and hr.departments have 2 columns with the same names, department_id MANAGER_ID, as well

    SELECT last_name, department_id, department_name

    Employees

    NATURAL JOIN departments

    WHERE department_id = 20;

    is equivalent to

    SELECT last_name, department_id, department_name

    Employees

    JOIN departments USING (department_id, manager_id)

    WHERE department_id = 20;

    In fact, I do not recommend NATURAL JOIN or USE.  I think it's less confusing and more robust for use on, like this

    SELECT last_name, department_id, department_name

    E EMPLOYEES

    JOIN departments d ON d.dpartment_id = e.department_id
    AND d.manager_id = e.manager_id

    WHERE department_id = 20;

    This isn't just my preference.   Person, not literally, using NATURAL JOIN unless they are a manual writing or reading a.

    Very rarely, you will see a person in the real world using the HELP, but again, it is very rare.

    In both cases, they have good reasons.  Save you time and forget all about NATURAL JOIN and USE.

  • Update a table using the clause

    Hello

    I want to update a table using the selected values.

    Cases in the sample:


    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Krishna Devi wrote:

    Hello

    I want to update a table using the selected values.

    Cases in the sample:

    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Thanks for posting creates table and test data.

    The error message would have helped because it's pretty obvious that this is the problem:

    Update table empsalary

    *

    ERROR on line 1:

    ORA-00903: invalid table name

    Just remove the word "table".

  • How to use the clause type without hard-coding the values inside?

    Query

    Select acct_no,

    gl_code,

    CASE

    WHEN entry_type_label ("earned INCOME") THEN

    "Recipes".

    ON THE OTHER

    "Deferred income of credit."

    END as entry_type_label,

    CASE

    WHEN entry_type_label IN ("opening balance") THEN

    "Opening balance".

    WHEN entry_type_label ("deferred revenue CREDIT") THEN

    "The amount of the invoice.

    WHEN entry_type_label ("earned INCOME") THEN

    "Recipes".

    WHEN entry_type_label IN ('closing balance") THEN

    "Closing balance.

    ON THE OTHER

    "Deferred income of credit."

    END tag as,

    entry_type_no,

    orig_chg_start_date,

    period_no,

    -amt as amt

    of revrec_test

    WHERE acct_no = 1788562

    AND IN (2, 4) entry_type_no (acct_no model dimension,

    gl_code,

    entry_type_label,

    entry_type_no,

    orig_chg_start_date,

    period_no) measures (amt) rules upsert

    all (amt 1788562,

    ' NON-10011561',

    "Opening balance"

    2,

    2 OCTOBER 17 08.30.00 AM'.

    190 = 0,

    AMT 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    190 = amt 1788562,

    ' NON-10011561',

    "Deferred income of credit."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    190 - amt 1788562,

    "WON-10011561',

    "Revenue."

    4,

    2 OCTOBER 17 08.30.00 AM'.

    190,

    AMT 1788562,

    ' NON-10011561',

    "Opening balance"

    2,

    2 OCTOBER 17 08.30.00 AM'.

    191 = amt 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    190,

    AMT 1788562,

    ' NON-10011561',

    "Deferred income of credit."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    191 = 0,

    AMT 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    191 =.

    (amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")

    2 October 17 08.30.00 AM', 191 + amt 1788562, "UNEARNED-10011561',

    ("'Revenue deferred credit', 2, 08.30.00 October 2, 17 h", 191)-amt

    1788562,

    "WON-10011561',

    "Revenue."

    4,

    2 OCTOBER 17 08.30.00 AM'.

    191,

    AMT 1788562,

    ' NON-10011561',

    "Opening balance"

    2,

    2 OCTOBER 17 08.30.00 AM'.

    192 = amt 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    191,

    AMT 1788562,

    ' NON-10011561',

    "Deferred income of credit."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    192 = 0,

    AMT 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    192 =.

    (amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")

    2 October 17 08.30.00 AM', 192 + amt 1788562, "UNEARNED-10011561',

    "Revenue deferred credit", 2, 08.30.00 2 October 17: "(, 192)-amt"

    1788562,

    "WON-10011561',

    "Revenue."

    4,

    2 OCTOBER 17 08.30.00 AM'.

    192,

    AMT 1788562,

    ' NON-10011561',

    "Opening balance"

    2,

    2 OCTOBER 17 08.30.00 AM'.

    193 = amt 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    192,

    AMT 1788562,

    ' NON-10011561',

    "Deferred income of credit."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    193 = 0,

    AMT 1788562,

    ' NON-10011561',

    "Closing balance."

    2,

    2 OCTOBER 17 08.30.00 AM'.

    193 =.

    (amt 1788562, "UNEARNED-10011561',"Opening balance", 2,")

    2 October 17 08.30.00 AM', 193 + amt 1788562, "UNEARNED-10011561',

    ("Revenue deferred credit", 2, 08.30.00 2 October 17: ', 193)-amt

    1788562,

    "WON-10011561',

    "Revenue."

    4,

    2 OCTOBER 17 08.30.00 AM'.

    193)

    ORDER BY period_no, entry_type_no;

    The query above works fine. But I hardcoded the values. I want to do the same operation for the other account number which will have different non periodical. How can I reach it?

    Thanks in advance.

    And why do you need a model for that? If I understand the reqs OK:

    with t as)

    Select acct_no,

    "U-11561' gl_code,

    "Deferred income credit ' entry_type_label,.

    2 entry_type_no,

    orig_chg_start_date,

    period_no,

    Max)

    case entry_type_no

    When 2 then - amt

    0 otherwise

    end

    ) amt,.

    Description of the "invoice."

    2 weight

    from table_one

    Acct_no group,

    orig_chg_start_date,

    period_no

    Union of all the

    Select acct_no,

    gl_code,

    entry_type_label,

    entry_type_no,

    orig_chg_start_date,

    period_no,

    -amt,

    Description "paid the Bill."

    3 weight

    from table_one

    where entry_type_no = 4

    Union of all the

    Select acct_no,

    "U-11561' gl_code,

    "Deferred income credit ' entry_type_label,.

    2 entry_type_no,

    orig_chg_start_date,

    period_no,

    AMT 0,.

    case lvl

    When 1 then 'account opening. "

    of other "close account."

    description of the end,

    case lvl

    When 1 then 1

    another 99

    end weight

    from table_one,.

    (select level lvl from dual connect by level<=>

    Acct_no group,

    orig_chg_start_date,

    period_no,

    LVL

    )

    Select acct_no,

    gl_code,

    entry_type_label,

    entry_type_no,

    orig_chg_start_date,

    period_no,

    case

    what weight (sum) (1.99) can

    case weight

    When 2 then amt

    When 3 then - amt

    0 otherwise

    end

    )

    During)

    acct_no partition

    order of period_no,

    weight

    )

    AMT else

    AMT of end,

    Description

    t

    order of acct_no,

    period_no,

    weight

    /

    ACCT_NO GL_CODE ENTRY_TYPE_LABEL ENTRY_TYPE_NO ORIG_CHG_START_DATE PERIOD_NO AMT DESCRIPTION
    ------- ---------------------------- ----------------------- ------------- --------------------- --------- ---------- ---------------
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 100 0 opening account
    1001 U-11561 deferred revenue credit 2 Bill October 2, 17 08.30.00 AM 100 44
    E-11561 1001 recipes 4 08.30.00 2 October 17: 100 13.87 paid invoice

    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 100 30.13 closing account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 30.13 opening account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 0 Bill
    E-11561 1001 recipes 4 08.30.00 2 October 17: 101 14,35 paid invoice

    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 101 15.78 closing account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102 15.78 opening account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102 Bill 0
    E-11561 1001 recipes 4 08.30.00 2 October 17: 102 14.83 invoice paid

    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 102.95 close account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103.95 opening account
    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103 Bill 0
    E-11561 1001 recipes 4 08.30.00 2 October 17: 103.95 invoice paid

    1001 U-11561 deferred revenue credit 2 2 October 17 08.30.00 AM 103 0 closing account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 104 0 opening account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 60 104 Bill
    1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 104 9.13 invoice paid

    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 104 50.87 closing account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 50.87 opening account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 105 50.87 opening account
    1002 U-11561 deferred revenue credit 2 09.30.00 December 20, 13 h 105 19.24 invoice
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 0 Bill
    1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 105 44,91 paid invoice

    1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM 105 - 7.82 Bill paid

    1002 fixed costs recurring revenue COA Code 4 09.30.00 December 20, 13 h 105 3.93 invoice paid

    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 105 29.09 closing account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 105 29.09 closing account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106 29.09 opening account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106 29.09 opening account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106 0 Bill
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106 0 Bill
    1002 fixed costs recurring revenue COA Code 4 09.30.00 November 17, 13 h 106 44,91 paid invoice

    1002 fixed costs recurring revenue COA Code 4 09.30.00 December 20, 13 h 106 11.75 invoice paid

    1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM - 23.47 106 paid

    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 106-4.1 closing account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 106-4.1 closing account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 - 4.1 opening account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 - 4.1 opening account
    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 Bill 0
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 Bill 0
    1002 fixed costs recurring revenue COA Code 4 December 20, 13 09.30.00 AM - 13.69 107 paid invoice

    1002 fixed costs recurring revenue COA Code 4 November 17, 13 09.30.00 AM 107 35.91 invoice paid

    1002 fixed costs recurring revenue COA Code 4 09.30.00 20 December 13 AM 107 6,86 invoice paid

    1002 U-11561 deferred revenue credit 2 17 November 13 09.30.00 AM 107 - 33.18 closing account
    1002 U-11561 deferred revenue credit 2 December 20, 13 09.30.00 AM 107 - 33.18 closing account

    47 selected lines.

    SQL >

    SY.

  • Cases identified in a clause Where using the clause

    Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    Hello

    I have an APEX application I need to build a SQL statement to a LOV (list of values). I hid filed that contains the type of customer that may be an 'R' or 'B '. The query must be able to display two sets of different results depending on the type of customer 'R' or 'B '.

    If the customer type is 'R', then:
    SELECT drg_descr d, drg_code r
    FROM distance_ranges
    WHERE  drg_min_miles IN (0,5)
    ORDER BY drg_min_miles
    If the customer type is 'B', then:
    SELECT drg_descr d, drg_code r
    FROM distance_ranges
    WHERE  drg_min_miles IN (0,5,10,15,20)
    ORDER BY drg_min_miles
    Can someone help me with what I think should be a case statement?

    Thank you
    Joe

    Try,

    SELECT drg_descr d, drg_code r
      FROM distance_ranges
     WHERE ( (drg_min_miles IN (0, 5)
          AND param_cust_type = 'R')
         OR  (drg_min_miles IN (0, 5, 10, 15, 20)
          AND param_cust_type = 'B'))
    ORDER BY drg_min_miles
    

    G.

  • Redirect to an Apex Pl/Sql by using the page

    Hello

    I want to redirect it to a page of the apex using pl/sql.

    I m using the following code.

    Begin

    htp.p (utl_http.request (": http://application-tier server: port/apex /'"));

    End;

    Get the following error: parsererror - syntax error: token Unexpexted.

    Help, please.

    Concerning

    Far87 wrote:

    Fac586 thank you very much for your reply,

    Sorry for the unclear issue, I will make you understand.

    My requirement is to navigate between the pages.

    I have a form with field x and a button to send in the same region.

    whenever you press submit, it should check

    If x = 1 then

    GoTo page 3

    elsif x = 3 then

    GoTo page 4

    on the other

    GoTo page5

    end if;

    To do this, I created a dynamic action using the code below.

    Begin

    If: P5_x = 1 then

    HTP.p (utl_http.request (": http://application-tier server: port/apex/f?")) p = 159:3'));

    elsif: P5_x = 3 then

    HTP.p (utl_http.request (': http://application-tier server:port/apex /f? p = 159:4'));

    on the other

    HTP.p (utl_http.request (': http://application-tier server:port/apex /f? p = 159:5'));

    end if;

    end;

    Get the following error: parsererror - syntax error: token Unexpexted.

    I replaced the htp.p (utl_http.request (": http://application-tier server: port/apex/f?")) p = 159:3"))

    with owa_util.redirect_url (": http://application-tier server: port/apex/f?") p = 159:3');

    apex_application.stop_apex_engine ();

    Always make the same mistake.

    This is completely the wrong approach for normal inter-page navigation in the APEX. The use of dynamic action is not here. In this situation use branches for navigation, with conditions to control which branch is used according to the logic that you need...

  • Unable to connect to the network in Windows 7 using the Boot Camp via Fusion 2.0.4 partition

    I know that Windows 7 RC is not officially supported, but I was wondering if anyone had ideas regarding my current situation.  I'm running the RC 32 - bit of a Boot Camp partition, via merger on a unibody MacBook, and whenever I'm in Fusion Windows cannot connect to my network.  Previously, I had a vm file-based and it worked normally, and in Boot Camp, I can get online without problem.  I went to training Camp to see if the Aero effects would work (they did after I ran the test of Windows experience).  I tried mode Bridged and NAT and any Windows does not see my wireless network.

    At the time current Windows 7 in any version is not supported by Apple on the Boot Camp partition, nor is it supported in any way under Fusion.

    Take a look at the configuration of the Virtual Machine's .vmx file and make sure that the NIC is showing that "e1000" as in the following example.

    ethernet0.virtualDEV = "e1000"
    

    To get the location of the Machine configuration file virtual .vmx take a look at the Beginner's Guide has VMware Fusion or gather Information for VMware Fusion.

    Note: You should make the change while Windows is shutdown, not suspended and merger closed.

    You can use TextEdit to edit the .vmx of the target Virtual Machine configuration file and locate the file...

    VMware Fusion (menu bar) > help > VMware Fusion help > navigation in VMware Fusion > using Virtual Machine library window > determine the location of the files from a virtual machine

    VMware Fusion (menu bar) > help > VMware Fusion help > using the Interface of VMware Fusion > work with Virtual Machine packages

  • Using the Type of object in fusion

    Hi all

    You have a small problem where I would like some suggestions.

    I had a declared TYPE.

    CREATE OR REPLACE TYPE 'MY_TYPE_OT' IS (OF THE OBJECT
    Field1 VARCHAR2,
    Field2 VARCHAR2,
    field3 VARCHAR2);

    I now have an array declared to type this

    TYPE MY_TYPE_TT IS TABLE OF INDEX MY_TYPE_OT BY VARCHAR2 (100);

    I have the collection of type MY_TYPE_TT

    MY_TYPE_TT MY_VARIABLE;

    I am populating this variable lets say 10 records.


    Then I try to save it to a database table, my_table for this I need to merge since it could be an update or insert. so, my query goes like this


    MERGE INTO my_table T2 using T1 ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2) TABLE ($my_var)

    Here, I get an error that my_variable is not a table. I tried different things like doing a casting, which gives me invalid data type etc.

    Any suggestions on how to pick up on this?

    Thanks in advance
    Paddy

    Collection with "index of" cannot be used in the context of sql. You can or use the collections without "index of" or treat it manually. See the example:

    drop table MY_TABLE purge
    /
    CREATE OR REPLACE TYPE MY_TYPE_OT IS OBJECT (
    field1 VARCHAR2(100),
    field2 VARCHAR2(100),
    field3 VARCHAR2(100))
    /
    create table MY_TABLE of MY_TYPE_OT
    /
    declare
      TYPE MY_TYPE_TT     IS TABLE OF MY_TYPE_OT INDEX BY VARCHAR2(100);
      MY_VAR              MY_TYPE_TT;
    begin
      --just testing values for collection:
      for i in 1..3
        loop
          MY_VAR(i):=MY_TYPE_OT(null,null,null);
          MY_VAR(i).field1:='field1-'||i;
          MY_VAR(i).field2:='field2-'||i;
          MY_VAR(i).field3:='field3-'||i;
        end loop;
    
      -- manually merging by one row:
      for c in MY_VAR.first..MY_VAR.last
        loop
          execute immediate '
            merge into MY_TABLE T2
            USING (select :1 field1, :2 field2, :3 field3 from dual) T1
            ON (T1.field1 = T2.field1 AND T1.field2 = T2.field2)
            when matched then
              update set
                     t2.field3=t1.field3
            when not matched then
              insert values(t1.field1,t1.field2,t1.field3)
          '
          using MY_VAR(c).field1,MY_VAR(c).field2,MY_VAR(c).field3
        ;
        end loop;
    end;
    /
    

    Kind regards
    Malakshinov Sayan

  • Failed to create the Data Source by using the pivot table query

    Hi people.

    Running Oracle BI Publisher 11.1.1.6.0

    He complains with ORA-01738: lack of KEYWORD

    When I try and a SQL query in function by using the data set:

    SELECT *.
    FROM (SELECT ist.descr |) ' '|| EIT. Descr service_type, ROUND (sum (milf.ttl_number_units)) ttl_number_units
    Of mv_iot_line_item_forecasting mllf
    Ope on ope.master_entity_id = milf.partner_master_entity_id JOIN operator
    JOIN iot_service_type on ist.iot_service_type_id = milf.iot_service_type_id ist
    JOIN iot_event_type on iet.iot_event_type_id = milf.iot_event_type_id EIT
    WHERE milf.iot_agreement_id = 2621
    AND milf.traffic_direction = 'CR '.
    AND ope.operator_type_id = pkg_ngc_constants.operator_type_id_gsm
    Ope.main_reference GROUP, ist.descr | ' '|| EIT. Descr)
    PIVOT (sum (ttl_number_units) FOR service_type IN ("Voice MO' like' voice', 'MT voice' as 'voice MT", "SMS MO" as "SMS MO", "SMS MT" as "SMS MT", "MB of data" as "MB of data"))
    order by 1


    No idea why it won't let me create?

    The query runs perfectly fine in SQL.

    Any input appreciated.

    Simon

    Can you try to change your "IN" clause to this and see if it works?

    service_type IN ("voice MO' as Voice_MO, 'Voice MT" as Voice_MT, "SMS MO" as SMS_MO, "SMS MT" SMS_MT, 'MB of data' as Data_MB)

    Thank you
    Bipuser
    Published by: BIPuser on October 18, 2012 07:40

    Published by: BIPuser on October 18, 2012 07:41

  • DML using the partition.

    Hello

    10.2.0.1.0 Oracle

    Is it possible to have quickly DML operation using partitions. as the update, insert, delete.


    as we do in select * partition of course (2001_pg_courses);


    kindly help.

    You don't need to explicitly select a partition.

    A partition table has 'rules' about what data go where. For example, a range may partition table have a 'rule' for a partition by day - all the lines for a day (according to table column invoice_date for example), is in a single partition. Similarly, a partitioned table list will also have a "rule", stating that the lines go in which partition.

    You can explicitly reference the score via a SQL statement as follows to find all invoices for a customer:

    select * from invoices partition (day_20110101) where customer_id = :1;
    

    This SQL is however not very shareable under the partition name is hardcoded. If you want to find the Bills for another day, a new brand SQL statement is necessary with hardcoded score of the day in the SQL.

    Also consider what it does to the application. User PL/SQL code can no longer use the SQL statement as is - like it needs a new SQL statement to use depending on the day. So dynamic SQL must be used - an approach complex and often creates a security risk because of risk of SQL injection.

    Or you can implicitly reference the partition using this 'rule' as part of the predicate. For example

    select * from invoices where invoice_date = :0 and customer_id = :1;
    

    The CBO will see invoice_date is used and he will know that it is used as the "rule of the partition. The CBO can now decide which or the partitions to use.

    The SQL that is created is shareable. We will use the same SQL in the shared pool of Oracle over and over again for customers and different days - we are not a completely new SQL for a day of different invoice.

    The PL/SQL user can now use the SQL like it - no need to use SQL dynamically and inserting the name of partition in SQL. No threat of SQL injection.

    Best of all - the PL/SQL Developer didn't need to worry how partition works, how it is applied, that partition names and so on. Standard SQL is used - as it would have been the case if the invoice table is not partitioned, or a cluster or an index organized table or anything else. The CBO has the intelligence to translate SQL into an optimal execution plan that is the most appropriate for the physical implementation table, available indexes and so on.

    The developer must only be concerned about the logic of its SQL statement - and not by the complexity of the physical implementation of the database.

Maybe you are looking for