Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:22:13+00:00 2026-06-17T12:22:13+00:00

I’m currently working on my little databases project, but I have already encountered problems.

  • 0

I’m currently working on my little databases project, but I have already encountered problems. I ave a two tables which generated scripts are posted underneath and now I’m trying to write a procedure which will add a record first to smaller one and next to the second using to it ID from the first one. But I’m getting an error:
“Column name or number of supplied values does not match table definition.”
in line which tries to add default values to the table Klienci.
I have no idea whats going on because there is no column or arguments so there should be no problem, at least like this one.

First table :

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[KlienciIndywidualni](
    [IDKlientaIndywidualnego] [int] IDENTITY(1,1) NOT NULL,
    [IDKlienta] [int] NOT NULL,
    [Imie] [nvarchar](50) NOT NULL,
    [Nazwisko] [nvarchar](50) NOT NULL,
    [NumerLegitymacji] [int] NULL,
    [Adres] [nvarchar](50) NOT NULL,
    [Miasto] [nvarchar](50) NOT NULL,
    [KodPocztowy] [nvarchar](50) NOT NULL,
    [Kraj] [nvarchar](50) NOT NULL,
    [Telefon] [int] NOT NULL,
    [Email] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_KlienciIndywidualni] PRIMARY KEY CLUSTERED 
(
    [IDKlientaIndywidualnego] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,     ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[KlienciIndywidualni]  WITH CHECK ADD  CONSTRAINT [FK_KlienciIndywidualni_Klienci] FOREIGN KEY([IDKlienta])
REFERENCES [dbo].[Klienci] ([IDKlienta])
GO

ALTER TABLE [dbo].[KlienciIndywidualni] CHECK CONSTRAINT [FK_KlienciIndywidualni_Klienci]
GO

ALTER TABLE [dbo].[KlienciIndywidualni]  WITH CHECK ADD  CONSTRAINT [CK_KlienciIndywidualni] CHECK  ((len([Telefon])>=(9)))
GO

ALTER TABLE [dbo].[KlienciIndywidualni] CHECK CONSTRAINT [CK_KlienciIndywidualni]
GO

ALTER TABLE [dbo].[KlienciIndywidualni]  WITH CHECK ADD  CONSTRAINT [CK_KlienciIndywidualni_mail] CHECK  (([Email] like '%@%.[a-z][a-z][a-z]'))
GO

ALTER TABLE [dbo].[KlienciIndywidualni] CHECK CONSTRAINT [CK_KlienciIndywidualni_mail]
GO

Second one:

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Klienci](
    [IDKlienta] [int] IDENTITY(1,1) NOT NULL,
CONSTRAINT [PK_Klienci] PRIMARY KEY CLUSTERED 
(
    [IDKlienta] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,   ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

Procedure:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE dodaj_klienta_indywidualnego 
-- parametry
@Imie nvarchar(50),
@Nazwisko nvarchar(50),
@Adres nvarchar(50),
@KodPocztowy nvarchar(50),
@Miasto nvarchar(50) ,
@Kraj nvarchar(50),
@Telefon int,
@Email nvarchar(50),
@NumerLegitymacji nvarchar(50) = null

AS
BEGIN

SET NOCOUNT ON;
declare @IDKlienta as int;

begin try
    begin tran
    --dodaj klienta
    INSERT INTO Klienci
    DEFAULT VALUES
    set @IDKlienta = @@IDENTITY;

    --dodaj klienta indywidualnego
    INSERT INTO KlienciIndywidualni
    VALUES(@IDKlienta, @Imie, @Nazwisko, @Adres, @Miasto, 
    @KodPocztowy, @Kraj, @Telefon, @Email);
    COMMIT TRAN
end try
begin catch
    declare @error as varchar(127)
    set @error = (Select ERROR_MESSAGE())
    RAISERROR('Nie mozna dodac osoby-klienta, blad danych. %s', 16, 1, @error);
    ROLLBACK TRAN
end catch
END
GO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:22:14+00:00Added an answer on June 17, 2026 at 12:22 pm

    Your second insertion needs ten parameters, you only provided 9, if you will skip the NumerLegitymacji field then you should specify each column by its name, cause the insertion now awaits the last NOT NULL column.

        --dodaj klienta indywidualnego
        INSERT INTO KlienciIndywidualni (
        IDKlienta,
        Imie,
        Nazwisko,
        Adres,
        Miasto,
        KodPocztowy,
        Kraj,
        Telefon,
        Email
    )
        VALUES(@IDKlienta, @Imie, @Nazwisko, @Adres, @Miasto, 
        @KodPocztowy, @Kraj, @Telefon, @Email);
        COMMIT TRAN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.