Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!

Hugo Nilsson

Ranch Hand
+ Follow
since Sep 05, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hugo Nilsson

So I have this function:


This returns 1 or 0 if allowed. I need to do a procedure which adds a row in a table called withdraw and that procedure needs to call get_authorization to check if the customer is allowed. This is what i have so far:

I know that i have a weird select statement in the if expression but thats how i have tried testing the code. Hope you understand
So i think i made some progress:



I deleted for each row and added that where clause. This lets me insert without error but it does not update the saldo on account
So it should update the balance and add the deposit. This code can be run and it says trigger created. But when i try to insert into amount then i get error:
ORA-04091: table SQL_ZIZHVESYDEVONPUGGMMFKTSPB.INSÄTTNING is mutating, trigger/function may not see it ORA-06512: at "SQL_ZIZHVESYDEVONPUGGMMFKTSPB.AIFER_INSÄTTNING", line 2
Anybody know why this dosent do as I intend it to?



How about if declare konto.saldo as number?
So i made a change where i think it was meant:



But i recieve two error:

Line/Col: 9/1 PL/SQL: SQL Statement ignored
Line/Col: 10/8 PL/SQL: ORA-00936: missing expression
If i understand what you mean then yes. The saldo should be updated with the calculation in SET and then printed out.
So my procedure should add a row to the table INSÄTTNING. Some keys are reference keys. When the row has been inserted it should take P_BELOPP and subtract it with SALDO which is in another table called KONTO. The new amount should be added into that column and replace the old amount. My code looks like this so far:


I get that SALDO must be declared error.

Hope its pretty understandable
I tried this and get error on the select. I also tried putting get_saldo in the sum expression and then got error on sum
So i have a function that returns saldo. It looks like this:



My trigger should call get_saldo and check that the amount of money being inserted in the withdraw table is not more than money on the account. My trigger looks like this so far:


Hope you guys understand what i mean. And i know what this forum thinks about stored procedures but i really need to use it. Its a school task where we need to use stored procedures.
Im sorry to be a pain in the butt. This is a school task(maybe i should have said that earlier) so i really need to do it
Yes sir i hear you. The thing is that i need to practice funtions(i thought this was mandatory stuff so maybe im no fairly new). So when a pnr and passwd get insertet and i call the function it should return 1 or 0 depending on how it went. Hope you understand it
Dave: I get: SQL Statement ignored. And: ORA-00947: not enough values.
Tim: I understand what you say and i agree with you but i need to make it a function
So im fairly new to sql so this function needs to be quite simple. My code example is this:



When i call it like this:

It should return 1 if found and 0 if not found. I just cant figure it out
When i used the suggested line: select to_date(substr(pnr,1,8)) - sysdate
I get:  literal does not match format string ORA-06512.
And when i use the suggested line: select ROUND(MONTHS_BETWEEN(SYSDATE, pnr)/12.0, 1) AS age_5
I get the same error