plsql

Use for loop after the With Clause in PL/SQL

泄露秘密 提交于 2021-02-08 15:46:05
问题 Im using PL/SQL. I am trying to have a for loop right after I define my temporary tables in the with clause. However, Im getting an error to have a SELECT query first. For instance WITH TMP1 AS (.....), TMP2 AS (......), TMP3 AS (......) FOR R IN (SELECT DISTINCT ..... FROM TMP1 WHERE .....) LOOP SELECT .... FROM TMP2, TMP2 WHERE TMP2.... = R..... .... How do I go about doing so? Thanks 回答1: You can't access a CTE outside of the whole statement. And you can't access individual parts of a CTE

ORA-01438: value larger than specified precision allows for this column

给你一囗甜甜゛ 提交于 2021-02-08 12:22:10
问题 We get sometimes the following error from our partner's database: <i>ORA-01438: value larger than specified precision allows for this column</i> The full response looks like the following: <?xml version="1.0" encoding="windows-1251"?> <response> <status_code></status_code> <error_text>ORA-01438: value larger than specified precision allows for this column ORA-06512: at "UMAIN.PAY_NET_V1_PKG", line 176 ORA-06512: at line 1</error_text> <pay_id>5592988</pay_id> <time_stamp></time_stamp> <

ORA-01438: value larger than specified precision allows for this column

a 夏天 提交于 2021-02-08 12:18:49
问题 We get sometimes the following error from our partner's database: <i>ORA-01438: value larger than specified precision allows for this column</i> The full response looks like the following: <?xml version="1.0" encoding="windows-1251"?> <response> <status_code></status_code> <error_text>ORA-01438: value larger than specified precision allows for this column ORA-06512: at "UMAIN.PAY_NET_V1_PKG", line 176 ORA-06512: at line 1</error_text> <pay_id>5592988</pay_id> <time_stamp></time_stamp> <

Is there a way to display dynamic columns in Oracle apex

≡放荡痞女 提交于 2021-02-08 11:15:25
问题 Long story short, I can't use pivot for this task due to the long elements that I need to include in the columns. Although I tried to create a Classic Report based on function in Oracle Apex. The query it's generated correctly but it's not working in the Classic Report. 回答1: A general hint first: Output your variable l_sql to your console using dbms_output.put_line or use some kind of debugging table where you can insert it into. Also be careful about the data type of that variable. If you

Why PLS-00382: expression is of wrong type?

半世苍凉 提交于 2021-02-08 10:59:55
问题 I have the following custom RECORD TYPE : TYPE TB48_RECTYPE IS RECORD ( codpo varchar2(5 BYTE), codco varchar2(5 BYTE), quadr varchar2(5 BYTE), espec varchar2(5 BYTE), aperf varchar2(5 BYTE), subes varchar2(5 BYTE), datin date); And now a function that returns the exact same type. function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is retorno_REC TB48_RECTYPE; begin select m.CODPO, m.CODCO, m.QUADR, m.ESPEC, m.APERF, m.SUBES, m.DATIN into retorno_REC from TB48_M m where m

Why PLS-00382: expression is of wrong type?

*爱你&永不变心* 提交于 2021-02-08 10:57:17
问题 I have the following custom RECORD TYPE : TYPE TB48_RECTYPE IS RECORD ( codpo varchar2(5 BYTE), codco varchar2(5 BYTE), quadr varchar2(5 BYTE), espec varchar2(5 BYTE), aperf varchar2(5 BYTE), subes varchar2(5 BYTE), datin date); And now a function that returns the exact same type. function retorna_infos_tabela_48(i_nip in varchar2) return TB48_RECTYPE is retorno_REC TB48_RECTYPE; begin select m.CODPO, m.CODCO, m.QUADR, m.ESPEC, m.APERF, m.SUBES, m.DATIN into retorno_REC from TB48_M m where m

Plsql best way to split string

心已入冬 提交于 2021-02-08 10:09:54
问题 What is the best way to extract words from a string? I already made something up because I found many ways and none of them looked 'simple'. Let's assume there is a procedure called 'change_opening_hours'. This procedure has a time-range string input called 'v_perioden'. This string looks like: '10:00-12:00' OR '10:00-12:00 14:00-16:00' OR '10:00-12:00 14:00-16:00 18:00-22:00' etc Now I already made something up myself to exstract every period of time from this input. v_perioden VARCHAR2(50)

Practical life examples of oracle explicit cursor use

心不动则不痛 提交于 2021-02-08 09:23:10
问题 I couldn't think of a practical situation to use explicit cursors in PL/SQL code. Can anybody please share some scenarios? Thanks! 回答1: If a cursor is used more than once in a program unit, an explicit cursor allows you to code the SQL once, which is good for maintenance. 回答2: There are two clear use cases for explicit cursors. The first is when we want to probe for the existence of a record and handle the outcome in the main flow of our code: open emp_cur (p_empno); fetch emp_cur into l_emp

timezone-dependant systimestamp and timestamp comparison on Oracle

爷,独闯天下 提交于 2021-02-08 08:34:20
问题 I've run into a weird situation. Could someone explain why comparison between timestamp and timestamp behaves as below (it depends on session timezone...). In addition outputed values are identical in all cases. It looks like timestamp inherits timezone from the session for comparison purposes, but for printing it does not? Queries: alter session set time_zone = '-6:0'; select cast(systimestamp as timestamp), systimestamp, case when cast(systimestamp as timestamp) < systimestamp then

dynamic table name without using cursors

本秂侑毒 提交于 2021-02-08 07:41:05
问题 I want to use dynamic table name within a for loop. I understand that there are solutions to this problems by using cursors. But I was wondering if there is a solution without cursor as my current code has generic for loop (implicit cursors) and I wanted to know if I can retain it the same way without going for explicit cursors. What works for me right now is: BEGIN for itr in (select var1,var2,var3,var4 from schedule_table) loop --work using itr.var1, itr.var2, itr.var3, itr.var4 end loop