0 Pluspunkte 0 Minuspunkte

Wie bekomme ich die Last Insert ID in Powershell? Bei mir zeigt es jedes mal 0.

& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Alice', 30);"
$i = & $SQLitePath $Database "SELECT last_insert_rowid();"
$i
& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Bob', 25);"
$i = & $SQLitePath $Database "SELECT last_insert_rowid();"
$i
& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Charlie', 35);"
$i = & $SQLitePath $Database "SELECT last_insert_rowid();"
$i
von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Versuch es in einem einzelnen Query zu senden.

& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Alice', 30);SELECT last_insert_rowid();"
& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Bob', 25);SELECT last_insert_rowid();"
& $SQLitePath $Database "INSERT INTO users (name, age) VALUES ('Charlie', 35);SELECT last_insert_rowid();"
von (844 Punkte)