SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    not sure if this insert query is compatible

    I'm sure this isn't the best idea but I use Access2000 linked to my postgresl 7.4 database to help me create my queries quickly. Then I move the query and make it work for Dreamweaver MX 2004/PHP. I'm trying to create an append query that will dump multiple records into a table. I'm not sure if this sql is compatible with my setup but here it is:

    INSERT INTO tbl95 ( col13, col2, col27, col28, col30, col31, col32, col33, col34 )
    SELECT view1.col23, view1.col2, view1.physician, view1.totaltopay, view1.col4, view1.col5, view1.col6, view1.col7, view1.col8
    FROM view1
    WHERE (((view1.col23)='recordid66'))

    I'm also trying to get it so that col35 would be a sequential number starting from a parameter is set. ie. the user enters 122, then the records that are added would enter into col35 the number 122, then on the next record it would add 123, then next record 124, etc. Is this all possible?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    your INSERT statement is fine, it is standard sql so postgresql should have no problem with it

    as far as autoincrements go, they are different in postgresql (i think they use sequences or serials) so you would have to experiment with it

    i don't have postgresql or i would experiment with it for you, not having anything else better to do today...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I looked at the autonumber fields for my primary keys in the postgres tables and the database lists the default on the primary key as such(for the primary key col1 in tbl95):

    nextval('public.tbl95_col1_seq'::text)

    Is there anyway to use this to increments the numbers in the records I'm inserting using this from the users initial number they enter?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •