conditional query in access db

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eitan M

    #1

    conditional query in access db

    Hello,

    In access db (2002),
    How can I make the equivalent :

    something like the pseudo code :

    if not exists (
    select ... from table_name) then
    insert into table...
    else
    update table.


    In Oracle it is :
    begin
    update table where id = ...
    if sql%notfound then
    insert into ...
    end if;
    end;

    How can I do the above in MS-Access.

    Need sample code, please.

    Thanks :)


  • Rick Wannall

    #2
    Re: conditional query in access db

    You cannot do this in a single Access query. The equivalent Microsoft tool
    for Oracle is SQL Server, in which you would use T-SQL and write a very
    similar stream of SQL/T-SQL to what you posted.

    To do something similar in Access, you will have to write some VB. One
    approach would be to create a form dedicated to this process, with a button
    that starts it. Inside the module you could use VB to test the conditions
    you're looking at and then either run saved Access queries or execute the
    SQL directly off the database object with .EXECUTE.
    [color=blue]
    >
    > In access db (2002),
    > How can I make the equivalent :
    >
    > something like the pseudo code :
    >
    > if not exists (
    > select ... from table_name) then
    > insert into table...
    > else
    > update table.
    >
    >
    > In Oracle it is :
    > begin
    > update table where id = ...
    > if sql%notfound then
    > insert into ...
    > end if;
    > end;
    >
    > How can I do the above in MS-Access.
    >
    > Need sample code, please.
    >
    > Thanks :)
    >[/color]


    Comment

    Working...