Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why did I write this code?
Message
From
15/12/2021 14:38:53
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01682961
Message ID:
01682966
Views:
50
>>>Hi,
>>>
>>>I know I should not be admitting to writing some stupid code. But I was refactoring code in one method where I have the following, in a long SQL Select.
>>>
>>>isnul( table1.table_pk,11) as table1_pk  
>>>
>>>Since this is a PK value of a table, it should never be NULL.
>>>But suppose I was being extra cautious, why "11"?
>>>
>>>Please no name calling :)
>>
>>Maybe this is from LEFT join to table1.
>>If it is so you can have NULL values in the query.
>>
>>WHY 11? Only you can tell :-)
>>Maybe 11 is impossible value and that way you recognize these records?
>>
>>The example is from VFP but it is valid to TSQL too
>>
>>CREATE CURSOR Tbl1 (Fld1 int, Fld2 char(2))  && Let say you have Primary key based on Fld1
>>INSERT INTO Tbl1 (Fld1, Fld2) VALUES (1, [aa])
>>INSERT INTO Tbl1 (Fld1, Fld2) VALUES (2, [bb])
>>
>>CREATE CURSOR Tbl2 (Fld1 int, Fld2 char(2))
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (1, [cc])
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (2, [dd])
>>INSERT INTO Tbl2 (Fld1, Fld2) VALUES (3, [ee])
>>
>>SELECT Tbl2.*,;
>>       NVL(Tbl1.Fld1, 11) AS Tbl1Fld1;
>>FROM Tbl2;
>>LEFT JOIN Tbl1 ON Tbl2.Fld1 = Tbl1.Fld1
>>
>
>Your point about the LEFT join makes sense. The SQL Select does have a LEFT joint of the same table. Which I am trying to eliminate. And I will check the code, down from this SQL Select, if the value 11 is being considered anywhere (as possible).
>Thank you!

Considering that, I have some tables with fixed, predefined PK's that are used in special cases. Something like that? What is the record with PK 11?
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform