Convert or map Typedonnees decimal Transact-SQL for Oracle Number data type?

MSSQL 2005
Oracle 10.2 g

In a MSSQL table, I have a column with the data type set on (decimal (1.0), null) with the values of line-1. (695 lines in total)

In the Oracle table, the proposed mapped column is a number data type. When I import data, I received 695 errors with the message "invalid value for the field. How to properly convert or map Decimal (MSSQL) Transact-SQL for Oracle Number data type for a negative value?

Thank you.

How do you load data into Oracle? What tool or programming language you are using? Can you post something cause what you stated in your post should work, but there may be some ODBC, or other type of conversion factors to be taken into account.

 > create table t1 (field1  number(1,0));

Table created.

 > insert into t1 values (-1);

1 row created.

UT1 > select * from t1;

    FIELD1
----------
        -1

HTH - Mark D Powell.

Tags: Database

Similar Questions

  • Largest number of digits for the NUMBER data type?

    What length more of a NUMBER that Oracle will "support"?

    The documentation says the following:

    Limitations of the data type says:

    «Can be represented in a comprehensive precision 38 digits»

    NUMBER of Data Types says:

    "Oracle guarantees portability of numbers with precision of up to 20 digits of base-100, which equals 39 or 40 decimal digits according to the position of the decimal point."

    I realize account that if I define a column as simply NUMBER, I can insert numbers with a size up to 126 characters.  However, Oracle seems to maintain only the first 40 digits in MOST cases.  The largest number of digits, it seems to allow is 40 before it begins to be replaced by 0.

    With numbers that have more than 40 figures, Oracle will sometimes replace all numbers according to the 38th numbers with a 0 and sometimes replace 0 after the digit 39th or 40th.

    Therefore, what is the largest number of digits, can be trusted to safely store Oracle?

    This is the code I used for this testing process.

    create the table max_num (num number);

    declare

    number of l_x;

    Start

    for x in 1.200

    loop

    l_x: = x;

    insert into max_num values (rpad (1, x, 1));

    end loop;

    exception

    while others then

    dbms_output.put_line ('STOP: ' | l_x);

    dbms_output.put_line (SQLERRM);

    end;

    /

    Select num, length (replace (num, 0)) of max_num;

    What length more of a NUMBER that Oracle will "support"?

    You have already given your own answer. If 'length': the maximum number of digits is written the doc gives you the answer:

    999... (38 9's) x 10 value maximum125

    The 38/39/40, hereinafter referred to as the doc means "significant digits". This is why rounding or truncation occurs if you provide more significant digits of 38/39/40.

    Oracle stores the numbers internally in a binary format 21 bytes using a documented structure in the doc of the OIC in the section 'NUMBER'.

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e10646/oci03typ.htm#i423684

    Oracle database stores the values of the NUMBER data type in a variable length format. The first byte is the exponent and is followed by 1 to 20 mantissa bytes. The high bit of the exponent byte is the sign bit; It is defined for positive numbers, and it is cleared for negative numbers. The lower 7 bits represent the exponent, which is a number of base-100 with an offset of 65.

    This article from doc continues to show you how to convert the internal format to the real value.

    An additional byte of 1 is used for all types of data to store the length; That's why you often see docs saying numbers can take 22 bytes.

  • IKM SQL for Hyperion Essbase (data) error

    Hello
    I've created an interface between Oracle DB and Essbase 11.1.2.
    I used Oracle DB as transit zone. I used IKM SQL for Hyperion Essbase (data) as a selector IKM.
    But I got an error as below in step ("Load Data on Essbase"); Can you help me? Thank you...

    org.apache.bsf.BSFException: exception of Jython:
    Traceback (most recent call changed):
    File "< string >", line 21, < module >


    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)

    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)

    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)

    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)

    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)

    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:202)

    at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:919)

    at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1261)

    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1419)

    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1668)

    at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:432)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)


    java.sql.SQLSyntaxErrorException: java.sql.SQLSyntaxErrorException: ORA-00936: lack of expression


    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.execInBSFEngine(SnpScriptingInterpretor.java:346)
    at com.sunopsis.dwg.codeinterpretor.SnpScriptingInterpretor.exec(SnpScriptingInterpretor.java:170)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java:2457)
    at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:47)
    at oracle.odi.runtime.agent.execution.cmd.ScriptingExecutor.execute(ScriptingExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:338)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:263)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:822)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:662)

    Hello

    finished column mapping, or be owned by mapping active of course active for each column.

  • IKM SQL for Hyperion Essbase (data)

    I am trying to load data into essbase through the ODI interface however module "IKM SQL for Hyperion Essbase (data)".

    Whenever data gets overwritten, how I accumulate this data during loading. As it is quite difficult for me to summarize the data, then load.

    Kind regards

    Amine ravi

    Use a rule to load and set to add to the existing values in the State of charge, adjustable load rule name in the options of the IKM.

    See you soon

    John

    http://John-Goodwin.blogspot.com/

  • ODI - SQL for Hyperion Essbase data loading

    Hello

    We have created a 'vision' in SQL Server that contains our data.  The view currently has every year and periods of Jan 2011 to present.  Each period is about 300 000 records.  I want to only load one period at a time.  For example may 2013.  Currently we use ODBC through a rule of data loading, but the customer wants to use ODI to be compatible with the versions of dimension metadata.  Here's the SQL on the view that works very well.   Is there a way I can run this SQL in the ODI Interface so it pulls only what I declare in the Where clause?  If yes where can I do it?

    Select

    CATEGORY, YEAR, LOCATION, SCRIPT, DEPT, PROJECT, EXPCODE, TIME, ACCOUNT, AMOUNT

    Of

    PS_LHI_HYP_PRJ_ACT

    Where

    YEAR > = "2013" AND PERIOD = 'MAY '.

    ORDER BY CATEGORY ASC ASC FISCAL_YEAR, LOCATION ASC, ASC, ASC, ASC, ASC, PERIOD EXPCODE PROJECT DEPT SCENARIO CSA ACCOUNT CSA;

    Hello

    Simply use the following KM to load data - IKM SQL for Hyperion Essbase (DATA) - in an ODI interface that has the view that you created the Source model. You can add filters to the source which are dynamically by ODI variables to create the Where clause based on the month and year. Make sure you only specify a rule of load method to load the data into the KM

  • Covert SybaseIQ SQL for Oracle

    Hi all

    Can come a help me next secret SybaseIQ SQL for Oracle.

    Select
    t.Sales_rep_id as sales_rep_id
    CASE when
    length (if t.market_id is null then "endif) = 0 or t.market_id is null
    then 0 otherwise cast (t.market_id as integer) end UP as market_id
    "TENDER" as feature_category
    null as is_override_tax_exempt
    null as audit_entered_by_user of ODS. POS_ODS_TENDER t;

    Thank you

    user2281943 wrote:
    Hi all

    Can come a help me next secret SybaseIQ SQL for Oracle.

    Select
    t.Sales_rep_id as sales_rep_id
    CASE when
    length (if t.market_id is null then "endif) = 0 or t.market_id is null
    then 0 otherwise cast (t.market_id as integer) end UP as market_id
    "TENDER" as feature_category
    null as is_override_tax_exempt
    null as audit_entered_by_user of ODS. POS_ODS_TENDER t;

    Thank you

    Try this

    select t.Sales_rep_id as sales_rep_id
           , CASE when length(decode(t.market_id,null,'')) = 0 or t.market_id is null
                  then 0
                  else to_number(t.market_id)
             END as market_id
           , 'TENDER' as feature_category
           , null as is_override_tax_exempt
           , null as audit_entered_by_user
      from ODS.POS_ODS_TENDER t;
    
  • table font PL/SQL: ORA-00902: invalid data type

    I m is

    PL/SQL: ORA-00902: invalid data type

    error in


    OPEN FOR PPymtCur
    SELECT *.
    TABLE (CAST (up_gap_tra_reports.myArray AS traArray));

    in my up_gap_tra_reports package.

    CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports
    AS

    TraRecord RECORD TYPE IS
    (
    group1StudEnrol NUMBER (6.1).
    group2StudEnrol NUMBER (6.1).
    pymtAmt gap_payment.NET_AMT%TYPE
    );


    TYPE traArray IS TABLE OF THE traRecord;
    myArray traArray: = traArray();

    END up_gap_tra_reports;

    I have alreay hv declared of type traArray.

    pls help me solve this problem.

    Meghna wrote:
    is it possible to use the collection pl/sql in SQL or refcur without creating it because I'm not able to create the type of database.

    The only way I know is function in pipeline:

    create or replace
      package pkg1
        is
          type traRecord
            is record(
                      ename emp.ename%type,
                      sal   emp.sal%type
                     );
          TYPE traArray IS TABLE OF traRecord;
          function f1
            return traArray
            pipelined;
    end;
    /
    create or replace
      package body pkg1
        is
        function f1
            return traArray
            pipelined
          is
              v_rec traRecord;
          begin
              v_rec.ename := 'Sam';
              v_rec.sal := 1000;
              pipe row(v_rec);
              v_rec.ename := 'John';
              v_rec.sal := 1500;
              pipe row(v_rec);
              v_rec.ename := 'Mary';
              v_rec.sal := 2000;
              pipe row(v_rec);
              return;
        end;
    end;
    /
    

    Now, you can:

    SQL> select * from table(pkg1.f1)
      2  /
    
    ENAME             SAL
    ---------- ----------
    Sam              1000
    John             1500
    Mary             2000
    
    SQL>
    

    Don't forget, it will create the generated system types:

    SQL> select type_name from user_types
      2  /
    
    TYPE_NAME
    ------------------------------
    SYS_PLSQL_73305_9_1
    SYS_PLSQL_73305_DUMMY_1
    SYS_PLSQL_73305_34_1
    
    SQL> desc SYS_PLSQL_73305_9_1
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ENAME                                              VARCHAR2(10)
     SAL                                                NUMBER(7,2)
    
    SQL> desc SYS_PLSQL_73305_DUMMY_1
     SYS_PLSQL_73305_DUMMY_1 TABLE OF NUMBER
    
    SQL> desc SYS_PLSQL_73305_34_1
     SYS_PLSQL_73305_34_1 TABLE OF SYS_PLSQL_73305_9_1
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ENAME                                              VARCHAR2(10)
     SAL                                                NUMBER(7,2)
    
    SQL> 
    

    SY.

  • Boolean converter doesn't work is not for the string data type

    Hi gurus,

    I am creating a Boolean converter based on the O/N value for column EO, but every time I select the checkbox that's throwing error "attribute with the value false precision/scale not valid."

    If I add PrecisionRule = 'false' for TestFlag to the EO, I had ORA-12899: value too large for column 'XX '. "" "" FDY_TEST '. "" TEST_FLAG' (real:, maximum of 5: 1).

    Seems that it is still store 'true' / 'false' char to instead "Y/N", even if the POS in the converter class return System.out.println ("getAsObject - value is Y")

    If I use the transitional attribute (TestFlagDummy) and change the EOImpl to TestFlagDummy getter and setter, it works very well.

    I was wondering why the converted does not, in which case the other converter for string I test to convert the value entered for upper case works very well.

    Appreciate any help.

    Definition EO

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

    < attribute

    Name = "TestFlag.

    Precision = '1 '.

    ColumnName = "TEST_FLAG."

    SQLType = 'VARCHAR '.

    Type = "Java.lang.String"

    ColumnType = "VARCHAR2".

    TableName = "FDY_TEST" >

    < DesignTime >

    < name Attr = "_DisplaySize" Value = "1" / >

    < / DesignTime >

    < / attribute >

    Converter class

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

    public class YNConverter

    implements the converter, ClientConverter

    {

    public Object getAsObject (FacesContext facesContext, UIComponent uiComponent, String value)

    {

    If (true".equals (value)) {" "}

    System.out.println ("getAsObject - value is Y");

    }

    else {}

    System.out.println ("getAsObject - value is N");

    }

    return "" true ".equals (value)?". Y":"N";

    }

    public String getAsString (FacesContext facesContext, UIComponent uiComponent, Object value)

    {

    System.out.println ("getAsString - Value is" + value.toString ());

    Return "Y".equals (value.toString ())? "true": "false";

    }

    public String getClientLibrarySource (FacesContext facesContext)

    {

    Returns a null value.

    }

    public Collection < String > getClientImportNames()

    {

    Return Collections.emptySet ();

    }

    public String getClientScript (FacesContext facesContext, UIComponent uiComponent)

    {

    Returns a null value.

    }

    public String getClientConversion (FacesContext facesContext, UIComponent uiComponent)

    {

    Returns a null value.

    }

    }

    USER INTERFACE

    ---

    < af:selectBooleanCheckbox

    label = "#{bindings." TestFlag.label}"id ="sbc1.

    value = "#{bindings." TestFlag.inputValue}.

    Converter = autoSubmit "YNConverter" = "true" / >

    Kind regards

    Ferrere

    Your link should look like this:

    
      
        
      
    
    

    VO attribute similar to the following:

      
    

    and EO attribute similar to the following:

    
      
        
      
    
    

    Dario

  • ODI 12 - problem with LKM SQL for Oracle

    Hi again,

    Three days ago, that I asked about the problem with the data types of data warehouses in models that were missing. After you apply the ideas suggested by Rita (thank you very much ) I got from their work.

    But after that, we came across a new problem. When you run a mapping (Oracle for Oracle databases), it failed on the second stage - ' "work table create. "When we checked the generated code was something like this: '(" CREATE TABLE < work_table_name >). None of the names of columns or data types have been described in parentheses and as expected, the ODI execution error was "invalid identifier". It seems that API odiRef.getColList(params)%> does not work. I tried loading using LKM Oracle Oracle (DB LINK) but once again the columns are missing in the generated script.

    I have to mention the master and work repositories are different databases from Oracle and ODI Agent is not installed because of some problems.

    We are still beginners of ODI and would appreciate any help from more experienced guy (or other beginners).

    Thank you in advance.

    Just by chance, we found the soluton today!

    The reason of missing generated code was that the description of the types of data was not entirely cofigured.

    We found that the fields "create table syntax" and "'syntax of data accessible in writing' in each type of data in the topology definition were empty." After filling them, the generation of the script is running properly.

    Before that we had problems with missing data types in models and we realized the reverse engineering of the types of data, but obviously it is insufficient.

    Thanks to all those who participated in the discussion and tried to help us!

  • Table of functions and direct requests for NUMBER data types database

    Hello. I call a number of functions table of our Enterprise BI server, and I chose to do this by using direct database requests (I believe you can also call functions table in the physical layer of the repository, but is not what I do). The problem is that whenever I go back any number of the table function which is not a whole number (1.23, for example), BI assigns the INTEGER data type to the field rather than the data type DOUBLE, rounded so my number to the nearest integer. Here is a short example:

    Create these 3 database objects:

    CREATE or REPLACE TYPE my_row AS OBJECT (my_num NUMBER);

    CREATE or REPLACE TYPE my_tab AS TABLE OF THE my_row;

    FUNCTION to CREATE or REPLACE my_table_function RETURN my_tab
    PIPELINED IS
    BEGIN
    PIPE ROW (my_row (1.23));
    END;
    /


    Make this your request at your request Direct to database:

    SELECT my_num FROM table (my_table_function);


    This query returns correctly '1.23' when it is called from the database. In BI, on the other hand, it returns a value of '1' (and the field of labels an INTEGER rather than data type DOUBLE). If at the request of data Direct you change column properties-> data-> decimal from 0 to 2 Format, then it displays is not surprising "1.00". I then tried to change MY_ROW. Data type of MY_NUM by explicitly specifying the precision and no luck. BI still labels this field as an INTEGER. Then I started to try to deceive BI massaging the SQL statement itself. None of the following worked:

    SELECT to_number (my_num) as my_num2 FROM table (my_table_function);
    SELECT my_num2 + 0.01 as my_num3 FROM (SELECT my_num - 0.01 AS my_num2 FROM table (my_table_function));
    SELECT to_number (to_char (my_num)) as my_num2 FROM table (my_table_function);
    SELECT to_number (substr (to_char ('x' | my_num), 2)) as my_num2 FROM table (my_table_function);

    Now, I found a solution, but I'm surprised that I have to resort to that:

    SELECT * FROM (SELECT / * + NO_MERGE * / table my_num (my_table_function));

    Is anyone out there knows a better way to do it? The above is a hack in my opinion. :)

    Thanks in advance for any input.

    -Jim

    Yes, it's really amazing.
    But I got it.

    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER(10,2));
    

    and in your SQL:

    SELECT cast(my_num as double precision) as my_num2 FROM table(my_table_function);
    

    I have the good result and I see the numbers after the decimal point.
    Very delicate!

    Published by: gerardnico on July 7, 2009 14:55 change number (10.2) in double precision... pffff

  • For the complex data type, how to generate the Dll with compatible interface to C/C++

    Hello

    I used the Labview FPGA module to develop test equipment. Now, I need to write a driver that is to be a Dll with compatible interface to C/C++ for this equipment. So that my client who is familiar with C/C++ can call the driver without any study on labview. But I had a few problem on how to convert labview for C/C++ data complex data type. To clearly explain to my question, I have attached a simple example. (see attachment) I try to generate a Dll for the attached example VI and get the the function prototype at the head of the files as below:

    ' void OpenFpgaReference (LStrHandle * RIODevice, TD1 * errorIn, LVRefNum * FPGAVIReferenceOut, TD1 * errorOut).

    As you have known, the type of data "LStrHandle * RIODevice" and "LVRefNum * FPGAVIReferenceOut" Labview data format are. C/C++ do not have this kind of data type and can not reconige it. As a result, I can't call the Dll of C/C++ programming language. How to convert these two data type of labview for the C/C++ compatible data format, and then build the Dll? Anyone know about this?

    The answer is really apprecaited! Thank you in advanced.

    Ivan.Chen wrote:

    As I found in the following article:

    http://digital.NI.com/public.nsf/WebSearch/FB001AA027C8998386256AAD006C142D?OpenDocument

    LVRefNum is the name of resource of LabVIEW VISA or refnum, and "it is impossible to convert LabVIEW VISA name of resource or refnum VISession valid ID."
    This means that external code modules can not access & control the session VISA which is open by labview. But for my purposes, I will not attempt to access this VISA extenal code(C/C++) session. I just hope that save this session VISA in the external code once I opened it in Labview dll; and pass it to the labview dll when needed. While I have not need to login again when I need to control the device. Is it possible to do?

    A LVRefNum is really just a single int32 value. Its meaning is useless for other environments than those who created it so that you Michael not any what in C/C++ caller but pass it back to other functions in your DLL, but this often isn't a problem at all.

    You can take the following statement of the LabVIEW extcode.h headers and add them to your delabviewed header files to make it work in such a way.

    #define Private (T) typedef struct T # _t {void * p ;} * T}

    Private (LVRefNum);

    The LStrHandle you must set a standard C string instead in your export DLL and document what is the size of the string buffer should have if it is an output parameter.

    TD1 error clusters should also be divided into their parameters (C compatible) separate for all items or just to the left of suite entirely.

    Rolf Kalbermatter

  • IOM 9.1.0.2 - Multi Weblogic JDBC for Oracle RAC Data Sources

    IOM-IOM 9.1.0.2 BP07 supports Weblogic JDBC Multi Data Sources (Services > JDBC > Multi Data Sources) for Oracle RAC instead of insert the "Oracle RAC JDBC URL" on xlDS and xlXADS JDBC Data Sources (Services > JDBC > Data Sources > xlDS | xlXADS > survey login > URL)?
    If so, are there any other changes that must be made on IOM, or simply to change data sources?

    Yes, it is supported. You install against a single instance directly of the Rac server. Then you update the file config.xml and jdbc resources in your server weblogic with the full address of rac. It is documented for installation against CARS. http://docs.Oracle.com/CD/E14049_01/doc.9101/e14047/database.htm#insertedID2

    -Kevin

  • Convert the Sql for Oracle script

    Could someone help me convert the sql script in oracle below

    -- EXEC SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport '2005','2010','09048','IL'    
    ALTER PROCEDURE SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport    
    --DECLARE     
    @StartYY AS VARCHAR(4),    
    @EndYY AS VARCHAR(4),    
    @AgentCode AS VARCHAR(9),    
    @CompanyCode AS VARCHAR(4)    
        
    AS    
        
    DECLARE @ProfileYYYYMM AS VARCHAR(6), @SQLStr1 AS VARCHAR(8000),@SQLStr2 AS VARCHAR(8000), @SQLStr3 AS VARCHAR(8000)    
        
    SET @ProfileYYYYMM = '201005'    
        
    SET @SQLStr1 = ''    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @CompAvgCount AS  DECIMAL(38,2), @CompAvgAP AS  DECIMAL(38,2), @CompInforceAP AS DECIMAL(15,2), @CompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @CompInforceCount NUMERIC, @CompSurrenderCount NUMERIC,@ALCompInforceAP AS DECIMAL(15,2), @ALCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ALCompInforceCount NUMERIC, @ALCompSurrenderCount NUMERIC,@ILCompInforceAP AS DECIMAL(15,2), @ILCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ILCompInforceCount NUMERIC, @ILCompSurrenderCount NUMERIC '    
      
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblAgentNumber TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
      
    SET @SQLStr1 = @SQLStr1 + '  DECLARE @tblmineInForce TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblmineSurrender TABLE '   
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '     
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblAgentNumber '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT AgentName, AgentNumber, AgentRank '    
    SET @SQLStr1 = @SQLStr1 + ' FROM [SUMYOLAP0001].aetnaildb.dbo.agentprofile'+ @ProfileYYYYMM +' AgtProfile '    
    SET @SQLStr1 = @SQLStr1 + ' WHERE (LEN(agentnumber) = 5 and (left(agentnumber,1) between ''0'' and ''8'' or left(agentnumber,1) = ''A'')) '    
    SET @SQLStr1 = @SQLStr1 + ' AND (Amname not like ''%COMPANY%'' OR Amname not like ''%DIRECT%'' OR Amname not like ''%MARKETsmp%'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND agencynumber not in (''ILS'',''PLS'',''99999'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND LEFT(agencynumber,2) not in (''CD'',''DR'') AND LEFT(agencynumber,3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND RIGHT(RTRIM(agencynumber),2) not in (''CD'',''DR'') AND RIGHT(RTRIM(agencynumber),3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND companycode = ''IL'' '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineSurrender '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN ('''+ @CompanyCode +''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''S'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompSurrenderCount = COUNT(1), @CompSurrenderAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineSurrender S '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON S.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND S.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineInforce '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''' + @CompanyCode + ''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''I'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompInforceCount = COUNT(1), @CompInforceAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineInforce I '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON I.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND I.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgCount = ROUND(ISNULL(@CompSurrenderCount,0) * 100 / ( ISNULL(@CompSurrenderCount,0) + @CompInforceCount),2) '     
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgAP = ROUND(ISNULL(@CompSurrenderAP,0) * 100 / ( ISNULL(@CompSurrenderAP,0) + @CompInforceAP),2) '     
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblODSmine_Policy TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Company_Code] VARCHAR(4), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_Policy_No] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Cont_Status] VARCHAR(1), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_Premium] DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + '  [No_count] NUMERIC '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr2 = 'INSERT INTO  @tblODSmine_Policy '    
    SET @SQLStr2 = @SQLStr2 + ' SELECT DISTINCT AgtProfile.AgentName, AgtProfile.AgentNumber, '    
    SET @SQLStr2 = @SQLStr2 + ' AgtProfile.AgentRank,mine.company_code, mine.mine_policy_no, mine.cont_status, mine.Annl_Premium, 1.0 as no_count '    
    SET @SQLStr2 = @SQLStr2 + ' FROM @tblAgentNumber AgtProfile '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN [SUMYOLAP0001].aetnaildb.dbo.COMAGH COMAGH '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = COMAGH.AHAGTN '    
    SET @SQLStr2 = @SQLStr2 + ' AND (AHAMNO = ''' + @AgentCode + ''' OR AHUMNO = ''' + @AgentCode + ''' OR AHAGNO = ''' + @AgentCode + ''') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO IN (''AL'',''IL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsagent_role Role '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = Role.servicsmpagent_code '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsmine_policy mine '    
    SET @SQLStr2 = @SQLStr2 + ' ON Role.company_code = mine.company_code '    
    SET @SQLStr2 = @SQLStr2 + ' AND Role.mine_policy_no = mine.mine_policy_no '    
    SET @SQLStr2 = @SQLStr2 + ' AND mine.cont_status IN (''S'',''I'') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code IN (''AL'',''IL'') '    
    END    
    ELSE     
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' AND YEAR(mine.effective_date) BETWEEN '+ @StartYY +'  AND  '+ @EndYY +' '    
        
    SET @SQLStr3 = 'SELECT AgentName, AgentRank, AgentNumber, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END)) AS Surrrender_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''I'' THEN no_count ELSE 0 END)) AS InForce_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) AS SurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''I'' THEN Annl_premium ELSE 0 END) AS InForceAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN count(*) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END) * 100 / count(*))) END AS AgtSurrenderCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN SUM(Annl_premium) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) * 100 / SUM(Annl_premium))) END AS AgtSurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100),@CompAvgCount) AS CompAvgCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100), @CompAvgAP) AS CompAvgAP '    
    SET @SQLStr3 = @SQLStr3 + ' FROM @tblODSmine_Policy '    
    SET @SQLStr3 = @SQLStr3 + ' GROUP BY AgentName, AgentRank, AgentNumber '    
        
    EXEC (@SQLStr1 + @SQLStr2 + @SQLStr3)    
    --PRINT (@SQLStr1 + @SQLStr2 + @SQLStr3)    

    Yes.

    1. the scrap code.
    2. get the specification of the requirements of business origin.
    3. learn PL/SQL.
    4. write the PL/SQL code to meet the requirements of the company.

  • Convert a statement of SQL for Oracle Server Update

    Hello
    I need to convert an update statement written for SQL Server to run on Oracle.
    the update is:

    UPDATE TABLE1
    SET TBL2 = CDate. CDate
    OF TABLE1 TBL1
    JOIN TABLE2 ON TBL2 TBL2. Code = TBL1. TBL2Code
    JOIN TABLE3 TBL3 ON TBL3. ID = TBL1. ID
    WHERE TBL3. TypeCode = '07'

    How can I make compatible with oracle?

    Thank you!!

    Try this...

    MERGE INTO table1 t1
         USING (SELECT t2.cdate cdate, t1.ROWID ri
                  FROM table2 t2, table3 t3, table1 t1
                 WHERE     t2.code = t1.tbl2code
                       AND t3.id = t1.id
                       AND t2.typecode = '07') src
            ON (t1.ROWID = src.ri)
    WHEN MATCHED
    THEN
       UPDATE SET t1.cdate = src.cdate
    
  • Please help to translate ms access sql for oracle

    Hello

    I work by the migration of sql processes for updating legacy 11g access ms stuff we already use for a lot of other business processes.

    I need advice with the code below if someone could help please.

    SELECT (ABC. NAME = ABC. + (ABC. FAMILY NAME) INITS = ABC. INITIALS or IsNull (ABC. INITS) or IsNull (ABC. +(ABC.) INITIALS)) BDAY = ABC. BIRTHDAY or IsNull (ABC. BDAY)) AS [success]

    The results in the column are successes; 0 = no match fields, matches, 2 = 2 fields match, 3 = 3 fields are the field of 1 = 1.

    It works 3 concatenations and function success fills a column with a numeric value that reflects the success.

    in General, it seems to be almost a Where statement but clause to choose and it operates fortunately access.

    There are a lot more code, but ironically it is fairly standard, once the brackets [] around the table with spaces names are deleted and search and replacement of the legacy! between the table and column names.

    Your suggestions are greatly appreciated.

    Cheers, Peter

    so you'd:

    SELECT DECODE (ABC. NAME, ABC. SURNAME, 1, 0)

    + DECODE (NVL (ABC. INITS, ABC. (INITIALS), NVL (ABC. INITIALS, ABC. INITS), 1, 0)

    + DECODE (NVL (ABC. BROWN, ABC. (BIRTHDAY), ABC. BIRTHDAY, 1, 0) as a result

    Of...

    Returns + 1 for all matches (so 0 to do nothing, 1 for 1, 2, 2,...)

    the matches are: the same name (both null is considered to be identical too)

    Inits and identical initials (null or one of them null is considered identical too)

    bday and identical birthday (both null or null bday is considered identical too)

    HTH

Maybe you are looking for