INSERT OR UPDATE [message #355875] |
Tue, 28 October 2008 04:49 |
cotoga
Messages: 2 Registered: October 2008
|
Junior Member |
|
|
Hi all,
i have a little problem.
in my database exists a table with SQL-Statements which are executed daily. Also "Grant"-Statements.
To get an overview, which user have rights on which table, i wrote a short query.
You see, I'm german (look at query ).
The table columns:
BENUTZER (USER) PKEY/IDX
TABELLE (TABLE) PKEY/IDX
RECHTE (RIGHTS)
KOMMENTAR (COMMENT)
The comment field will be filled manually by me.
An my problem is now, to fill the table with data without violation due to double entrys (user/table).
When the entry exists, the query should update it, else insert a new one.
But I don't know a procedure for "insert or update"
"INSERT INTO OR UPDATE" ... USER_TABLE (BENUTZER,TABELLE,RECHTE)
FROM
(
SELECT
SQLCODE
,substr(SQLCODE,instr(SQLCODE,' TO ')+4,length(SQLCODE)-instr(SQLCODE,' TO ')+4) AS BENUTZER
,substr(SQLCODE,instr(SQLCODE,' ON ')+4,instr(SQLCODE,' TO ')-instr(SQLCODE,' ON ')-4) AS TABELLE
,substr(SQLCODE,7,instr(SQLCODE,'ON')-7) AS RECHTE
FROM AA_SUP_SQL_BATCH
WHERE SQLCODE LIKE 'GRANT%'
)
Perhaps anyone can help me.
Kind regards
Stephan
|
|
|
|
|
|