NULL in Oracle

Key Points

The special value NULL means no data, a statement of the fact that the value is unknown. By default, columns, and variables of any type can take this value unless they have a NOT NULL constraint. Also, the DBMS automatically adds a NOT NULL constraint to columns included in the table's primary key.

The main feature of NULL is that it is not equal to anything, not even another NULL. You cannot compare any value with it using any operators: =, <, >, like ... Even the expression NULL != NULL will not be true because one cannot uniquely compare one unknown with another. By the way, this expression will not be false either because when calculating the conditions, Oracle is not limited to the TRUE and FALSE states. Due to the presence of an element of uncertainty in the form of NULL, there is one more state — UNKNOWN

NullPointerException in Java: Causes and Ways to Avoid It

NullPointerException: the Most Common Exception

NullPointerException (NPE) is the most common exception in Java. The cause of this exception is known but looks like that in most cases developers prefer to ignore it and don't take any action. I personally expect that reasons for such behavior are the following: 

  • Most of the developers don't see any problem here and recognize all NPE exceptions as the developer's fault. 
  • Developers who are aware of this design problem don't know how to fix it. 

In this article, I'll explain what is the root of this problem and provide ways to fix that problem.

We need to talk about Job Interview Questions

Let me ask you a question; When was the last time you implemented Quick Sort? If you're an experienced developer, there's a 99% statistical probability of that you'll answer "at university." Still, no job interview seems to be complete unless you can correctly describe the pivot value in a multiple choice type of question. Ignoring the fact of that you could probably program your calculator to answer these questions, the relevance of these types of questions is; ZIP, NADA, NOTHING, NULL!

98% of my job as an enterprise software developer is composition, architecture, class design, and similar things. In fact, even if I try, I cannot imagine one single real world use case that involves me needing to know Quick Sort - But then again, what do I know? I only have 20+ years of professional experience. If some problem actually do need me to remember Quick Sort, I can probably copy and paste Jon Skeet's code from StackOverflow faster than I can twist my brain for the correct solution anyway.

Oracle SQL Performance Plan Review Automation

Why Do We Need a SQL Performance Review?

  1. The current code review process is manual and doesn’t capture the Explain Plan for all modified queries.
  2. Currently, lead devs, along with developers, run Explain Plans manually in Toad/SQL Developer.
  3. To build an automated tool to capture problematic queries from an Explain Plan perspective and reduce manual oversight.
  4. To provide performance audits with data points.

Solution

  • Oracle stores all the SQL database in-page memory and indexes it by SQL ID in gv$sqltext
  • During development (PLSQL/Java/OA Framework/XML Publisher), tag all the desired SQL queries with a code comment (Release Name/User Story Number).
  • Develop a PLSQL program with below features:
    • Analyze the Execution Plan of queries executed by a concurrent program/Java program/OAF code/forms/reports/BI publisher reports.
    • Generate a report with queries which could impact performance. For example, queries with FULL TABLE SCAN, MERGE CARTESIAN JOIN, FULL INDEX SCAN.
    • Capability to categorize queries at User Story, Sprint, Release, and Scrum Team levels based on program input parameters.
    • Capability to analyze queries executed by a concurrent program/package/Java modules.
    • Capture data of relevant queries analyzed in a table for future analysis and dashboards.
    • Store the generated Explain Plan in a database table for audit purposes.
  • In the Oracle E-Business Suite world, this program can be registered as an executable of concurrent programs and assigned to a request group.
  • Before a release migration, the SysAdmin can put together a business process to execute this concurrent program to review the Explain Plan for the SQL queries for that release and catch any trouble making queries well in advance.

Sample Query

SQL
 




x
111


 
1
SELECT DISTINCT obj.object_name
2

          
3
                        ,program_line#
4

          
5
                        , cpu_time / 1000000 AS cpu_time_in_secs
6

          
7
                        , elapsed_time / 1000000 AS elapsed_time_in_secs
8

          
9
                        ,buffer_gets
10

          
11
                        ,disk_reads
12

          
13
                        ,end_of_fetch_count AS rows_fetched_per_execution
14

          
15
                        ,executions
16

          
17
                        ,optimizer_cost
18

          
19
                        ,vsql.sql_id
20

          
21
                        ,NULL operation
22

          
23
                        ,NULL options
24

          
25
                        ,vsplan.plan_hash_value
26

          
27
                        ,sql_text
28

          
29
                        , ( SUBSTR ( DBMS_LOB.SUBSTR ( sql_fulltext
30

          
31
                                                      ,4000
32

          
33
                                                      ,1
34

          
35
                                                     )
36

          
37
                                    , INSTR ( DBMS_LOB.SUBSTR ( sql_fulltext
38

          
39
                                                               ,4000
40

          
41
                                                               ,1
42

          
43
                                                              ), '/*' ) + 2
44

          
45
                                    , INSTR ( DBMS_LOB.SUBSTR ( sql_fulltext
46

          
47
                                                               ,4000
48

          
49
                                                               ,1
50

          
51
                                                              ), '*/' ) - INSTR ( DBMS_LOB.SUBSTR ( sql_fulltext
52

          
53
                                                                                                   ,4000
54

          
55
                                                                                                   ,1
56

          
57
                                                                                                  ), '/*' ) - 2
58

          
59
                                   )
60

          
61
                          ) release_string
62

          
63
                        ,NULL error_flag
64

          
65
                        ,NULL error_message
66

          
67
                        ,loads
68

          
69
                        ,first_load_time
70

          
71
                        ,user_io_wait_time
72

          
73
                        ,rows_processed
74

          
75
                        ,last_load_time
76

          
77
                        ,vsql.module
78

          
79
                        ,fnd_global.user_id created_by
80

          
81
                        ,SYSDATE creation_date
82

          
83
                        ,fnd_global.user_id last_updated_by
84

          
85
                        ,SYSDATE last_update_date
86

          
87
                        ,'-1' last_update_login
88

          
89
         FROM            gv$sql vsql
90

          
91
                        ,gv$sql_plan vsplan
92

          
93
                        ,all_objects obj
94

          
95
         WHERE           1 = 1
96

          
97
         AND             vsql.sql_id = vsplan.sql_id
98

          
99
         AND             vsql.sql_fulltext NOT LIKE '%sql_text%'
100

          
101
         AND             vsql.program_id = obj.object_id(+)
102

          
103
         AND             vsql.sql_fulltext LIKE lv_pattern
104

          
105
         AND             TO_DATE ( last_load_time, 'YYYY-MM-DD/HH24:MI:SS' ) >= ( SYSDATE - p_hours_from / 24 )
106

          
107
         AND             nvl(obj.object_name, '-') = NVL(p_program,nvl(obj.object_name, '-'))
108

          
109
         AND             nvl(vsql.module, '-') = NVL(p_module,nvl(vsql.module, '-'))
110

          
111
         ORDER BY        last_load_time DESC;


fnd_file.put_line(fnd_file.output, 'String..') – This can be used to print the SQL plan in a concurrent program output file.

Sample Output

How can I get to the derivative of polynomial using LinkedList?

This is my derivative function. This code works correctly but does not delete the constant term. It sets directly to 0 and writes to the result. how can i fix this? Thank you..
EX:
Input: "-x^3-6x^2+ 4x+22"
Output: -3.0x^2 -12x +4.0 + 0.0
How can i delete this 0.0?

struct PolyNode { 
    double coef;              
    int exp;                  
    struct PolyNode* next;    
}; 
/////////////////////////////////////// 
PolyNode* Derivative(PolyNode* poly) { 
    PolyNode* current = new PolyNode; 
    current = poly; 

    //Just goes through entire list 
    while (current != NULL) { 
        if (current->exp == 0) { 
            current->coef = 0; 
            current->exp = 0; 
            current = current->next; 
        } 
        else { 
            current->coef = current->coef * current->exp; 
            current->exp = current->exp - 1; 
            current = current->next; 
        } 
    } 


    return poly;

Stack program not accepting string(word).

Im trying to create a program that accepts a string of characters, which should be able to perform push, pop and peek. The code is running, but the program only accepts the first letter of the string. Ive tried many different ways to implement the code, but Im still not getting the program to work as expected. I have a fair understanding how to use stack to accept numbers, but Im unable to perform the task on a string of characters. Each node should store one character from the word.

Note: some functions were snippets of code from online source that were slightly implemented in a different way.

#define MAX 100

struct stack
{
    char data;
    struct stack *next;
};

struct stack* top;

int size = 0;

void push(char *element);
char pop();
int peek();
void display();

int main()
{
    int choice;
    char str[MAX];

    printf("******** Stack using linked list ********\n\n");

    printf("Enter a word(no longer than 100 characters) :");
    scanf("%s",str);
    char* strcpy(str);

    while(1)
    {
        printf("******** Menu ********\n");
        printf(" 1. Push\n 2. Pop\n 3. Peek \n 4. Display\n 5. Exit\n");
        printf("Enter your choice: ");
        scanf("%d", &choice);

        switch(choice)
        {
            case 1:
                push(str);
                break;

            case 2:
                *str = pop();

                if (str != '\0')
                    printf("Data => %s\n", str);
                break;

            case 3: if(isEmpty(top)){
                        printf("Stack is empty!\n");
                    }else{
                        printf("Stack is not empty!\n");
                    }

                    peek(str);
                break;

            case 4: display();
                break;

            case 5:
                printf("\nProgram Exited\n");
                exit(0);
                break;

            default:
                printf("Incorrect selection!\n");
        }

        printf("\n");
    }

    //reverse(str);

    return 0;
}

void push(char *element)
{
    int i;
    if (size >= MAX)
    {
        printf("Stack Overflow.\n");
        return;
    }

    struct stack * newNode = (struct stack*)malloc(sizeof(struct stack));
    newNode -> data = *element;
    newNode -> next = top;
    top = newNode;

    size++;

    printf("\nSuccessfully added to stack!!\n");
}

char pop()
{
    char data;
    struct stack *newNode;

    if (size <= 0 || !top)
    {
        printf("Stack is empty.\n");
        return 1;
    }

    newNode = top;
    data = top->data;
    top = top->next;
    free(newNode);

    size--;

    return data;
}

int isEmpty(struct stack* root)
{
    return root == NULL;
}

int peek(struct stack *top;)
{
    if (!isEmpty(top))
        return top-> data;
    exit(0);
}


void display(){

    struct stack* newNode;
    if(top == NULL){
        printf("\nStack is Empty!!!\n");
    }else{
        newNode = top;
        while(newNode != NULL){
            printf("%c--->", newNode -> data);
            newNode = newNode -> next;
        }
    }
}

pass multiple inputs to proc_open pipe in php

I am trying to create an interactive terminal to use in a project that I am working on. the idea is that I will have a web page which looks like a terminal and can use it to work with command line tools. anyway I need to use php as my service was built on php and I am familiar with it , but I couldn't get to a point where I can send multiple commands to bash (I am using bash for testing) , here is my last code snippet which seems to be able to send the given commands but I am not sure because the output of the commands is 1 !

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);


$descs = array(

    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "error.txt", "w")
);


$cmd = "/bin/bash";


$proc = proc_open($cmd, $descs, $pipe, NULL);
stream_set_blocking($pipe[0], 0);
stream_set_blocking($pipe[1], 0);

if(!$proc) {
$error_file = fopen("error.txt", "r");
echo "Error !" . fread($error_file, filesize($error_file));
fclose($error_file);
exit();
}

$status = proc_get_status($proc);
print_r($status);

if(is_resource($proc)) {

$commands = ["id", "whoami", "ls"]; 
$n = 0;
$output = "";
while($n < 3) {
    echo $commands[$n];
    usleep(1000);   
    fwrite($pipe[0], $commands[$n] . PHP_EOL );
    fflush($pipe[0]);
    usleep(1000);

    while($out = stream_get_contents($pipe[1]) && !feof($pipe[1])){

        $output .= $out ;

    }
    echo $output;   
    $n++;
}

} 
?>

Open Website from String variable

Hi, so I am very new to coding and I wanted to make something that opens a website stored in a string variable like this:

#include <string>
#include <iostream>
#include <windows.h>

int main()
{
string url = https://google.com;

//now I dont know how to open the url from the string
ShellExecute(NULL, "open", "https://google.com", NULL, NULL, SW_SHOWMAXIMIZED);
}

Unfortunately I dont know how to open the url from the string. I know how to open an url but not how to open one stored in a variable.
Tanks for all answers.

edit a Registry Key (REG_SZ) with c++

Hi, guys i am trying to create a String in the Windows Registry to imput some nice Proxy Adress. But i failed to input the correct datatype. I do not have any problems with Type (DWORD)... But (REG_SZ) has not work. Can someone tell me how can i input in the Registry a HTTPs Adress like "HTTPS://www.google.com" as a test. :)

Thank you

Below my code the secound part works fine :) I am struggling with REG_SZ :(

include

include

void add_proxy()

long pro;
HKEY hKeyp;
// under this field should be the Type REG_SZ to input a Proxy Adress
REG_SZ "proxy";
pro = RegCreateKeyEx(
    HKEY_CURRENT_USER,
    L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\test",
    0,
    NULL,
    REG_OPTION_NON_VOLATILE,
    KEY_ALL_ACCESS | KEY_WOW64_32KEY,
    NULL,
    &hKeyp,
    NULL);

// Status of work
if (pro != ERROR_SUCCESS)
{
    std::cout << "Registry creation failed & Error No - " << GetLastError() << std::
        endl;
}
std::cout << "Registry creation success" << std::endl;

lReg = RegSetValueEx(
    hKeyp,
    L"ProxyEnable",
    NULL,
    REG_SZ,
    (LPBYTE)&value,
    sizeof(value)
);
//Status of work
if (pro != ERROR_SUCCESS)
{
    std::cout << "Registry creation failed & Error No - " << GetLastError() << std::
        endl;
}
std::cout << "Registry creation success" << std::endl;

RegCloseKey(pro);

//Part 2

LONG lReg;
HKEY hKey;
DWORD dwData =00000001;
lReg = RegCreateKeyEx(
    HKEY_CURRENT_USER,
    L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
    0,
    NULL,
    REG_OPTION_NON_VOLATILE,
    KEY_ALL_ACCESS | KEY_WOW64_32KEY,
    NULL,
    &hKey,
    NULL);
    // Status of work
if (lReg != ERROR_SUCCESS)
{
    std::cout << "Registry creation failed & Error No - " << GetLastError() << std::
        endl;
}
std::cout << "Registry creation success" << std::endl;

lReg = RegSetValueEx(
    hKey,
    L"ProxyEnable",
    NULL,
    REG_DWORD,
    (LPBYTE)&dwData,
    sizeof(dwData)
);
    //Status of work
if (lReg != ERROR_SUCCESS)
{
    std::cout << "Registry creation failed & Error No - " << GetLastError() << std::
        endl;
}
std::cout << "Registry creation success" << std::endl;

RegCloseKey(hKey);
system("PAUSE");

What Exactly Nullptr Is in C++?

The answer to "What exactly nullptr is in C++?" would be a piece of cake for experienced C++ programmers and for those who are aware of Modern C++ (i.e. keyword). But nullptr is more than just a keyword in C++, and to explain that, I have written this article. But, before I jump into it, we will see issues with NULL. Then, we'll dive into the unsophisticated implementation of  nullptr and some use-cases of nullptr.

Note: This article is more or less the same thing which you can find here, here, and in nullptr proposal(N2431) but with a more organized and simplified explanation.

I have a problem with the last text.It dosen’t appere

This is my code.

#include "pch.h"
#include <iostream>
#include <Windows.h> 
#include <string>
#include <ctime>
#include <fstream>

using namespace std;

std::string AppName = "League of Legends";
LPCSTR LAppWindow = "Riot Client";
std::string AppStatus;

bool IsAppAvil;
bool Update;

int main()
{
    //Start App
    ShellExecuteA(NULL,"open","D:\\Games\\Riot Games\\League of Legends\\LeagueClient.exe\\",NULL,NULL, SW_SHOWDEFAULT);

    //Checking if app is running
    HWND hGameWindow = NULL;
    int timeSinceLAstUpdate = clock();
    int AppAvailTMR = clock();
    int onePressTMR = clock();
    int Timer = 0;
    DWORD dwProcID = NULL;
    HANDLE hProcHandle = NULL;

    while(!GetAsyncKeyState(VK_ESCAPE))
    {
        Timer += 1;
        if (clock() - AppAvailTMR > 100)
        {
            AppAvailTMR = clock();
            IsAppAvil = false;

            hGameWindow = FindWindowA(NULL, LAppWindow);

            if (hGameWindow)
            {
                GetWindowThreadProcessId(hGameWindow, &dwProcID);
                if (dwProcID != 0)
                {
                    hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
                    if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
                    {
                        AppStatus = "Faild to open.Invalid HANDLE";
                    }
                    else
                    {
                        AppStatus = "App opend";
                        IsAppAvil = true;
                    }
                }
                else
                {
                    AppStatus = "Faild to open.Didn't get the process ID";
                }
            }
            else
            {
                AppStatus = "Faild to open.App not found";
            }
        }

            Sleep(1000);
            system("cls");
            cout << "-------------------------------------------------------------------" << endl;
            cout << "                      Auto App Loger" << endl;
            cout << "-------------------------------------------------------------------" << endl;
            cout << "APP STATUS: " << AppStatus << endl;
            cout << "[ESC] exit" <<endl;

    }

    return ERROR_SUCCESS;
}

void ReadTxt() 
{
    std::string line_;
    ifstream file_("Nam.Password.txt");
    if (file_.is_open())
    {
        std::cout << "Reading file" << '\n' << endl;
        while (getline(file_, line_))
        {
            std::cout << line_ << '\n' << endl;
        }
    }
    else
    {
        std::cout << "File not found" << '\n' << endl;
    }
}

Convert C++ code in C language

           HI everyone,

_SBLOCK allocateMemBlock(size_t size)
[
_SBLOCK
block = (_SBLOCK)sbrk(0);
void
memadr = (void)sbrk(0);
void
allocate_mem = (void)sbrk(BLOCK_SIZE + size);
if(allocate_mem == (void
)-1)
[
return NULL;
]
else
[
block->next = NULL;
block->isfree = false;
block->size = size;
block->memoryAddress = memadr+BLOCK_SIZE;
return block;
]

C++ Pyramid of numbers: Print numbers that count by two’s and not by one’s

Hello. I am taking a "Data Structures" class. I have to create a code that will print the following "Output":
8 6 4 2 0
6 4 2 0
4 2 0
2 0
0

I tried doing this code three different ways. Here is the first way. I did a similar project in "Java" so I knew I needed a "Nested Loop. I just "re-wrote" the code in "C++" but it does not print the correct numbers. I have to print the numbers in a way that the numbers count by "two's" and not "one's":

for(int i = 8; i >= 1; --i){
    for(int j = 1; j <= i; ++j){
        cout << j << " ";
     }
     cout << endl;
    }
return 0;

Here is the second way. This is incorrect becasue the output prints too many numbers:

for(int count = 8; count >= 1; --count){
    for(int index = 1; index <= count; ++index){
        for (int num = 8; num >= 0; num = num - 2) {
            cout << num << " ";
        }
    }
    cout << endl;
}

Here is the third way. This is incorrect becasue the teacher said this is still considered "Hard Coding" which is not allowed:

 char str[] = "86420 6420 420 20 0";  

 char *token = strtok(str, " "); 

 while (token != NULL) { 
    printf("%s\n", token); 
    token = strtok(NULL, " "); 
  }

return 0; 

My main problem is this (this program seems so simple and I think I have a general idea on how to solve this so I apologize if this question has an easy answer): How do I manipuate the numbers to print "86420" on the first row, "6420" on the second row etc...? I was told that I would need to print these numbers in a "horizontal line" then use a "two level nested loop" to manipulate how the numbers are printed but this is the part I am having trouble with. I can manipulate how the numbers print itself but I can not get the numbers to print correctly.

I tried to find examples of this on "Dani Web" and online but none of them answerd my main question. Please help and thank you in advance to anyone who can help me solve this problem.

The ‘= NULL’ Mistake and Other SQL NULL Heresies

The SQL Prompt Best Practice rule checks whether a comparison or expression includes a NULL literal ('NULL'), which in SQL Server, rather than result in an error, will simply always produce a NULL result. Phil Factor explains how to avoid this, and other SQL NULL-related calamities.

SQL Prompt has a code analysis rule (BP011) that checks whether a comparison or expression includes a NULL literal ('NULL'). These will always produce a NULL result. To determine whether a datatype is or isn’t NULL, use ISNULLor ISNOTNULL.

A Look at Java Optionals

Optional is a container object that may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.

Package : java.util
public final class Optional<T>
extendsObject


A program to list a code listing (beginner stuff

I just started learning C with a book called "Sams | Teach Yourself C in 21 Days, 6th edition" and I've already run into a problem I can't solve. The book gives a program that is supposed to display any code from any saved source file - including its own. As the book states on page 37, "The list_it.c program in Listing 2.2 displays C program listings that you have saved. These listings are displayed on the screen with line numbers added."

The problem is that I don't know how to use it to make it work and the book doesn't give any specific instructions for using it. What am I supposed to do with it? I'm using Dev C++ and when I run it all I get is this:

            Proper Usage is:

            list_it filename.ext

I've tried renaming and recompliling this program with two different filenames - list_it multiply.c and list_it list_it.c and it just gave me scrambled junk. I've also tried opening multiply.c and using the same approach and I got the same result.
Here's the code:

/* list_it.c - This program displays a listing with line numbers! */

#include <stdio.h>
#include <stdlib.h>

void display_usage(void);
int line;

int main( int argc, char *argv[] )
{
    char buffer[256];
    FILE *fp;

    if(argc < 2)
    {
        display_usage();
        return 1;
    }

    if (( fp = fopen( argv[1], "r" )) == NULL )
    {

        fprintf( stderr, "Error opening file, %s!", argv[1] );
        return(1);

    }

    line = 1;

    while( fgets( buffer, 256, fp ) != NULL )
        fprintf( stdout, "%4d:\t%s", line++, buffer );

    fclose(fp);
    return 0;

}   

void display_usage(void)
{
    fprintf(stderr, "\nProper Usage is: " );
    fprintf(stderr, "\n\nlist_it filename.ext\n" );
}

All time show NULL value please help me…

All Time Show Null value
Please help me what is the wrong in my code

declare @mxdbvlu  int
 declare @dbvlunm int
  set @mxdbvlu= (select max(Database_name) from TBL_FY_SELECT_1)
 if @mxdbvlu = null 
 set @dbvlunm=1000
 else 
 set @dbvlunm=sum(@mxdbvlu+1)
  select @dbvlunm,@mxdbvlu

How to store data from file redirect to new file using C

Hi all,

I am working on a project that should take all the data from file redirect and write them to a new file. Here is what I have:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "node.h"
#include "tree.h"

#define TRUE 0
#define FALSE 1
#define stdin stdin
#define stdout stdout
#define stderr stderr

    int main(int argc,char *argv[])
    {
    int i;
    FILE *fp;

    fp = fopen("result.out", "w"); //create file to write stdin data to. 

    if(fp == NULL) // file validation
    {
    printf("Could not open file");
    return 0;
    }

     if(argc == 1) // executes if command line has file redirect. 
    {
    printf("Getting data from file redirect. \n");
    fprintf (fp, "%s\n", stdin); //Print arguments from redirect to fp.

    }
     printf("Completed\n");
    return 0;
    }

This code will execute fine with no errors, but result.out is empty
The file being redirected only contains words separated by spaces.
I also never know the size of the file being redirected.
I just want to copy the data from the file being redirected to result.out.

Any suggestions on how I can improve the code?