how to populate sysdate in apex_item.date_popup - oracle

i have created apex_item.datepopup() function to provide entry for user to select date from calendar, it should populate sysdate bydefault..
APEX_ITEM.DATE_POPUP (2,ROWNUM,ISSUED_DATE,'dd-mon-yyyy')

Try this:
APEX_ITEM.DATE_POPUP (2,ROWNUM, nvl(ISSUED_DATE, sysdate),'dd-mon-yyyy')

Directly copied from my code where I have it
APEX_ITEM.DATE_POPUP (p_idx => 2 , p_value => (CASE WHEN UPPER(cur_parameter.default) = 'SYSDATE' THEN SYSDATE WHEN UPPER(cur_parameter.default) != 'SYSDATE' AND cur_parameter.default IS NOT NULL THEN TO_DATE(cur_parameter.default) ELSE NULL END) , p_item_id => cur_parameter.name, p_date_format => cur_parameter.format , p_item_label => cur_parameter.name)
The CASE is because I keep the defaults stored in a table, and most of the time, the default date is sysdate, however, its viewed as a string and not SYSDATE. The cur_parameter is a row in a cursor.
If a call has more than one or two parameters, its always best to use named notation, avoids confusion and helps prevent mix ups.

APEX_ITEM.DATE_POPUP (p_idx =>2 , p_value => SYSDATE , p_item_id => ISSUED_DATE, p_date_format => 'DD-MON-YYYY') IssuedDate,

Related

ORA 00907 Missing Right Parenthesis

I am getting this Error of "Missing Right Parenthesis" on the Query below. Can someone rectify the mistake please?
SELECT
DESCRIPTION,
TOTAL_ADMISSION,
EMERGENCY,
NORMAL
FROM TABLE (ORDERENTRY.PKG_S04REP00031.ADMISSION_SUMMARY(P_START_DATE = to_date('31/08/2021', 'dd/mm/yyyy')
P_END_DATE = to_date('01/09/2021', 'dd/mm/yyyy')
P_ADMISSION_TYPE = 'NORMAL'
/*P_ORDER_LOCATION_ID => :P_ORDER_LOCATION_ID, */
P_LOCATION_ID = 'K01'));
This should work
SELECT
DESCRIPTION,
TOTAL_ADMISSION,
EMERGENCY,
NORMAL
FROM TABLE (ORDERENTRY.PKG_S04REP00031.ADMISSION_SUMMARY(P_START_DATE => to_date('31/08/2021', 'dd/mm/yyyy') ,
P_END_DATE => to_date('01/09/2021', 'dd/mm/yyyy') ,
P_ADMISSION_TYPE => 'NORMAL' ,
--P_ORDER_LOCATION_ID => :P_ORDER_LOCATION_ID,
P_LOCATION_ID => 'K01')
);
You are using select from table(package.function, therefore
Parameters values in functions or packages follow the sign => not =
Parameters are separated by comma
I replaced /* */ just for --, just for cosmetic purposes, as both represent comments, but the later is more common when you want to comment just one line

how convert sql to Laravel

I am new to laravel, I am having trouble converting my sql to Laravel Query.
Example
INSERT INTO table(field1, field2) SELECT 'value1', 'value2' WHERE NOT EXISTS(SELECT 1 FROM tabla WHERE campo = 'search');
this is my code
INSERT INTO siryus.presupuesto_anio (id, fk_agencia_id, anyo, estado, created_at, updated_at) SELECT 30,4,2020, 'A', '2021-04-21 10:35:01','2021-04-21 10:35:01' WHERE NOT EXISTS(SELECT 1 FROM presupuesto_anio WHERE fk_agencia_id = '4');
i want insert only if there is no field with that value. The insert is done only if there are values ​​of the select, and the select will return data only if the WHERE is met.
Inside the WHERE we have a simple SELECT that verifies if the data exists in the table.
I want to convert it to example code
DB::table('presupuesto_anio') ->join('agencia','presupuesto_anio.fk_agencia_id','agencia.id') ->select('presupuesto_anio.*','agencia.descripcion') ->get();
im not understand with your questions, maybe this will help:
$check = Model::where('id', 4)->first();
if(!$check){
Model::create({
'column1' => 'value1',
'column2' => 'value2'
});
}

how to add a checkbox with condition in oracle apex

I have created one tabular form(legacy page) in oracle apex and in some columns i have given type checkbox.I just want to add a condition that if that column value is 'y' then it is already checked otherwise unchecked.
please help me regarding this.
You can do it by adding case statement in the select query and give the conditions there.
Set SQL query something like this:
select ID, name, my_column
APEX_ITEM.CHECKBOX2(
p_idx => 2, p_value => ID,
p_checked_values => case when my_column = 'Y' then ID else null end
) checkbox
from my_table;

DBMS_STATS with Looping

I just tried to learn new things. I just make a experiment to analyze tables with looping. But, I found error that said
'Invalid reference to variable 'indx'
. If I take out the DBMS_STATS 'thing' and just to print the result, it works. But when I tried to analyze the tables, the error came out.
CREATE OR REPLACE PROCEDURE ANALYZE_TABLE
AS
CURSOR table_cur IS
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE TABLE_NAME LIKE 'STUDENT%';
table_nm table_cur%ROWTYPE;
TYPE table_nms IS TABLE OF table_nm%TYPE;
l_table table_nms;
BEGIN
OPEN table_cur;
FETCH table_cur BULK COLLECT INTO l_table;
CLOSE table_cur;
FOR indx IN 1..l_table.COUNT LOOP
IF (indx.table_name = 'STUDENT_DETAILS') THEN
dbms_stats.gather_table_stats(ownname => 'ADMIN', tabname => indx.table_name , estimate_percent => 100,
method_opt => 'for all indexed columns size auto',
degree => 4 ,cascade => TRUE );
ELSIF (indx.table_name = 'STUDENT_ALLOWANCE' OR indx.table_name = 'STUDENT_PAYMENT')
THEN
DBMS_STATS.GATHER_TABLE_STATS (ownname => 'ADMIN', tabname => indx.table_name , estimate_percent => 100,
method_opt => 'for all indexed columns size auto',
degree => 4 ,cascade => TRUE );
ELSE
DBMS_STATS.GATHER_TABLE_STATS (ownname => 'ADMIN', tabname => indx.table_name , estimate_percent => 100,
method_opt => 'for all indexed columns size auto',
degree => 4 ,cascade => TRUE );
END IF;
--DBMS_OUTPUT.PUT_LINE(l_table(indx).TABLE_NAME);
END LOOP;
END ANALYZE_TABLE;
Any suggestion? Or a better way to analyze tables with this loop?
Thank you in advance for anyone that helping me. :)
You need to reference the contents of your array, not the loop index. The loop index tells you which element in the array. So:
IF (l_table(indx).table_name = 'STUDENT_DETAILS') THEN
and so on
You should reference the values in your table as follows:
if (l_table(indx).table_name = 'STUDENT_DETAILS') ...

Split owner and object name in Oracle

Given an object identified by the form owner.tablename; how do I split the owner and table name up?
Both my ideas of either string tokenization or select owner, object_name from all_objects where owner || '.' || object_name = 'SCHEMA.TABLENAME' seem like hacks.
You can use DBMS_UTILITY.name_tokenize for this purpose.
This procedure calls the parser to parse the given name as "a [. b [.
c ]][# dblink ]". It strips double quotes, or converts to uppercase if
there are no quotes. It ignores comments of all sorts, and does no
semantic analysis. Missing values are left as NULL.
e.g.
DBMS_UTILITY.NAME_TOKENIZE
( name => 'SCHEMA.TABLENAME'
, a => v_schema
, b => v_object_name
, c => v_subobject -- ignore
, dblink => v_dblink
, nextpos => v_nextpos -- ignore
);
http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_util.htm#BJEFIFBJ
SELECT SUBSTR('SCHEMA.TABLENAME', 0, INSTR('SCHEMA.TABLENAME', '.') - 1) OWNER,
SUBSTR('SCHEMA.TABLENAME', INSTR('SCHEMA.TABLENAME', '.') + 1) TABLE_NAME
FROM DUAL

Resources