Logical error in this procedure

Hi,
I have creted this procedure when i execute it,
procedure created successfully, but when i run the procedute then it gives this error
*ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "POI_RELEASE.SPECIAL_YPOL", line 13
ORA-06512: at line 1
CREATE or REPLACE PROCEDURE SPECIAL_YPOL
(tablename IN VARCHAR2,
     fieldname IN VARCHAR2)
AUTHID CURRENT_USER
IS
BEGIN
EXECUTE IMMEDIATE 'Update '      
                    ||tableName
                    || ' set '
                    ||fieldname
                    ||' =REPLACE('     
                    ||fieldname     
               ||',CHR(38) || ''QUOT,'',CHR(39)) WHERE'
                    ||FIELDNAME
                    ||'LIKE ''%'' || CHR(38) || ''QUOT,''';
OMMIT;
END;
/

If this was ancient times, and you wrote this code to run on any of my databases, I would have handed your over to the SQL Inquisition for showing you the error of your ways.
This is exactly how NOT to write code in Oracle. This is exactly how to cause performance problems in Oracle. This is exactly how to trash and fragment the Oracle Shared Pool. This is exactly how to design code and applications that are fragile and generate weirdly non-wonderful runtime errors.
On the performance side... this is what I posted not even a week ago to show just how stupid this approach you're using is:
SQL> create table footab( n number );
Table created.
SQL> set timing on
SQL>
SQL> -- doing a 100,000 inserts using a bind variable
SQL> declare
2 sqlInsert varchar2(1000);
3 begin
4 sqlInsert := 'insert into footab( n ) values( :0 )';
5 for i in 1..100000
6 loop
7 execute immediate sqlInsert using i;
8 end loop;
9 end;
10 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:04.91
SQL>
SQL> -- doing a 100,000 inserts without using a bind variable
SQL> declare
2 sqlInsert varchar2(1000);
3 begin
4 -- need to built a unique SQL for each insert
5 for i in 1..100000
6 loop
7 sqlInsert := 'insert into footab( n ) values( '||i||' )';
8 execute immediate sqlInsert;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
Elapsed: 00:05:21.47
SQL>So.. you want to turn something that should run in a few seconds, to something that takes several minutes to run.
Great stuff!! Pardon me, but I think I will need yet another cup of coffee to see me through this morning's browsing of Oracle Forums..

Similar Messages

  • What' s the error in this procedure

    set serveroutput on
    create or replace PROCEDURE p1
    (v_quote IN number,
    v_stock IN Number,
    v_approval OUT number)
    IS
    BEGIN
    V_approval:=v_quote + v_stock;
    dbms_output.put_line(v_approval);
    END;
    call p1(7,8);

    But your procedure has 3 arguments, not 2. You must specify all of them, the last being a variable where the result can go. Perhaps you want something like this:
    SQL> create or replace PROCEDURE p1 (v_quote IN number,
      2                                  v_stock IN Number,
      3                                  v_approval OUT number) IS
      4  BEGIN
      5     V_approval:=v_quote + v_stock;
      6  END;
      7  /
    Procedure created.
    SQL> var  approval number
    SQL> exec p1(7, 8, :approval);
    PL/SQL procedure successfully completed.
    SQL> print approval
                APPROVAL
                      15(by the way, you shouldn't double post. Especially 6 minutes apart)

  • What's the logic error in this piece of  code?

    Hello All:
    I am doing a simple program dealing with restaurant operation. The problem is that when customer click check out button, the status of the corresponding table object doesn't change to "Vacant", whereas it should as according to my design.
    Following is the piece of code from the Interface class, where check out button (outB) is declared and add with an ActionListener:
    pCentre.setLayout(new GridLayout(3,2));
         outL = new Label("Pls type your table number to check out");
         outTable = new TextField(30);
         outMsg = new TextField(30);
         outB = new Button("Check Out");
         outB.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e)
              int tbNo = Integer.parseInt(outTable.getText());
              if (tbNo<1 || tbNo>5)
                   outMsg.setText("This table doesn't exist!");
              else
                   outMsg.setText("Thank you. See you again.");
    proc.checkout(tbNo);
              }// proc is the handler of Processor Class, which contain the checkout method.
    this is Processor class:
    public class Processor
    DataStore ds;
    public Processor()
    ds = new DataStore();
    public int searchTable(CusmInfo ci)
    for (int i=0; i<5; i++)
         if((ds.tInfo.tCap > ci.cNo) &&
         (ds.tInfo[i].tStat.equals("Vacant")))
         ds.tInfo[i].tStat = ci.name;
              return i+1;
         return -1;
         public String check(int i)
         if(i<1 || i>5)
         return("Table number exceeded");
    else
         return ds.tInfo[i-1].tStat;
    public void checkout(int i)
         ds.tInfo[i-1].tStat = "Vacant";     
    This is DataStore class which caters for table objects:
    public class DataStore
    public TableInfo[] tInfo = new TableInfo[5];
    public DataStore()
    tInfo[0] = new TableInfo(1, 4, "Vacant");
    tInfo[1] = new TableInfo(2, 4, "Vacant");
    tInfo[2] = new TableInfo(3, 6, "Occupy");
    tInfo[3] = new TableInfo(4, 6, "Occupy");
    tInfo[4] = new TableInfo(5, 8, "Vacant");
    public TableInfo getTableInfo(int i)
    return tInfo[i];
    class TableInfo
    int tNo;
    int tCap;
    String tStat;
    public TableInfo(int n, int c, String s)
    tNo = n;
         tCap = c;
         tStat = s;
    Why is it that after clicking the outB button, the status of the table is still customer's name but not "vacant". It seems the checkout method doesn't work. Is it because we can change the attribute of table object directly? BTW, the rest of methods in Prossor class all work properly.      

    Lol, "piece" of code is good...
    First, you should encapsule your code in "code" tags ([_code_] and [_/code_] w/o the underscores) so it will be much more readable.
    Then maybe you should assign some dukedollars to attract people to do the work for you. This is not an easy one-minute-thought question like "I'm new to java how do i print out text to stdout?" ....
    Do that and I'll check back to have a look...

  • My problem is on my Windows PC.  I am getting the error message, "The procedure entry point sqlite_3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.  I am told this is related to iTunes.  Any help?

    I use both a Mac and a PC.  My problem is on my Windows 7 PC.  I am getting the error message, "The procedure entry point sqlite_3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.  I am told this is related to iTunes.  Any help out there?  Thanks

    With Windows Explorer, navigate to your C:\Program Files\Common Files\Apple\Apple Application Support folder.
    Copy the SQLite3.dll that you should find there, navigate to the nearby Mobile Device Support folder, and Paste it in there also.
    Restart the programme all should be well
    In case that your OS is (64 bit)
    1. Open windows explorer, go to location C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    2. Copy file "SQLite3.dll"
    3. Now paste it in the folder  C:\Program Files (x86)\Common Files\Apple\Mobile Device Support
    4. Restart the programme, it should not display that message, it should be clear.
    Good Luck

  • I just tried updating to iTunes 10.7 on my pc and when I try to launch it I get this error message-The procedure entry point AVCFPlayerSetDirect3DDevice could not be located in the dynamic library AVFoundationCF.dll.  Any Ideas?

    I just tried updating to iTunes 10.7 and when I try to launch it I get this error message-The procedure entry point AVCFPlayerSetDirect3DDevice could not be located in the dynamic library AVFoundationCF.dll.  Them it tells me to re-install iTunes and the same thing happens again.  Any Ideas?

    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. If you're using Vista or 7, now head into your Uninstall a program control panel, select "Apple Application Support" and then click "Repair". If you're using XP, head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (If you've got XP, although the procedure is for Vista and 7, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever

  • Recently tried to update iTunes 12.0.1 and got this error message:  The procedure entry point ADAdPolicyEngine_DidEnterStation could not be located in the dynamic link library iAdCore.dll.

    I recently tried to update iTunes to 12.0.1 and got this error message:
    The procedure entry point ADAdPolicyEngine_DidEnterStation could not be located in the dynamic link library iAdCore.dll.
    After that, I get:  iTunes did not install properly.  Reinstall iTunes.
    I tried downloading iTunes again (without uninstalling it) and it won't download.
    Any suggestions?

    Thanks so very much, I have been looking for an answer to this for
    almost a week and just thought i'd look again and in 2 minutes my iTunes opened YIPPEE
    I must have installed deleted everything in order at least 15 times
    Is there anyways this cane get pinned to stay at top as it works and save people ploughing
    through post after post which is just asking the same question.
    Off to back up and I Cloud back up and see how it works without sidebar
    again thank you

  • Updating iTunes 12.1 and get error message "The procedure entry point CMBlockBufferCopyDataBytes could not be located in the dynamic link library CoreMedia.dll - what went wrong and how to resolve this?

    Updating iTunes 12.1 and get error message "The procedure entry point CMBlockBufferCopyDataBytes could not be located in the dynamic link library CoreMedia.dll". What went wrong and how to resolve this?

    Entry point errors can often be fixed by deleting the offending dll, then repairing the component it is part of.
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If the advice above doesn't resolve things you could try this alternate version:
    iTunes 12.1.0.71 for Windows (64-bit - for older video cards) - itunes64setup.exe (2015-01-28)
    which is a 64-bit installer for the 32-bit version of the core application, similar to previous 64-bit releases.
    Or roll back to the previous build:
    iTunes 12.0.1.26 for Windows (32-bit) - iTunesSetup.exe (2014-10-16)
    iTunes 12.0.1.26 for Windows (64-bit) - iTunes64Setup.exe (2014-10-16)
    tt2

  • I downloaded the latest version of itunes.  Now I cannot open iTunes.  I receive this error message: The procedure entry point AVCFAssetCreateWithByteStreamAndOptions could not be located in the dynamic link library AVfoundationCF.dll.  Thoughts?

    I downloaded the latest version of iTunes on my PC.  Now I cannot open iTunes.  I receive the following error message: "The procedure entry point AVCFAssetCreateWithByteStreamAndOptions could not be located in the dynamic link library AVfoundationCF.dll"  After pressing the "OK" button I receive a second error message: 'iTunes not installed correctly.  Please reinstall iTunes.  Error 7 (Windows error 127)".  I've uninstalled iTunes and reinstalled to no avail.  I've also eliminated the temp files (per suggestions on the trouble-shooting page) and no luck.  I also tried system restore and that did not fix the problem.  Any thougths on a repair?   

    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. Head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (Although the procedure is for Vista and 7 and you've got XP, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever since I did that my itunes won't open any more.  Itunes starts but before anything loads a

  • Unexpected error in stored procedure

    Howdy group...
    I have a stored procedure in Oracle;
    p_BILL_TO_ADDRESS1 IN CONT_ADDRESS.ADDRESS1%TYPE
    Default NULL, --VC(50)
    With a condition;
    IF p_BILL_TO_ADDRESS1 is NULL THEN
    Raise_Application_Error(-20100,'BILL TO Address cannot be a NULL Value');
    END IF;
    I have some PHP code that tries to insert the data;
    $addr = '1234 Main';
    $sth = oci_parse($conn, "begin D_ACCT_NEW(:p_BILL_TO_ADDRESS1, :P_Error_Return );end;");
    oci_bind_by_name($sth, ":p_BILL_TO_ADDRESS1", $addr, -1);
    oci_bind_by_name($sth, ":P_Error_Return", $errorcode, -1); oci_execute($sth);
    echo $errorcode;
    And I always get the following error;
    Warning: oci_execute() [function.oci-execute]: ORA-06502: PL/SQL:
    numeric or value error ORA-06512: at "SYSADM.D_ACCT_NEW", line 483
    ORA-20100: BILL TO Address cannot be a NULL Value ORA-06512: at line 1 in /home/foo/bar/glorp.php on line 25
    If anyone on the list understands the intricacies of Oracle, could you sooth my aching head and help me to understand what is going on here? I have RTFM and the following article from the PHP Oracle Cookbook;
    http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_sps.html
    ;and I still am clueless. Thanks a million in advance!
    null

    Here is the entire procedure. This is developed by a third party and I cannot chnage it, I just need to be able to write PHP to interact with it. Thanks for your help on this.
    create or replace Procedure D_ACCT_NEW
    -- Return Parameters
    p_Return OUT Varchar2,                -- CONTRACT_ID
    P_Error_Return OUT Varchar2,                -- Error Message if any
    -- Input Parameters
    p_USERNAME IN CONT_CUST.ENTRY_BY%TYPE Default NULL, --VC(40)
    p_ALT_ACCOUNT_NO IN CONT_CUST.ALT_ACCOUNT_NO%TYPE Default NULL, -- N/A
    p_ALT_SUB_ACCOUNT_ID IN CONT_CUST.ALT_SUB_ACCOUNT_ID%TYPE Default NULL, -- N/A)
    p_PARENT_CONTRACT_ID IN CONT_CUST.PARENT_CONTRACT_ID%TYPE Default NULL,
    -- Contact Data
    p_CUST_TYPE IN CUSTOMERS_INFO.CUST_TYPE%TYPE Default NULL, --VC(1)  I/B
    p_CONTACT_F_NAME IN CUSTOMERS_INFO.FIRST_NAME%TYPE           Default NULL, --VC(100)
    p_CONTACT_L_NAME IN CUSTOMERS_INFO.LAST_NAME%TYPE           Default NULL, --VC(100)
    p_CONTACT_MIDDLE_INITIAL IN CUSTOMERS_INFO.MIDDLE_INIT%TYPE      Default NULL, --VC(10)
    p_CONTACT_TITLE IN CUSTOMERS_INFO.NAME_TITLE%TYPE           Default NULL, --VC(10)
    P_CONTACT_SUFFIX IN CUSTOMERS_INFO.NAME_SUFFIX%TYPE      Default NULL, --VC(10)
    p_COMPANY_NAME IN CUSTOMERS_INFO.COMPANY_NAME%TYPE      Default NULL, --VC(50)
    p_HOME_PHONE_NUM IN CUSTOMERS_INFO.HOME_PHONE_NUM%TYPE Default NULL, --VC(25)
    p_BUSINESS_PHONE_NUM IN CUSTOMERS_INFO.BUSINESS_PHONE_NUM%TYPE Default NULL, --vn(25)
    p_COUNTRY_ID IN CUSTOMERS_INFO.COUNTRY_ID%TYPE Default NULL, --VN(4,0)
    p_EMAIL_ADDRESS IN CUSTOMERS_INFO.EMAIL_ADDRESS%TYPE      Default NULL, --VC(50)
    P_Contact_Name1 IN CUSTOMERS_INFO.other_field1%TYPE Default NULL,
    P_Contact_Name2 IN CUSTOMERS_INFO.other_field2%TYPE Default NULL,
    P_Contact_Name3 IN CUSTOMERS_INFO.other_field3%TYPE Default NULL,
    -- Bill To Data
    p_BILL_TO_NAME IN CONT_ADDRESS.NAME%TYPE                Default NULL, --VC(50)
    p_BILL_TO_ADDRESS1 IN CONT_ADDRESS.ADDRESS1%TYPE           Default NULL, --VC(50)
    p_BILL_TO_ADDRESS2 IN CONT_ADDRESS.ADDRESS2%TYPE           Default NULL, --VC(50)
    p_BILL_TO_CITY IN CONT_ADDRESS.CITY%TYPE                Default NULL, --VC(50)
    p_Bill_To_County IN CONT_ADDRESS.COUNTY%TYPE Default NULL, --VC(50)
    p_BILL_TO_STATE IN CONT_ADDRESS.STATE%TYPE Default NULL, --VC(25)
    p_BILL_TO_ZIP IN CONT_ADDRESS.POSTAL_CODE%TYPE Default NULL, --VC(20)
    p_BILL_TO_COUNTRY IN CONT_ADDRESS.COUNTRY%TYPE           Default NULL, --VC(50)
    p_BILL_TO_GEOCODE IN CONT_ADDRESS.GEOCODE%TYPE           Default NULL, --VC(15)
    p_BILL_TO_BUS_OR_RES_FLAG IN CONT_ADDRESS.BUS_OR_RES_FLAG%TYPE Default NULL, --VC(1)
    p_BILL_TO_INSIDE_CORP_FLAG IN CONT_ADDRESS.INSIDE_CORP_FLAG%TYPE Default NULL, --VC(1)
    p_TAX_REGION_ID IN CONT_CUST.TAX_REGION_ID%TYPE Default NULL, --VN(10,0)
    -- Credit Score Data
    p_SOC_SEC_NUM            IN CUSTOMERS_INFO.SOC_SEC_NUM%TYPE                Default NULL,  VC(20)
    p_ID_OR_DANDB_TYPE IN CUSTOMERS_INFO.ID_METHOD%TYPE           Default NULL, --VC(50)
    p_ID_REGION IN CUSTOMERS_INFO.ID_REGION%TYPE           Default NULL, --VC(25)
    p_ID_OR_DANB_NO          IN CUSTOMERS_INFO.IDENTIFICATION_NO%TYPE          Default NULL,  VC(25)
    p_TAX_ID IN CUSTOMERS_INFO.IDENTIFICATION_NO%TYPE Default NULL, --VC(25)
    p_DRIVER_LICENSE_NO IN CUSTOMERS_INFO.DRIVER_LICENSE_NO%TYPE Default NULL, --VC(25)
    p_PHOTO_ID_VALUE IN CUSTOMERS_INFO.PHOTO_ID_VALUE%TYPE Default NULL, --VC(25)
    p_PHOTO_ID_STATE IN CUSTOMERS_INFO.PHOTO_ID_STATE%TYPE Default NULL, --VC(25)
    pc_BIRTH_DATE IN Varchar2      Default NULL,
    p_ORIG_INTERNAL_SCORE IN CUSTOMERS_INFO.CREDIT_SCORE%TYPE      Default NULL, --VC(10)
    p_INTERNAL_SCORE IN CUSTOMERS_INFO.INTERNAL_CREDIT_SCORE%TYPE     Default NULL, --VC(10)
    p_CRED_SCORE_ADDRESS1 IN CUSTOMERS_INFO.ADDRESS1%TYPE          Default NULL, --VC(100)
    p_CRED_SCORE_ADDRESS2 IN CUSTOMERS_INFO.ADDRESS2%TYPE           Default NULL, --VC(100)
    p_CRED_SCORE_CITY IN CUSTOMERS_INFO.ADDRESS3%TYPE           Default NULL, --VC(100)
    p_CRED_SCORE_COUNTY IN CUSTOMERS_INFO.ADDRESS4%TYPE Default NULL, --VC(100)
    p_CRED_SCORE_STATE IN CUSTOMERS_INFO.ADDRESS5%TYPE           Default NULL, --VC(100)
    p_CRED_SCORE_ZIP IN CUSTOMERS_INFO.ADDRESS6%TYPE           Default NULL, --VC(100)
    p_CRED_SCORE_COUNTRY       IN CUSTOMERS_INFO.ADDRESS6%TYPE                      Default NULL,  VC(100)
    p_IntScore_Override_Date   IN CUSTOMERS_INFO.OTHER_FIELD19%TYPE       Default NULL,  N/A
    pc_CURR_ADDRESS_DATE IN Varchar2 Default NULL,
    p_PREV_ADDRESS1 IN CUSTOMERS_INFO.PREV_ADDRESS1%TYPE      Default NULL, --VC(50)
    p_PREV_ADDRESS2 IN CUSTOMERS_INFO.PREV_ADDRESS2%TYPE      Default NULL, --VC(50)
    p_PREV_CITY IN CUSTOMERS_INFO.PREV_CITY%TYPE           Default NULL, --VC(50)
    p_PREV_COUNTY IN CUSTOMERS_INFO.PREV_COUNTY%TYPE Default NULL, --VC(50)
    p_PREV_STATE IN CUSTOMERS_INFO.PREV_STATE%TYPE           Default NULL, --VC(25)
    p_PREV_ZIP IN CUSTOMERS_INFO.PREV_POSTAL_CODE%TYPE Default NULL, --VC(20)
    p_PREV_COUNTRY IN CUSTOMERS_INFO.PREV_COUNTRY%TYPE      Default NULL, --VC(25)
    -- Billing Settings
    p_BillCycle IN CONT_CUST.BILLCYCLE%TYPE Default 0,
    p_BILL_BY_EMAIL IN CUSTOMERS_INFO.BILL_BY_EMAIL%TYPE Default 'N', --VC(1)
    p_DETAIL_BILLING IN CONT_CUST.DETAIL_BILLING%TYPE      Default 'Y', --VC(1)
    p_BILL_LANGUAGE_ID IN CONT_CUST.BILL_LANGUAGE_ID%TYPE Default NULL, --VN(10,0)
    p_BILL_LAYOUT_ID IN CONT_CUST.BILL_LAYOUT_ID%TYPE      Default NULL, --VN(10,0)
    p_BILL_CURRENCY_ID IN CONT_CUST.BILL_CURRENCY_ID%TYPE Default NULL, --VN(10,0)
    p_FIXED_CURRENCY IN CONT_CUST.FIXED_CURRENCY%TYPE      Default NULL, --VC(1)
    p_APPLY_LATE_FEES IN CONT_CUST.APPLY_LATE_FEES%TYPE      Default NULL, --VC(1)
    p_USAGE_THRESHOLD IN CONT_CUST.USAGE_THRESHOLD%TYPE Default NULL, --VN(15,2)
    -- Payment Data
    p_AUTO_PAYMENT_FLAG IN CONT_PAYMENTS_INFO.AUTO_PAYMENT_FLAG%TYPE Default NULL, --VC(1)
    p_PAYMENT_METHOD IN CONT_PAYMENTS_INFO.PAYMENT_METHOD%TYPE      Default NULL, --VC(10)
    p_DEF_PAY_BANK_NAME IN CONT_PAYMENTS_INFO.BANK_NAME%TYPE      Default NULL, --VC(100)
    p_DEF_PAY_OWNER_NAME IN CONT_PAYMENTS_INFO.OWNER_NAME%TYPE      Default NULL, --VC(100)
    p_DEF_PAY_CARD_ADDRESS IN CONT_PAYMENTS_INFO.OWNER_ADDRESS%TYPE      Default NULL, --VC(100)
    P_DEF_PAY_ADDRESS2 IN CONT_PAYMENTS_INFO.OWNER_ADDRESS%TYPE Default NULL,
    P_DEF_PAY_CITY IN CONT_PAYMENTS_INFO.OWNER_ADDRESS%TYPE Default NULL,
    P_DEF_PAY_COUNTY IN CONT_PAYMENTS_INFO.OWNER_ADDRESS%TYPE Default NULL,
    P_DEF_PAY_STATE IN CONT_PAYMENTS_INFO.OWNER_ADDRESS%TYPE Default NULL,
    p_DEF_PAY_CARD_NUMBER IN CONT_PAYMENTS_INFO.BANK_CC_NUMBER%TYPE      Default NULL, --VC(50)
    p_DEF_PAY_CARD_TYPE IN CONT_PAYMENTS_INFO.CC_CARD_TYPE_ID%TYPE Default NULL, --VC(10)
    pc_DEF_PAY_CARD_EXPIRES IN Varchar2 Default NULL,
    p_DEF_PAY_AMEX_CID IN CONT_PAYMENTS_INFO.CC_AMEX_CID%TYPE      Default NULL, --VC(50)
    p_DEF_PAY_ZIP IN CONT_PAYMENTS_INFO.CARDHOLDER_POSTAL_CODE%TYPE Default NULL, --VC(10)
    P_DEF_PAY_ROUTING_NO IN CONT_PAYMENTS_INFO.ABA%TYPE Default NULL,
    P_DEF_CHK_ACCOUNT_TYPE IN CONT_PAYMENTS_INFO.ACCOUNT_TYPE%TYPE Default NULL,
    p_DEF_PAY_CARD_CCV2 IN CONT_PAYMENTS_INFO.CC_CCV2_NUMBER%TYPE Default NULL,
    -- Other
    p_SALES_REP_FLAG IN CUSTOMERS_INFO.SALES_REP_FLAG%TYPE Default NULL, --VC(1)
    pc_ACT_DATE IN Varchar2 Default NULL,
    pc_ENTRY_DATE IN Varchar2 Default NULL,
    p_STATUS IN CONT_CUST.ACCOUNT_STATUS%TYPE Default NULL,
    -- Credit Control
    p_Credit_Category IN CONT_CCTRL_INFO.Credit_Category%TYPE Default NULL,
    p_Credit_Risk IN CONT_CCTRL_INFO.Credit_Risk%TYPE Default NULL,
    p_Credit_Status IN CONT_CCTRL_INFO.Credit_Status%TYPE Default NULL,
    pc_PTP_Date IN Varchar2 Default NULL,
    p_RECEIVE_SMS_FLAG IN CONT_CCTRL_INFO.RECEIVE_SMS_FLAG%TYPE Default NULL,
    p_AUTO_RECONNECT_FLAG IN CONT_CCTRL_INFO.AUTO_RECONNECT_FLAG%TYPE Default NULL,
    p_CCTRL_BYPASS_FLAG IN CONT_CCTRL_INFO.CCTRL_BYPASS_FLAG%TYPE Default NULL,
    p_Excel_LD_Flag IN CUSTOMERS_INFO.other_field5%TYPE Default NULL,
    P_VIP_Type IN CUSTOMERS_INFO.other_field6%TYPE Default NULL,
    P_CPNI_FLAG IN CUSTOMERS_INFO.OTHER_FIELD9%TYPE Default NULL,
    p_Promo_Id IN Varchar2 Default NULL,
    p_Carrier_Id IN CONT_CUST.CARRIER_ID%TYPE Default NULL,
    p_Category_ID IN CONT_CUST.Category_ID%TYPE Default NULL,
    p_MTA_ID IN CONT_CUST.MTA_ID%TYPE Default 1,
    p_REQUIRED_DEPOSIT_AMT IN CUSTOMERS_INFO.OTHER_FIELD11%TYPE Default NULL,
    p_PREPAY_FLAG IN CONT_CUST.PREPAY_FLAG%TYPE Default NULL,
    P_ALT_ACCOUNT_NO2 IN CUSTOMERS_INFO.OTHER_FIELD12%TYPE Default NULL,
    P_EWAVE_CREDIT_SCORE IN CUSTOMERS_INFO.OTHER_FIELD13%TYPE Default NULL,
    P_EWAVE_APPLICATION_NO IN CUSTOMERS_INFO.OTHER_FIELD14%TYPE Default NULL,
    P_ALT_OWNER_NAME IN CUSTOMERS_INFO.ALT_OWNER_NAME%TYPE Default NULL,
    P_ALT_OWNER_PASSWORD IN CUSTOMERS_INFO.ALT_OWNER_PASSWORD%TYPE Default NULL,
    P_SALES_REP_ID IN CUSTOMERS_INFO.SALES_REP_ID%TYPE Default NULL,
    P_SALES_REP_EMAIL IN CUSTOMERS_INFO.SALES_REP_EMAIL%TYPE Default NULL
    IS
    ---------0---------0---------0---------0---------0---------0---------0--------80
    -- PURPOSE : Creates a NEW Account
    -- PARAMETERS : See above.
    -- NOTES :
    -- RETURN : 1) If successfull ................: Contract_Id
    -- 2) If a logical error then .......: ' ' (1 space)
    -- ERROR : If an exception error..........: 'p_error_return = sqlerrm.........'
    -- MODIFICATION HISTORY :
    -- Person Date Comments
    -- Mary Phan Jun 15, 2004 Init version. This procedure will execute procedure D_ACCT_NEW
    -- Mary Phan Jul 07, 2004 Add SALES_REP_ID and SALES_REP_EMAIL
    -- Subas Sep 07, 2005 Modified for ECAM
    -- Subas Sep 19, 2005 Added code to insert a blank record in CONT_MISC_DATA
    cc_PROC_NAME Varchar2(30):='D_ACCT_NEW';
    vc_SECTION Varchar2(10):='000';
    vn_Count Number;
    R_CCTRL_INFO_REC CONT_CCTRL_INFO%ROWTYPE;
    R_CI_REC CUSTOMERS_INFO%ROWTYPE;
    R_CC_REC CONT_CUST%ROWTYPE;
    R_CA_REC CONT_ADDRESS%ROWTYPE;
    R_CPI_REC CONT_PAYMENTS_INFO%ROWTYPE;
    vn_Customer_Id CONT_CUST.CUSTOMER_ID%TYPE;
    vn_Contract_Id CONT_CUST.CONTRACT_ID%TYPE;
    vc_bill_to_name CONT_ADDRESS.NAME%TYPE;
    vd_act_date CONT_CUST.ACT_DATE%TYPE;
    vn_BillCycle CONT_CUST.BILLCYCLE%TYPE;
    vc_Credit_Risk CONT_CCTRL_INFO.CREDIT_RISK%TYPE;
    vn_PARENT_CONTRACT_ID CONT_CUST.PARENT_CONTRACT_ID%TYPE;
    BEGIN
    vc_SECTION:='010';
    -- CHECK FOR CUSTOMER TYPE :
    IF UPPER(p_cust_type) NOT IN ('I','B') THEN
    Raise_Application_Error(-20100,'Customer type may be either "I" or "B"');
    END IF;
    -- CHECK FOR CUSTOMER NAME :
    IF UPPER(p_cust_type)='I' THEN
    IF ltrim(rtrim(p_contact_f_name)) is NULL THEN
    Raise_Application_Error(-20100,'Customer Name can not be a NULL Value');
    END IF;
    ELSIF UPPER(p_cust_type)='B' THEN
    IF ltrim(rtrim(p_company_name)) is NULL THEN
    Raise_Application_Error(-20100,'Company Name can not be a NULL Value');
    END IF;
    END IF;
    -- CHECK FOR BILL BY EMAIL :
    IF UPPER(p_bill_by_email)='Y' THEN
    IF p_EMAIL_ADDRESS is NULL THEN
    Raise_Application_Error(-20100,'Email Address cannot be a NULL Value');
    END IF;
    END IF;
    -- ASSIGN VALUES TO BILL_TO_NAME :
    vc_Bill_To_Name := ltrim(rtrim(p_BILL_TO_NAME));
    IF vc_Bill_To_Name IS NULL THEN
    IF UPPER(p_cust_type)='I' THEN
    vc_bill_to_name:=p_CONTACT_F_NAME||' '||
    p_CONTACT_MIDDLE_INITIAL||' '||
    p_CONTACT_L_NAME;
    ELSIF UPPER(p_cust_type)='B' THEN
    vc_bill_to_name:=p_COMPANY_NAME;
    END IF;
    END IF;
    -- Check for Minimum Address Requirement:
    IF p_BILL_TO_ADDRESS1 is NULL THEN
    Raise_Application_Error(-20100,'BILL TO Address cannot be a NULL Value');
    END IF;
    -- Determine Default values:
    IF pc_ACT_DATE IS NULL THEN
    vd_act_date:=sysdate;
    ELSE
    vd_act_date:=trunc(to_date(pc_ACT_DATE, 'yyyymmddhh24miss'));
    END IF;
    -- Assign BILLCYCLE:
    vn_BillCycle := p_BillCycle;
    IF vn_BillCycle = 0 THEN
    vn_BillCycle := C_UTIL_GET_DEF_BILLCYCLE (p_Carrier_Id);
    END IF;
    IF NVL(vn_Billcycle,0) = 0 then
    Raise_Application_Error(-20100,'Can not find a valid BILLCYCLE ');
    END IF;
    -- Get Customer_Id and Contract_ID from SEQUENCES :
    select contract_id_sequence.nextval into vn_Contract_Id from dual;
    select customer_id_sequence.nextval into vn_Customer_Id from dual;
    --INSERT RECORDS TO CUSTOMERS_INFO :
    vc_SECTION:='020';
    R_CI_REC.CUSTOMER_ID := vn_Customer_Id;
    R_CI_REC.FIRST_NAME := p_CONTACT_F_NAME;
    R_CI_REC.LAST_NAME := p_CONTACT_L_NAME;
    R_CI_REC.MIDDLE_INIT := p_CONTACT_MIDDLE_INITIAL;
    R_CI_REC.ADDRESS1 := p_CRED_SCORE_ADDRESS1;
    R_CI_REC.ADDRESS2 := p_CRED_SCORE_ADDRESS2;
    R_CI_REC.ADDRESS3 := p_CRED_SCORE_CITY;
    R_CI_REC.ADDRESS4 := p_CRED_SCORE_COUNTY;
    R_CI_REC.ADDRESS5 := p_CRED_SCORE_STATE;
    R_CI_REC.ADDRESS6 := p_CRED_SCORE_ZIP;
    --R_CI_REC.ADDRESS6                   := p_CRED_SCORE_Country;
    R_CI_REC.OTHER_FIELD1 := P_Contact_Name1;
    R_CI_REC.OTHER_FIELD2 := P_Contact_Name2;
    R_CI_REC.OTHER_FIELD3 := P_Contact_Name3;
    R_CI_REC.OTHER_FIELD4 := 0;
    R_CI_REC.OTHER_FIELD5 := p_Excel_LD_Flag;
    R_CI_REC.OTHER_FIELD6 := P_VIP_Type;
    R_CI_REC.OTHER_FIELD7 := NULL;
    R_CI_REC.OTHER_FIELD8 := NULL;
    R_CI_REC.OTHER_FIELD9 := P_CPNI_FLAG;
    R_CI_REC.OTHER_FIELD10 := P_PROMO_ID;
    R_CI_REC.OTHER_FIELD11 := P_REQUIRED_DEPOSIT_AMT;
    R_CI_REC.OTHER_FIELD12 := P_ALT_ACCOUNT_NO2;
    R_CI_REC.OTHER_FIELD13 := P_EWAVE_CREDIT_SCORE;
    R_CI_REC.OTHER_FIELD14 := P_EWAVE_APPLICATION_NO;
    R_CI_REC.OTHER_FIELD15 := NULL;
    R_CI_REC.OTHER_FIELD16 := NULL;
    R_CI_REC.OTHER_FIELD17 := NULL;
    R_CI_REC.OTHER_FIELD18 := NULL;
    R_CI_REC.OTHER_FIELD19 := NULL;
    R_CI_REC.OTHER_FIELD20 := NULL;
    R_CI_REC.EMAIL_ADDRESS := p_EMAIL_ADDRESS;
    R_CI_REC.BILL_BY_EMAIL := NVL(p_BILL_BY_EMAIL,B_UTIL_DEFSTRVAL('ACCOUNT','BILL_BY_EMAIL'));
    R_CI_REC.CUST_TYPE := p_CUST_TYPE;
    R_CI_REC.COMPANY_NAME := p_COMPANY_NAME;
    R_CI_REC.IDENTIFICATION_NO := p_TAX_ID;
    R_CI_REC.DRIVER_LICENSE_NO := p_DRIVER_LICENSE_NO;
    R_CI_REC.PHOTO_ID_VALUE := p_PHOTO_ID_VALUE;
    R_CI_REC.PHOTO_ID_STATE := p_PHOTO_ID_STATE;
    R_CI_REC.COUNTRY_ID := p_COUNTRY_ID;
    ---R_CI_REC.SOC_SEC_NUM := p_SOC_SEC_NUM;
    R_CI_REC.ID_METHOD := p_ID_OR_DANDB_TYPE;
    R_CI_REC.ID_VALUE := NULL;
    R_CI_REC.ID_REGION := p_ID_REGION;
    R_CI_REC.BIRTH_DATE := to_date(pc_Birth_Date, 'yyyymmddHH24MISS');
    R_CI_REC.HOME_PHONE_NUM := p_HOME_PHONE_NUM;
    R_CI_REC.BUSINESS_PHONE_NUM := p_BUSINESS_PHONE_NUM;
    R_CI_REC.CURR_ADDRESS_DATE := to_date(pc_Curr_Address_Date,'yyyymmddHH24MISS');
    R_CI_REC.PREV_ADDRESS1 := p_PREV_ADDRESS1;
    R_CI_REC.PREV_ADDRESS2 := p_PREV_ADDRESS2;
    R_CI_REC.PREV_CITY := p_PREV_CITY;
    R_CI_REC.PREV_COUNTY := p_PREV_COUNTY;
    R_CI_REC.PREV_STATE := p_PREV_STATE;
    R_CI_REC.PREV_POSTAL_CODE := p_PREV_ZIP;
    R_CI_REC.PREV_COUNTRY := p_PREV_COUNTRY;
    R_CI_REC.CREDIT_SCORE := p_ORIG_INTERNAL_SCORE;
    R_CI_REC.INTERNAL_CREDIT_SCORE := UPPER(p_INTERNAL_SCORE);
    R_CI_REC.INTERNAL_CREDIT_SCORE_DATE := SYSDATE;
    R_CI_REC.SALES_REP_FLAG := p_SALES_REP_FLAG;
    R_CI_REC.NAME_TITLE := p_CONTACT_TITLE;
    R_CI_REC.NAME_SUFFIX := P_CONTACT_SUFFIX;
    R_CI_REC.CREATION_DATE := SYSDATE;
    R_CI_REC.ALT_OWNER_NAME := P_ALT_OWNER_NAME;
    R_CI_REC.ALT_OWNER_PASSWORD := P_ALT_OWNER_PASSWORD;
    R_CI_REC.SALES_REP_ID := P_SALES_REP_ID;
    R_CI_REC.SALES_REP_EMAIL := P_SALES_REP_EMAIL;
    R_CI_REC.LAST_MODIFIED_DATE := SYSDATE;
    R_CI_REC.LAST_MODIFIED_BY := P_USERNAME;
    D_INS_UPD_CUSTINFO(p_Return,p_Error_Return,p_UserName,'INS',R_CI_REC);
    --INSERT RECORDS INTO CONT_CUST :
    vc_SECTION:='030';
    SELECT DECODE(P_PARENT_CONTRACT_ID,NULL,VN_CONTRACT_ID,P_PARENT_CONTRACT_ID)
    INTO VN_PARENT_CONTRACT_ID
    FROM DUAL;
    R_CC_REC.CONTRACT_ID := vn_Contract_Id;
    R_CC_REC.ACCOUNT_NO := vn_Contract_Id;
    R_CC_REC.CUSTOMER_ID := vn_customer_id;
    R_CC_REC.RP_ID := 0;
    R_CC_REC.MTA_ID := p_MTA_ID;
    R_CC_REC.TAX_REGION_ID := p_TAX_REGION_ID;
    R_CC_REC.ACT_DATE := trunc(vd_act_date);
    R_CC_REC.BILLCYCLE := vn_Billcycle;
    R_CC_REC.LAST_BILL_DATE := trunc(vd_act_date-1);
    R_CC_REC.DEACT_DATE := NULL;
    R_CC_REC.ENTRY_DATE := NVL(to_date(pc_ENTRY_DATE,'yyyymmddhh24miss'),SYSDATE);
    R_CC_REC.ENTRY_BY := p_UserName;
    R_CC_REC.OPEN_BALANCE := 0;
    R_CC_REC.PREPAY_FLAG := P_PREPAY_FLAG;
    R_CC_REC.USAGE_THRESHOLD := NVL(p_USAGE_THRESHOLD,
    B_UTIL_GET_CREDIT_LIMIT(P_Internal_Credit_Score=>UPPER(p_INTERNAL_SCORE),
    p_Contract_Type=>'ACCOUNT'));
    R_CC_REC.PMM_CUR_BALANCE := NULL;
    R_CC_REC.SUB_ACCOUNT_ID := 0;
    R_CC_REC.CATEGORY_ID := p_Category_ID;
    R_CC_REC.DEACT_REASON_ID := NULL;
    R_CC_REC.DETAIL_BILLING := NVL(P_DETAIL_BILLING,B_UTIL_DEFSTRVAL('ACCOUNT','DETAIL_BILLING'));
    R_CC_REC.CARRIER_ID := NVL(p_carrier_id,1);
    R_CC_REC.BILL_LANGUAGE_ID := NVL(p_BILL_LANGUAGE_ID,B_UTIL_DEFSTRVAL('ACCOUNT','BILL_LANGUAGE_ID'));
    R_CC_REC.BILL_LAYOUT_ID := NVL(p_BILL_LAYOUT_ID,B_UTIL_DEFSTRVAL('ACCOUNT','BILL_LAYOUT_ID'));
    R_CC_REC.BILL_CURRENCY_ID := NVL(p_BILL_CURRENCY_ID,B_UTIL_DEFSTRVAL('ACCOUNT','BILL_CURRENCY_ID'));
    R_CC_REC.FIXED_CURRENCY := NVL(p_FIXED_CURRENCY,B_UTIL_DEFSTRVAL('ACCOUNT','FIXED_CURRENCY'));
    R_CC_REC.APPLY_LATE_FEES := NVL(p_APPLY_LATE_FEES,B_UTIL_DEFSTRVAL('ACCOUNT','APPLY_LATE_FEES'));
    R_CC_REC.PARENT_CONTRACT_ID := VN_PARENT_CONTRACT_ID;
    R_CC_REC.LEVEL_NO := 0;
    R_CC_REC.AP_FLAG := 'Y';
    R_CC_REC.RESTRICTION_CLASS_ID := NULL;
    R_CC_REC.OMM_UPDATE_FLAG := 'N';
    R_CC_REC.INACTIVE_FLAG := 'N';
    R_CC_REC.SWITCH_PROFILE := NULL;
    R_CC_REC.ALT_ACCOUNT_NO := p_ALT_ACCOUNT_NO;
    R_CC_REC.ALT_SUB_ACCOUNT_ID := p_ALT_SUB_ACCOUNT_ID;
    R_CC_REC.DEPOSITED_AMT := NULL;
    R_CC_REC.READY_TO_ACT := NULL;
    R_CC_REC.ACCOUNT_STATUS := NVL(p_STATUS,'SHELL');
    R_CC_REC.EARLY_TERMINATION_FEE := NULL;
    R_CC_REC.EARLY_TERMINATION_DATE := NULL;
    R_CC_REC.SALES_REP_ID := NULL;
    R_CC_REC.MANUAL_OMM_ACTIVATE := NULL;
    R_CC_REC.PERMANENT_USAGE_THRESHOLD := R_CC_REC.USAGE_THRESHOLD;
    D_INS_UPD_CONTCUST(p_Return,p_Error_Return,p_UserName,'INS',R_CC_REC);
    --INSERT RECORDS INTO CONT_PAYMENT_INFO :
    vc_SECTION:='040';
    R_CPI_REC.CONTRACT_ID := vn_Contract_Id;
    R_CPI_REC.AUTO_PAYMENT_FLAG := NVL(p_AUTO_PAYMENT_FLAG,B_UTIL_DEFSTRVAL('ACCOUNT','AUTO_PAYMENT_FLAG'));
    R_CPI_REC.PAYMENT_METHOD := NVL(p_PAYMENT_METHOD,'CASH');
    R_CPI_REC.BANK_NAME := p_DEF_PAY_BANK_NAME;
    R_CPI_REC.OWNER_NAME := p_DEF_PAY_OWNER_NAME;
    R_CPI_REC.OWNER_ADDRESS := p_DEF_PAY_CARD_ADDRESS;
    R_CPI_REC.OWNER_ADDRESS2 := p_DEF_PAY_ADDRESS2;
    R_CPI_REC.OWNER_CITY := p_DEF_PAY_CITY;
    R_CPI_REC.OWNER_COUNTY := p_DEF_PAY_COUNTY;
    R_CPI_REC.OWNER_STATE := p_DEF_PAY_STATE;
    R_CPI_REC.BANK_CC_NUMBER := p_DEF_PAY_CARD_NUMBER;
    R_CPI_REC.CC_CARD_TYPE_ID := p_DEF_PAY_CARD_TYPE;
    R_CPI_REC.CC_EXPIRATION_DATE := to_date(pc_DEF_PAY_CARD_EXPIRES,'YYYYMMDDHH24MISS');
    R_CPI_REC.CC_AMEX_CID := p_DEF_PAY_AMEX_CID;
    R_CPI_REC.CC_AUTH_NUMBER := NULL;
    R_CPI_REC.CC_AUTH_REQUEST_AMOUNT := NULL;
    R_CPI_REC.CC_AUTH_AMOUNT := NULL;
    R_CPI_REC.CC_AUTH_DATE := NULL;
    R_CPI_REC.CARDHOLDER_POSTAL_CODE := p_DEF_PAY_ZIP;
    R_CPI_REC.ABA := P_DEF_PAY_ROUTING_NO;
    R_CPI_REC.ACCOUNT_TYPE := P_DEF_CHK_ACCOUNT_TYPE;
    R_CPI_REC.CC_CCV2_NUMBER := p_DEF_PAY_CARD_CCV2;
    R_CPI_REC.LAST_MODIFIED_DATE := SYSDATE;
    R_CPI_REC.LAST_MODIFIED_BY := P_USERNAME;
    D_INS_UPD_CONTPAYMENTSINFO(p_Return,p_Error_Return,p_UserName,'INS',R_CPI_REC);
    --INSERT RECORDS INTO CONT_ADDRESS
    vc_SECTION:='050';
    R_CA_REC.CONTRACT_ID := vn_Contract_id;
    R_CA_REC.ADDRESS_TYPE := 'B';
    R_CA_REC.NAME := vc_bill_to_name;
    R_CA_REC.ADDRESS1 := p_BILL_TO_ADDRESS1;
    R_CA_REC.ADDRESS2 := p_BILL_TO_ADDRESS2;
    R_CA_REC.CITY := p_BILL_TO_CITY;
    R_CA_REC.COUNTY := P_BILL_TO_COUNTY;
    R_CA_REC.STATE := p_BILL_TO_STATE;
    R_CA_REC.POSTAL_CODE := p_BILL_TO_ZIP;
    R_CA_REC.COUNTRY := P_BILL_TO_COUNTRY;
    R_CA_REC.GEOCODE := p_BILL_TO_GEOCODE;
    R_CA_REC.BUS_OR_RES_FLAG := p_BILL_TO_BUS_OR_RES_FLAG;
    R_CA_REC.INSIDE_CORP_FLAG := p_BILL_TO_INSIDE_CORP_FLAG;
    D_INS_UPD_CONTADDRESS(p_Return,p_Error_Return,p_UserName,'INS',R_CA_REC);
    -- INSERT RECORD INTO CONT_CCTRL_INFO :
    vc_SECTION:='060';
    IF p_Credit_Risk is not NULL then
    vc_Credit_Risk := p_Credit_Risk ;
    ELSE
    IF R_CI_REC.INTERNAL_CREDIT_SCORE IS NULL THEN
    vc_Credit_Risk := 'High';
    ELSIF R_CI_REC.INTERNAL_CREDIT_SCORE IN ('A','B') THEN
    vc_Credit_Risk := 'Low';
    ELSIF R_CI_REC.INTERNAL_CREDIT_SCORE = 'C' THEN
    vc_Credit_Risk := 'Medium';
    ELSE
    vc_Credit_Risk := 'High';
    END IF;
    END IF;
    R_CCTRL_INFO_REC.CONTRACT_ID := vn_CONTRACT_ID;
    R_CCTRL_INFO_REC.ENTRY_BY := p_UserName;
    R_CCTRL_INFO_REC.CREDIT_RISK := vc_Credit_Risk;
    R_CCTRL_INFO_REC.CREDIT_CATEGORY := NVL(p_Credit_CATEGORY,B_UTIL_DEFSTRVAL('ACCOUNT','CREDIT_CATEGORY'));
    R_CCTRL_INFO_REC.CREDIT_STATUS := NVL(p_Credit_STATUS,B_UTIL_DEFSTRVAL('ACCOUNT','CREDIT_STATUS'));
    R_CCTRL_INFO_REC.PTP_DATE := to_date(pc_PTP_Date,'yyyymmddhh24miss');
    R_CCTRL_INFO_REC.RECEIVE_SMS_FLAG := 'N';
    R_CCTRL_INFO_REC.AUTO_RECONNECT_FLAG := NVL(p_AUTO_RECONNECT_FLAG,'Y');
    R_CCTRL_INFO_REC.CCTRL_BYPASS_FLAG := NVL(p_CCTRL_BYPASS_FLAG,'N');
    R_CCTRL_INFO_REC.LAST_MODIFIED_BY := p_UserName;
    R_CCTRL_INFO_REC.LAST_MODIFIED_DATE := SYSDATE;
    D_INS_UPD_CONTCCTRLINFO(P_Return,P_Error_Return,p_UserName,'INS',R_CCTRL_INFO_REC);
    -- INSERT RECORD INTO CONT_MISC_DATA :
    vc_SECTION:='070';
    INSERT INTO CONT_MISC_DATA
    (CONTRACT_ID)
    VALUES
    (vn_Contract_Id);
    p_Return := vn_Contract_Id;
    EXCEPTION
    WHEN others THEN
    p_Return:='';
    p_Error_Return :=cc_PROC_NAME||' '|| vc_SECTION||':'|| SUBSTR(sqlerrm,1,300);
    END; -- D_ACCT_NEW

  • Error while executing procedure

    Hi,
    I am executing a procedure, which will write a query result into a spreadsheet and it will store it into the local PC. i am trying to run this procedure using TEST username.
    Now i created a utl_file directory like below:
    create directory MYDIR5 AS 'c:\raj';
    and i tried to assign permission like below :
    grant read,write on directory MYDIR5 to TEST
    i got the below error, while i am executing the GRANT stmt:
    ORA-01749: you may not GRANT/REVOKE privileges to/from yourself
    So who has to grant privileges for this. I tried to execute the procedure without granting privileges but it end up with ORA-29283: error.
    So pls help me on this issue.
    Thanks in advance!!!

    You looked up the CREATE DIRECTORY statement right? What does it say under "Prerequisites"?
    > I am executing a procedure, which will write a query result into a spreadsheet and it will store it into the local PC
    Is the database also on your local PC? UTL_FILE runs on the database server.

  • When I attempt to open a PDF file I saved from a website, I get the message "There was an error opening this document. The file is damaged and could not be repaired." Is there any way to correct this problem?

    When I attempt to open a PDF file I saved from a website using Safari, I get the message "There was an error opening this document. The file is damaged and could not be repaired." When I save the same PDF file using FireFox it opens up immediately. Is there any way to correct this problem with Safari?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Logical error in the query

    create table my_employee
    (id number(4)primary key,
    last_name varchar2(25),
    first_name varchar2(25),
    userid varchar2(8),
    salary number(9,2)
    I want to write an INSERT statement to MY_EMPLOYEE table . Concatenate the first letter of the first name and first seven characters of the last name to produce user ID using a single sql statement
    I wrote the query like this and i am getting logical error
    insert into my_employee
    values(&id,'&last_name','&first_name',substr('&&first_name',1,1)||substr('&last_name',1,7),&salary);
    SQL> insert into my_employee
    2 values(&id,'&last_name','&first_name',substr('&&first_name',1,1)||substr('&last_name',1,7),&sal
    ary);
    Enter value for id: 20
    Enter value for last_name: popopopp
    Enter value for last_name: qwertyyuu
    Enter value for salary: 300000
    old 2: values(&id,'&last_name','&first_name',substr('&&first_name',1,1)||substr('&last_name',1,7),
    new 2: values(20,'popopopp','o',substr('o',1,1)||substr('qwertyyuu',1,7),300000)
    1 row created.
    it is asking the last_name two times

    you can do it with a .sql script
    c:\my_emp.sql
    PROMPT
    PROMPT instering my_employees
    PROMPT
    ACCEPT ID NUMBER PROMPT 'ID ? : '
    ACCEPT FIRST_NAME CHAR PROMPT 'FIRST_NAME ?: '
    ACCEPT LAST_NAME CHAR PROMPT 'LAST_NAME ?: '
    ACCEPT SALARY NUMBER PROMPT 'SALARY ? : '
    insert into my_employee values(&id,'&last_name','&first_name',substr('&&first_name',1,1)||substr('&last_name',1,7),&salary);
    SELECT * FROM my_employee where id=&&id;
    and then from sqlplus @c:\my_emp.sql
    scott@ORCL> @C:\MY_EMP
    instering my_employees
    ID ? : 20
    FIRST_NAME ?: john
    LAST_NAME ?: papas
    SALARY ? : 1000
    old 1: insert into my_employee values(&id,'&last_name','&first_name',substr('&&first_name',1,1)||substr('&last_name',1,7),&salary)
    new 1: insert into my_employee values( 20,'papas','john',substr('john',1,1)||substr('papas',1,7), 1000)
    1 row created.
    old 1: SELECT * FROM my_employee where id=&&id
    new 1: SELECT * FROM my_employee where id= 20
    ID LAST_NAME FIRST_NAME USERID SALARY
    20 papas john jpapas 1000
    scott@ORCL>

  • How to get line error from a procedure?

    Hello,
    I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
    How to do it?
    Thanks in advance.
    EXCEPTION WHEN OTHERS THEN
    HTP.P('Sorry');
    emailme(SQLERRM);
    emailme(line where erro occurs);???????
    END;
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Paula Bronfman ([email protected]):
    Hello,
    I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
    How to do it?
    Thanks in advance.
    EXCEPTION WHEN OTHERS THEN
    HTP.P('Sorry');
    emailme(SQLERRM);
    emailme(line where erro occurs);???????
    END;
    <HR></BLOCKQUOTE>
    Hi;
    your best bet would be to set a variable in the procedure every 10 lines or so, and email the contents of that var.
    begin
    mydebug:=0;
    mydebug:=10;
    when others then
    emailme(SQLERRM&#0124; &#0124;' '&#0124; &#0124;mydebug);
    end;
    Cheers
    Paulo

  • With OSX10.7.5 and Adobe Reader 11.0.02 when I try to open a PDF downloaded from the web I get 'There was an error opening this document. This file is damaged and could not be repaired. Preview will not open either. Older PDFs OK.

    I am running OS X 10.7.5 and Adobe Reader 11.0.02. In the last few days I have been unable to open PDF's downloaded from the web. Reader gives the error message 'There was an error opening this document. The file is damaged and could not be repaired'. Removing Reader and trying to use Preview to open these files give the error 'Preview cannot open this file. It may be damaged or use a file format that Preview doesn't recognise' (or something like that). Downloading the same files with Reader removed from my Mac Preview opens the files OK.
    I was recently prompted to update Adobe software but did not note exactly what the update was nor when it was done.
    Reader and Preview will both open PDFs I downloaded a week ago. Reader will also open files downloaded on another Mac running OS X 10.0.0 and copied to my Mac. Any ideas?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Help me in debugging this procedure

    PROCEDURE p_main_dpn (
    m_post IN OUT VARCHAR2,
    m_company VARCHAR2,
    m_user_group VARCHAR2,
    m_user_id VARCHAR2,
    m_choice VARCHAR2,
    m_year VARCHAR2,
    m_period VARCHAR2,
    m_tot_count NUMBER,
    g_asset_code VARCHAR2
    IS
    CURSOR c1 (m_last_day_of_period DATE)
    IS
    SELECT company, asset_code, asset_dept, capital_cost, current_wdv,
    dpn_type, status, residual_val, dpn_prd, dpn_year, nl_intf,
    asset_life, updated_wdv, dpn_date, comm_date
    FROM fa_asset_reg
    WHERE status = 'C'
    AND company = m_company
    AND asset_code =
    NVL (g_asset_code, asset_code)
    -- dpn before sale
    AND updated_wdv > residual_val
    AND TO_NUMBER (TO_CHAR (NVL (dpn_date, comm_date), 'yyyymmdd')) <
    TO_NUMBER (TO_CHAR (m_last_day_of_period, 'yyyymmdd'))
    ORDER BY asset_dept;
    rc1 c1%ROWTYPE;
    sl_value NUMBER (15, 2);
    -- Used in Sraight Line Method Calculation
    sl_dpn NUMBER (15, 2); -- Straight Line depreciation amount
    rb_value NUMBER (15, 2);
    -- Used in Reducing Balance Method Calculation
    rb_dpn NUMBER (15, 2);
    -- Reducing Balance depreciation amount
    m_doc_ref VARCHAR2 (16); -- For generating new Doc-Ref
    m_updated_wdv NUMBER (15, 2); -- Latest book value of the Asset
    m_tot_dpn NUMBER (15, 2); -- Department-wise total depreciation
    m_loop_count NUMBER; -- To check for First Loop
    m_prev_dept VARCHAR2 (12);
    m_next_dept VARCHAR2 (12);
    period_last_day DATE; --*
    m_period_days NUMBER; --*
    m_dpn_days NUMBER; --* used for datewise DPN calculation
    dpn_for_a_day NUMBER; --*
    m_last_day DATE; --*
    m_start_day DATE; --*
    m_from_day DATE; --*
         Chk Number;
    BEGIN
    /* First Delete any Trial Depreciations Calculated */
    DELETE FROM fa_temp_dpn
    WHERE company = m_company;
    Chk :=1;
    BEGIN
    /* This check is done to calculate dpn before sale for a particular asset*/
    IF g_asset_code IS NULL
    THEN
    SELECT LAST_DAY (fdp), LAST_DAY (fdp) - fdp + 1, fdp
    INTO m_last_day, m_period_days, m_start_day
    FROM sm_calendar
    WHERE company = m_company AND YEAR = m_year AND prd = m_period;
                   DBMS_OUTPUT.PUT_LINE('m_last_day, m_period_days, m_start_day'||m_last_day||','|| m_period_days||','|| m_start_day);
    ELSE
    SELECT SYSDATE, LAST_DAY (fdp) - fdp + 1,
    TRUNC (SYSDATE - fdp) + 1, fdp
    INTO m_last_day, m_period_days,
    m_dpn_days, m_start_day
    FROM sm_calendar
    WHERE company = m_company AND YEAR = m_year AND prd = m_period;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    m_post := 'System calendar not defined properly';
    END;
    --OPEN c1 (m_last_day);
    FOR RC1 IN C1(m_last_day)
    LOOP
         cHK := 0;
    /*FETCH c1
    INTO rc1;*/
              cHK := 0.1;
    dbms_OUTPUT.PUT_LINE('ENtered the loop'||c1%rowcount||m_last_day);
    EXIT WHEN c1%NOTFOUND or c1%rOWCOUNT = 0;ADDED BY ALOK
              cHK := 0.2;
    m_loop_count := NVL (m_loop_count, 0) + 1;
              cHK := 0.3;
              DBMS_OUTPUT.PUT_LINE('m_loop_count '||m_loop_count );
    -- No more depreciation for the Asset which has depreciated
    -- upto the Residual Value!!
    rb_dpn := NULL;
    sl_dpn := NULL;
    -- SLL or SL% METHOD
    IF rc1.dpn_type = 'S' OR rc1.dpn_type = 'P'
    THEN
    -- Provision is given for adding already depreciated assets into the register.****
    sl_value := NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0));
    DBMS_OUTPUT.put_line ('SL Value ' || sl_value);
    IF rc1.dpn_type = 'S'
    THEN -- SLL METHOD
    sl_dpn := (sl_value - rc1.residual_val) / rc1.asset_life;
    DBMS_OUTPUT.put_line
    ( 'sl_dpn := (SL_VALUE - rc1.residual_val)/rc1.asset_life'
    || sl_dpn
    ELSIF rc1.dpn_type = 'P'
    THEN -- SL% METHOD
    sl_dpn :=
    ((sl_value - rc1.residual_val) * rc1.asset_life) / 100;
    DBMS_OUTPUT.put_line
    ( 'sl_dpn := ((SL_VALUE - rc1.residual_val)*rc1.asset_life)/100'
    || sl_dpn
    END IF;
    -- Dpn Calculation for no. of days in the period.
    dpn_for_a_day := sl_dpn / m_period_days;
                   DBMS_OUTPUT.put_line('dpn_for_a_day '||dpn_for_a_day );
    IF g_asset_code IS NULL
    THEN
    -- Get the no. of days from rc1.dpn_date to last_day of current period.
    IF rc1.dpn_date = rc1.comm_date
    THEN
    -- Dpn calculation for the first time.
    m_start_day := rc1.dpn_date;
                        DBMS_OUTPUT.put_line('m_start_day '||m_start_day);
    END IF;
    ELSE
    IF TO_CHAR (m_start_day, 'MMYYYY') =
    TO_CHAR (rc1.comm_date, 'MMYYYY')
                   THEN
    m_start_day := rc1.comm_date;
                        DBMS_OUTPUT.put_line('TO_CHAR (m_start_day, ''MMYYYY'')'||TO_CHAR (m_start_day, 'MMYYYY'));
    ELSE
    m_start_day := rc1.dpn_date + 1;
    END IF;
    END IF;
    m_dpn_days := TRUNC (m_last_day - m_start_day) + 1;
    DBMS_OUTPUT.put_line('m_dpn_days '||m_dpn_days);
    -- Compare the days for which depreciation has to be calculated with the
    -- no. of days in the period.
    IF m_dpn_days > m_period_days
    THEN
    m_post :=
    'Depreciation has not been done for a previous period.';
    EXIT;
    ELSE
    -- Restore the DPN into same variable
    sl_dpn := dpn_for_a_day * m_dpn_days;
                   DBMS_OUTPUT.put_line('sl_dpn '||sl_dpn);
    END IF;
    Chk := 2;
    -- Update the Current Value of this Asset(SL)
    m_updated_wdv := rc1.updated_wdv - sl_dpn;
    -- RBL OR RB% METHOD
    ELSIF rc1.dpn_type = 'R' OR rc1.dpn_type = 'Q'
    THEN
    rb_value :=
    NVL (rc1.updated_wdv,
    NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0))
    Chk :=3;
    IF rc1.dpn_type = 'R'
    THEN
    rb_dpn := (rb_value - rc1.residual_val) / rc1.asset_life;
    ELSIF rc1.dpn_type = 'Q'
    THEN
    rb_dpn :=
    ((rb_value - rc1.residual_val) * rc1.asset_life) / 100;
    END IF;
    -- Dpn Calculation for no. of days in the period.
    dpn_for_a_day := rb_dpn / m_period_days;
    IF g_asset_code IS NULL
    THEN
    -- Get the no. of days from rc1.dpn_date to last_day of current period.
    IF rc1.dpn_date = rc1.comm_date
    THEN
    -- Dpn calculation for the first time.
    m_start_day := rc1.dpn_date;
    END IF;
    ELSE
    IF TO_CHAR (m_start_day, 'MMYYYY') =
    TO_CHAR (rc1.comm_date, 'MMYYYY')
    THEN
    m_start_day := rc1.comm_date;
    ELSE
    m_start_day := rc1.dpn_date + 1;
    END IF;
    END IF;
    m_dpn_days := TRUNC (m_last_day - m_start_day) + 1;
    -- Compare the days for which depreciation has to be calculated with the
    -- no. of days in the period.
    IF m_dpn_days > m_period_days
    THEN
    m_post :=
    'Depreciation has not been done for previous a period.';
    EXIT;
    ELSE
    -- Restore the DPN into same variable
    rb_dpn := dpn_for_a_day * m_dpn_days;
    END IF;
    Chk := 4;
    -- Update the Current Value of this Asset(RB)
    m_updated_wdv :=
    NVL (rc1.updated_wdv,
    NVL (rc1.current_wdv, NVL (rc1.capital_cost, 0))
    - rb_dpn;
    END IF;
    -- Check if the depreciation reduces the current book value
    -- to make it lesser than Residual Value
    IF m_updated_wdv < rc1.residual_val
    THEN
    IF rc1.dpn_type = 'S' OR rc1.dpn_type = 'P'
    THEN
    sl_dpn := sl_dpn - (rc1.residual_val - m_updated_wdv);
    ELSIF rc1.dpn_type = 'R' OR rc1.dpn_type = 'Q'
    THEN
    rb_dpn := rb_dpn - (rc1.residual_val - m_updated_wdv);
    END IF;
    m_updated_wdv := rc1.residual_val;
    END IF;
    m_from_day := m_start_day;
    Chk := 5;
    -- Check whether Department-wise AJ consolidation required.
    IF m_choice = 'Y'
    THEN /* Department-wise AJ required */
    INSERT INTO fa_stats
    (company, asset_code, closing_wdv, YEAR,
    prd, dpn_per_day, no_of_days, from_date,
    TO_DATE, asset_dpn, usr_id, TIMESTAMP
    VALUES (rc1.company, rc1.asset_code, m_updated_wdv, m_year,
    m_period, dpn_for_a_day, m_dpn_days, m_from_day,
    m_last_day, NVL (rb_dpn, sl_dpn), m_user_id, SYSDATE
                   DBMS_OUTPUT.PUT_LINE('Inserted the value into Fa_Stats');
    UPDATE fa_asset_reg
    SET dpn_year = m_year,
    dpn_prd = m_period,
    dpn_date = m_last_day,
    updated_wdv = m_updated_wdv
    WHERE company = m_company AND asset_code = rc1.asset_code;
                             DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||'Rows Updated the value into Fa_Asset_Reg');
    m_next_dept := rc1.asset_dept;
    IF m_next_dept = NVL (m_prev_dept, m_next_dept)
    THEN /* same department */
    m_tot_dpn := NVL (m_tot_dpn, 0)
    + NVL (NVL (sl_dpn, rb_dpn), 0);
    m_prev_dept := m_next_dept;
    IF m_loop_count = m_tot_count
    THEN /* last record */
    p_create_dpn_jv (m_company,
    m_user_group,
    m_user_id,
    m_post,
    m_period,
    m_year,
    m_last_day,
    'XXXXXX',
    m_next_dept,
    m_choice,
    m_tot_dpn,
    m_updated_wdv,
    rc1.nl_intf,
    NULL,
    NULL,
    NULL,
    NULL
    --m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
    EXIT;
    END IF;
    END IF;
    IF m_next_dept <> m_prev_dept
    THEN
    p_create_dpn_jv (m_company,
    m_user_group,
    m_user_id,
    m_post,
    m_period,
    m_year,
    m_last_day,
    'XXXXXX',
    m_prev_dept,
    m_choice,
    m_tot_dpn,
    m_updated_wdv,
    rc1.nl_intf,
    NULL,
    NULL,
    NULL,
    NULL
    --m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
    m_tot_dpn := NVL (NVL (sl_dpn, rb_dpn), 0);
    m_prev_dept := m_next_dept;
    IF m_loop_count = m_tot_count
    THEN /* last record */
    p_create_dpn_jv (m_company,
    m_user_group,
    m_user_id,
    m_post,
    m_period,
    m_year,
    m_last_day,
    'XXXXXX',
    m_next_dept,
    m_choice,
    m_tot_dpn,
    m_updated_wdv,
    rc1.nl_intf,
    NULL,
    NULL,
    NULL,
    NULL
    --m_updated_wdv & m_last_day not applicable if CHOICE = 'Y'
    EXIT;
    END IF;
    END IF;
    ELSE
              Chk := 5.1; /* choice is N */
    p_create_dpn_jv (rc1.company,
    m_user_group,
    m_user_id,
    m_post,
    m_period,
    m_year,
    m_last_day,
    rc1.asset_code,
    rc1.asset_dept,
    m_choice,
    NVL (sl_dpn, rb_dpn),
    m_updated_wdv,
    rc1.nl_intf,
    dpn_for_a_day,
    m_dpn_days,
    m_from_day,
    m_last_day
                                       Chk := 5.2;
    END IF;
    END LOOP;
    -- CLOSE c1;
         cHK := 7;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    m_post := 'Processing failed !! No data found ';
    WHEN DUP_VAL_ON_INDEX
    THEN
    m_post :=
    'Posting failed . Duplicate value exists for ' || rc1.asset_code;
    ROLLBACK;
              wHEN otHERS THEN
              m_post := 'ERROR oCCURED'||SQLERRM||chk||' '||m_loop_count;
              rOLLBACK;
    END;
    Here when i'm executing this procedure, I'm getting a error ORA-01002- Fetch Out of Sequence.
    Plz help me.
    Thanks in advance.
    Regards,ALok

    Earlier it was having the simple loop.But i changed
    it to the FOr loop cursor,
    Cos, For loop is more efficient in fetching the
    data.Only from 10g on and when you don't use BULK fetch
    in your cursor loop.
    As for your other question: I meant of course the ROLLBACK
    in the procedure p_create_dpn_jv.
    Again, if you can't remove that ROLLBACK there, you could
    bulk fetch all the records of your main cursor and process them
    afterwards in a FOR/FORALL loop, if the result fits into the available
    memory of course.
    C.

Maybe you are looking for