mgrex's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Active Members
Active Posts:
205 (0.11 per day)
Joined:
25-March 10
Profile Views:
1,924
Last Active:
User is online 7 minutes ago
Currently:
Viewing Topic: Pass 2 arrays to a method,Cannot...

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   mgrex has not set their status

Posts I've Made

  1. In Topic: Pass 2 arrays to a method,Cannot make a static reference to ..

    Posted 2 Jul 2015

    View PostChrisNt, on 02 July 2015 - 11:00 AM, said:

    You are trying to call a non static method from your main method ,to do so you have to make your method static or create an object of that class and call the method.



    This is why I created the following in line 12:
    Ch_05_01_ControlStructures Pass1 = new Ch_05_01_ControlStructures();

    Awesome, that seemed to do the trick.

    The following worked:
    Pass1.avgSalesStaff(sales2014, staff2014);

    The following did not:
    Pass1.avgSalesStaff(sales2014[], staff2014[]);

    I'd like to know the static method way, but the book I'm reading hasn't gotten that far (I hope so).

    Thank your for the assistance.
  2. In Topic: Java.lang.Math functions displays nothing during execution.

    Posted 28 Jun 2015

    I restarted eclipse. And now, it's displaying the program in the Console. I had to shut it down task manager. Thank you macosx, for the response.
  3. In Topic: Error Code: 1215. Cannot add foreign key constraint

    Posted 3 Jan 2015

    View Postandrewsw, on 01 January 2015 - 05:38 PM, said:

    Do you have a vendor_id of 12 in the vendors table?

    If this isn't the issue then you need to determine which line is causing the error.


    Thanks.

    I executed the following query.
    INSERT INTO `ap`.`vendors` (`vendor_id`) VALUES ('12');
    


    I still got the following message:

    Quote

    12:22:43 INSERT INTO invoices (vendor_id, invoice_number, invoice_date, invoice_total, terms_id, invoice_due_date) VALUES (12, '3289175', '2011-07-18', 165, 3, '2011-08-17') Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`ap`.`invoices`, CONSTRAINT `invoices_fk_terms` FOREIGN KEY (`terms_id`) REFERENCES `terms` (`terms_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) 0.000 sec


    Posted Image

    Edit: Since Terms_ID also has a foreign key, I added the value 3 to it:
    INSERT INTO `ap`.`terms` (`terms_id`) VALUES ('3');
    
    


    I now get the error:

    Quote

    12:38:32 UPDATE invoices SET credit_total = 35.89 WHERE invoice_number = '367447' Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect. 0.000 sec


    I go to Edit → Preferences, I can't find "SQL Queries and reconnect"... smh
    Posted Image

    This is what the ap, invoice table looks like now:
    Posted Image

    I'll also add I don't have any corresponding values, '367447', and '4-342-8069', so I guess the update and delete statements are irrelevant/should be ignored for now.
  4. In Topic: Error Code: 1215. Cannot add foreign key constraint

    Posted 1 Jan 2015

    I now get error 1452:
    Cannot add or update a child row: a foreign key constraint fails (`ap`.`invoices`, CONSTRAINT `invoices_fk_vendors` FOREIGN KEY (`vendor_id`) REFERENCES `vendors` (`vendor_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)	0.000 sec
    


    Query I tried to execute:
    Spoiler


    Tables and columns I have created so far for 'ap' schema.
    Posted Image
  5. In Topic: Error Code: 1215. Cannot add foreign key constraint

    Posted 31 Dec 2014

    Thank you for the valuable responses. It helped.

    I removed the following segment, including the comma after date, and was able to create the table.

    ,
      CONSTRAINT invoices_fk_vendors
        FOREIGN KEY (vendor_id)
        REFERENCES vendors (vendor_id),
      CONSTRAINT invoices_fk_terms
        FOREIGN KEY (terms_id)
        REFERENCES terms (terms_id)
    
    


    Spoiler


    I tried creating the foreign key constraints, invoices_fk_vendors + invoices_fk_terms, separately. Do I need to make two new tables, vendors and terms, in order to make the foreign keys?

    Syntax doesn't match, as indicated with the bolded text:

    Quote

    ALTER TABLE `ap`.`invoices`
    ADD CONSTRAINT `invoices_fk_vendors`
    FOREIGN KEY (`vendor_id`)
    REFERENCES `ap`.`invoices` (`vendor_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION;

    ERROR 1025: Error on rename of '.\ap\#sql-13fc_20' to '.\ap\invoices' (errno: 150 - Foreign key constraint is incorrectly formed)

    Should I make new schema/database named vendors?

    Posted Image

    Edit: I created a table in ap database named vendors, with just 1 column, vendors_id, as the primary key NOT NULL, and WorkBench was able to implement the following syntax successfully.

    ALTER TABLE `ap`.`invoices` 
    ADD CONSTRAINT `invoices_fk_vendors`
      FOREIGN KEY (`vendor_id`)
      REFERENCES `ap`.`vendors` (`vendor_id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION;
    

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

mgrex hasn't added any friends yet.

Comments

mgrex has no profile comments yet. Why not say hello?